body {
    font-family: Arial, sans-serif;
    background:#f4f6f8;
    margin:0;
    color:#111827;
}

.layout {
    display:flex;
    min-height:100vh;
}

.sidebar {
    width:230px;
    background:#111827;
    color:white;
    padding:24px 18px;
    flex-shrink:0;
}

.sidebar h2 {
    font-size:18px;
    margin:0 0 28px;
}

.sidebar .section {
    color:#6b7280;
    font-size:12px;
    margin:22px 0 8px;
    text-transform:uppercase;
    letter-spacing:.04em;
}

.sidebar a {
    display:block;
    color:#d1d5db;
    text-decoration:none;
    padding:10px 0;
    font-size:14px;
}

.sidebar a.active {
    color:white;
    font-weight:bold;
}

.content {
    flex:1;
    padding:28px;
    min-width:0;
}

h1 {
    margin:0 0 6px;
    font-size:30px;
}

h2 {
    margin-top:0;
}

.subtitle {
    color:#6b7280;
    margin-bottom:22px;
    font-size:16px;
}

.topbar {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:14px;
    margin-bottom:22px;
}

.status-box {
    background:white;
    padding:12px 16px;
    border-radius:12px;
    box-shadow:0 2px 8px rgba(0,0,0,.05);
    color:#374151;
    font-size:14px;
}

.status-dot {
    display:inline-block;
    width:9px;
    height:9px;
    border-radius:50%;
    background:#22c55e;
    margin-right:7px;
}

.grid {
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:16px;
    margin-bottom:24px;
}

.card {
    background:white;
    padding:20px;
    border-radius:14px;
    box-shadow:0 2px 8px rgba(0,0,0,.06);
    text-decoration:none;
    color:#111827;
    display:block;
    transition:.15s ease;
}

.card:hover {
    transform:translateY(-2px);
    box-shadow:0 8px 18px rgba(0,0,0,.08);
}

.card span {
    display:block;
    color:#6b7280;
    font-size:14px;
    margin-bottom:10px;
}

.card strong {
    font-size:30px;
}

.card small {
    display:block;
    margin-top:8px;
    color:#9ca3af;
    font-size:12px;
}

.warning strong { color:#b45309; }
.danger strong { color:#991b1b; }
.success strong { color:#166534; }

.panels {
    display:grid;
    grid-template-columns:2fr 1fr;
    gap:18px;
    align-items:start;
}

.panel {
    background:white;
    border-radius:14px;
    box-shadow:0 2px 8px rgba(0,0,0,.05);
    overflow:hidden;
}

.panel h2 {
    font-size:18px;
    padding:18px;
    margin:0;
    border-bottom:1px solid #e5e7eb;
}

.filters {
    background:white;
    padding:18px;
    border-radius:12px;
    margin-bottom:18px;
    box-shadow:0 2px 8px rgba(0,0,0,.05);
    display:flex;
    gap:12px;
    align-items:center;
    flex-wrap:wrap;
}

input,
select {
    padding:10px 12px;
    border:1px solid #d1d5db;
    border-radius:8px;
    font-size:14px;
}

input {
    min-width:320px;
}

button,
.clear {
    padding:10px 14px;
    border-radius:8px;
    border:0;
    background:#111827;
    color:white;
    cursor:pointer;
    text-decoration:none;
    font-size:14px;
}

.clear {
    background:#6b7280;
}

.table-wrap {
    width:100%;
    overflow-x:auto;
    background:white;
    border-radius:12px;
    box-shadow:0 2px 8px rgba(0,0,0,.05);
}

table {
    width:100%;
    border-collapse:collapse;
}

.table-wrap table {
    min-width:1200px;
}

th,
td {
    padding:12px 14px;
    border-bottom:1px solid #e5e7eb;
    text-align:left;
    font-size:14px;
    vertical-align:top;
}

th {
    background:#111827;
    color:white;
}

.badge {
    display:inline-block;
    padding:4px 9px;
    border-radius:999px;
    font-size:12px;
    white-space:nowrap;
    background:#eef2ff;
    color:#3730a3;
}

.inbound,
.badge.inbound {
    background:#dcfce7;
    color:#166534;
}

.outbound,
.badge.outbound {
    background:#dbeafe;
    color:#1e40af;
}

.status-open,
.status-failed,
.status-canceled,
.status-cancelled,
.stock-out_of_stock,
.resolved-0,
.resolved-false,
.active-0,
.active-false,
.dnc-1,
.dnc-true {
    background:#fee2e2;
    color:#991b1b;
}

.status-sent,
.status-resolved,
.status-confirmed,
.status-delivered,
.stock-in_stock,
.resolved-1,
.resolved-true,
.active-1,
.active-true,
.dnc-0,
.dnc-false {
    background:#dcfce7;
    color:#166534;
}

.status-pending,
.status-assigned,
.priority-medium,
.priority-high,
.stock-limited,
.confirm-pending {
    background:#fef3c7;
    color:#92400e;
}

.priority-urgent {
    background:#7f1d1d;
    color:white;
}

.message,
.msg,
.notes,
.keywords,
.items,
.vars,
.failure {
    line-height:1.5;
}

.message {
    max-width:520px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.msg,
.notes,
.keywords,
.items,
.vars,
.failure {
    min-width:260px;
    max-width:560px;
}

.quick-list {
    padding:12px 18px 18px;
}

.quick-list a {
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:12px 0;
    border-bottom:1px solid #e5e7eb;
    color:#111827;
    text-decoration:none;
    font-size:14px;
}

.quick-list a:last-child {
    border-bottom:0;
}

.quick-list span {
    color:#6b7280;
}

.empty {
    background:white;
    padding:24px;
    border-radius:12px;
    color:#6b7280;
}

.pagination {
    margin-top:18px;
    background:white;
    padding:14px;
    border-radius:12px;
}

.pagination nav > div:first-child {
    display:none;
}

@media (max-width:1100px) {
    .grid {
        grid-template-columns:repeat(2,minmax(0,1fr));
    }

    .panels {
        grid-template-columns:1fr;
    }
}

@media (max-width:900px) {
    .sidebar {
        display:none;
    }

    .content {
        padding:18px;
    }

    .grid {
        grid-template-columns:1fr;
    }

    .topbar {
        align-items:flex-start;
        flex-direction:column;
    }

    input {
        min-width:100%;
    }
}

.sidebar h2 {
    color: #38bdf8;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
}

.card,
.panel,
.filters,
.table-wrap,
.empty,
.status-box {
    border: 1px solid #eef2f7;
}

.table-wrap {
    overflow-x: auto;
}

td.message,
td.msg,
td.notes,
td.keywords,
td.items,
td.vars,
td.failure {
    word-break: break-word;
}

td[dir="rtl"],
.message,
.msg {
    unicode-bidi: plaintext;
}

.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: #111827;
    box-shadow: 0 0 0 3px rgba(17,24,39,.08);
}

button:hover,
.clear:hover {
    opacity: .92;
}

.sidebar a:hover {
    color: white;
}

/* Dashboard cleanup: remove duplicated Quick Access panel */
.panels {
    grid-template-columns: 1fr;
}

.panels .panel:nth-child(2) {
    display: none;
}

/* Better sidebar grouping */
.sidebar .section {
    margin-top: 26px;
    margin-bottom: 8px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
}

.sidebar a {
    padding: 11px 12px;
    border-radius: 10px;
    margin-bottom: 4px;
}

.sidebar a:hover {
    background: rgba(255,255,255,.06);
    color: white;
}

.sidebar a.active {
    background: rgba(56,189,248,.12);
    color: #ffffff;
    border-left: 3px solid #38bdf8;
    padding-left: 9px;
}

/* Better content width after removing Quick Access */
.panel {
    width: 100%;
}

/* Professional collapsible sidebar */
.sidebar {
    width: 250px;
    transition: width .2s ease;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 26px;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 18px;
    color: white;
    line-height: 1.2;
}

.sidebar-header small {
    display: block;
    color: #64748b;
    margin-top: 5px;
    font-size: 11px;
}

.sidebar-toggle {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    color: white;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(56,189,248,.18);
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 26px;
}

.nav-icon {
    width: 24px;
    min-width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 15px;
    color: #cbd5e1;
}

.sidebar a.active .nav-icon {
    background: rgba(56,189,248,.18);
    color: #38bdf8;
}

.nav-text {
    white-space: nowrap;
}

/* collapsed mode */
body.sidebar-collapsed .sidebar {
    width: 78px;
    padding-left: 14px;
    padding-right: 14px;
}

body.sidebar-collapsed .sidebar-header {
    justify-content: center;
}

body.sidebar-collapsed .sidebar-header h2,
body.sidebar-collapsed .sidebar-header small,
body.sidebar-collapsed .section,
body.sidebar-collapsed .nav-text {
    display: none;
}

body.sidebar-collapsed .sidebar a {
    justify-content: center;
    padding: 12px 8px;
}

body.sidebar-collapsed .sidebar a.active {
    border-left: 0;
    padding-left: 8px;
}

body.sidebar-collapsed .nav-icon {
    margin: 0;
}

body.sidebar-collapsed .sidebar-toggle {
    margin: 0 auto;
}

/* better sidebar section spacing */
.sidebar .section {
    margin-top: 24px;
    margin-bottom: 8px;
}

/* dashboard latest messages now full width */
.panels {
    grid-template-columns: 1fr !important;
}

.panels .panel:nth-child(2) {
    display: none !important;
}

/* Sidebar professional navigation with quick counts */
.sidebar {
    width: 270px;
    background: #0f172a;
    transition: width .22s ease;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 28px;
}

.brand-block h2,
.sidebar-header h2 {
    margin: 0;
    font-size: 18px;
    color: #ffffff;
    letter-spacing: -.02em;
}

.brand-block small,
.sidebar-header small {
    display: block;
    color: #94a3b8;
    margin-top: 5px;
    font-size: 11px;
}

.sidebar-toggle {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    color: white;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(56,189,248,.18);
}

.sidebar .section {
    margin: 26px 0 9px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .10em;
    text-transform: uppercase;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    margin-bottom: 5px;
    border-radius: 12px;
    color: #dbeafe;
    text-decoration: none;
    font-size: 14px;
    position: relative;
}

.sidebar a:hover {
    background: rgba(255,255,255,.06);
    color: white;
}

.sidebar a.active {
    background: #14324a;
    color: #ffffff;
    border-left: 3px solid #38bdf8;
    padding-left: 9px;
}

.nav-icon {
    width: 25px;
    min-width: 25px;
    height: 25px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #bfdbfe;
    background: rgba(148,163,184,.08);
    font-size: 14px;
}

.sidebar a.active .nav-icon {
    background: rgba(56,189,248,.20);
    color: #38bdf8;
}

.nav-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-badge {
    margin-left: auto;
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(59,130,246,.16);
    color: #93c5fd;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-badge.muted {
    background: rgba(148,163,184,.13);
    color: #cbd5e1;
}

.nav-badge.warning {
    background: rgba(245,158,11,.15);
    color: #fbbf24;
}

.nav-badge.danger {
    background: rgba(239,68,68,.16);
    color: #fca5a5;
}

.nav-badge.success {
    background: rgba(34,197,94,.15);
    color: #86efac;
}

.sidebar-footer {
    margin-top: 30px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,.05);
    color: #cbd5e1;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-footer .status-dot {
    margin-right: 0;
}

/* Collapsed sidebar */
body.sidebar-collapsed .sidebar {
    width: 82px;
    padding-left: 14px;
    padding-right: 14px;
}

body.sidebar-collapsed .brand-block,
body.sidebar-collapsed .section,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-badge,
body.sidebar-collapsed .sidebar-footer {
    display: none;
}

body.sidebar-collapsed .sidebar-header {
    justify-content: center;
}

body.sidebar-collapsed .sidebar a {
    justify-content: center;
    padding: 12px 8px;
}

body.sidebar-collapsed .sidebar a.active {
    border-left: 0;
    padding-left: 8px;
}

body.sidebar-collapsed .nav-icon {
    margin: 0;
}

body.sidebar-collapsed .sidebar-toggle {
    margin: 0 auto;
}

/* Remove old Quick Access panel permanently */
.panels {
    grid-template-columns: 1fr !important;
}

.panels .panel:nth-child(2) {
    display: none !important;
}

/* Better dashboard spacing after removing Quick Access */
.content {
    max-width: none;
}

.panel {
    width: 100%;
}

/* Small page-level stats */
.mini-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.mini-card {
    background: white;
    border: 1px solid #eef2f7;
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.mini-card span {
    display: block;
    color: #64748b;
    font-size: 13px;
    margin-bottom: 8px;
}

.mini-card strong {
    display: block;
    font-size: 26px;
    color: #111827;
}

.mini-card.warning strong {
    color: #b45309;
}

.mini-card.success strong {
    color: #166534;
}

.mini-card.danger strong {
    color: #991b1b;
}

@media (max-width: 900px) {
    .mini-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Dashboard cards refinement */
.card {
    border: 1px solid #eef2f7;
    position: relative;
    overflow: hidden;
}

.card::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    width: 5px;
    height: 100%;
    background: #e5e7eb;
}

.card.warning::after {
    background: #f59e0b;
}

.card.danger::after {
    background: #ef4444;
}

.card.success::after {
    background: #22c55e;
}

.card strong {
    letter-spacing: -0.04em;
}

.panel table td {
    color: #374151;
}

.panel table th {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.panel .message {
    max-width: 700px;
}

.card.neutral strong {
    color: #334155;
}

.card.neutral::after {
    background: #cbd5e1;
}

.nav-badge.neutral {
    background: rgba(148,163,184,.16);
    color: #cbd5e1;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top left, rgba(56,189,248,.16), transparent 30%),
        #f4f6f8;
}

.login-card {
    width: 390px;
    background: white;
    border: 1px solid #eef2f7;
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 16px 40px rgba(15,23,42,.10);
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 26px;
}

.login-card p {
    margin: 0 0 24px;
    color: #64748b;
    font-size: 14px;
}

.login-card label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    color: #334155;
    font-weight: 700;
}

.login-card input[type="email"],
.login-card input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 16px;
}

.login-card .remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    margin-bottom: 18px;
}

.login-card .remember input {
    min-width: auto;
}

.login-card button {
    width: 100%;
    padding: 12px 14px;
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
}

.sidebar-user {
    margin-top: 18px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,.05);
    color: #cbd5e1;
    font-size: 13px;
}

.sidebar-user strong {
    display: block;
    color: white;
    margin-bottom: 3px;
}

.sidebar-user small {
    color: #94a3b8;
}

.logout-form {
    margin-top: 10px;
}

.logout-btn {
    width: 100%;
    background: rgba(239,68,68,.12);
    color: #fecaca;
    padding: 9px 10px;
    font-size: 13px;
}

.logout-btn:hover {
    background: rgba(239,68,68,.20);
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.action-btn {
    background: #111827;
    color: white;
    text-decoration: none;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 14px;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}

.success-alert {
    background: #dcfce7;
    color: #166534;
}

.error-alert {
    background: #fee2e2;
    color: #991b1b;
}

.form-card {
    background: white;
    border: 1px solid #eef2f7;
    border-radius: 16px;
    padding: 22px;
    max-width: 620px;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.form-card label {
    display: block;
    margin: 14px 0 7px;
    font-weight: 700;
    font-size: 13px;
    color: #334155;
}

.form-card input,
.form-card select {
    width: 100%;
    box-sizing: border-box;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.actions-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.actions-cell form {
    margin: 0;
}

.small-btn {
    display: inline-block;
    background: #111827;
    color: white;
    text-decoration: none;
    border: 0;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
}

.danger-btn {
    background: #991b1b;
}

.role-super_admin {
    background: #ede9fe;
    color: #5b21b6;
}

.role-admin {
    background: #dbeafe;
    color: #1e40af;
}

.role-user {
    background: #f1f5f9;
    color: #334155;
}

.required {
    color: #dc2626;
    font-weight: 800;
}

.optional {
    color: #94a3b8;
    font-weight: 400;
    font-size: 12px;
}

.settings-section {
    background: white;
    border: 1px solid #eef2f7;
    border-radius: 16px;
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.settings-section h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.settings-section p {
    margin: 0 0 18px;
    color: #64748b;
    font-size: 14px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.setting-card {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 15px;
    background: #f8fafc;
}

.setting-card label {
    display: block;
    font-size: 13px;
    font-weight: 800;
    color: #334155;
    margin-bottom: 8px;
}

.setting-card input {
    width: 100%;
    box-sizing: border-box;
    background: white;
}

.setting-card small {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.4;
}

.sensitive-setting {
    background: #fff7ed;
    border-color: #fed7aa;
}

.masked-value {
    background: white;
    border: 1px dashed #fb923c;
    color: #9a3412;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 700;
}

@media (max-width: 1100px) {
    .settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

.setting-card textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    background: white;
}

.advanced-setting {
    background: #f8fafc;
    border-color: #dbeafe;
}

.settings-subtitle {
    margin: 20px 0 12px;
    font-size: 16px;
    color: #0f172a;
}

.empty-card {
    padding: 16px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    color: #64748b;
}

.sticky-save {
    margin: 0 0 22px;
}

.form-card textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    background: white;
}
