:root {
    --bg:        #fffff;
    --surface:   #fefeff;
    --surface2:  #ffffff;
    --border:    #2a2f42;
    --accent:    #1f2333;
    --accent2:   #000000;
    --success:   #83ee7b;
    --warning:   #fbbf24;
    --danger:    #f87171;
    --text:      #0c36dc;
    --muted:     #00125a;
    --sidebar-w: 210px;
    --header-h:  50px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    font-size: 13px;
}

/* ── Sidebar ─────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    max-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    overflow: hidden;
}
.sidebar-logo {
    padding: .9rem 1rem .75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-logo span {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -.3px;
    color: var(--text);
}
.sidebar-logo small {
    display: block;
    font-size: .82rem;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    margin-top: 2px;
}
.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
    overflow-y: auto;
    min-height: 0;
}

.nav-section {
    padding: .5rem 1rem .25rem;
    font-size: .70rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .42rem 1rem;
    color: var(--muted);
    text-decoration: none;
    font-size: .8rem;
    font-weight: 400;
    transition: all .15s;
    border-left: 3px solid transparent;
    margin: 1px 0;
}
.nav-item:hover {
    color: var(--text);
    background: var(--surface2);
}
.nav-item.active {
    color: var(--accent);
    background: rgba(91,110,245,.1);
    border-left-color: var(--accent);
    font-weight: 500;
}
.nav-icon { font-size: 1rem; width: 18px; text-align: center; }

.sidebar-user {
    padding: .65rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .65rem;
    flex-shrink: 0;
}
.user-avatar {
    width: 30px; height: 30px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong {
    display: block;
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-info small { font-size: .7rem; color: var(--muted); }
.logout-btn {
    color: var(--muted);
    text-decoration: none;
    font-size: .9rem;
    transition: color .15s;
}
.logout-btn:hover { color: var(--danger); }

/* ── Main area ───────────────────────── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h1 {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.badge-pill {
    font-size: .7rem;
    font-family: 'DM Mono', monospace;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: .2rem .6rem;
    border-radius: 999px;
}

.page-body {
    padding: 1.25rem 1.5rem;
    flex: 1;
}

/* ── Shared components ───────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.page-header h2 { font-size: 1.1rem; font-weight: 600; }
.page-header p  { font-size: .78rem; color: var(--muted); margin-top: .15rem; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .85rem;
    border-radius: 7px;
    font-size: .8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all .15s;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4a5ce0; }
.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: rgba(248,113,113,.12); color: var(--danger); border: 1px solid rgba(248,113,113,.25); }
.btn-danger:hover { background: rgba(248,113,113,.2); }
.btn-sm { padding: .3rem .7rem; font-size: .78rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}

.stat-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1rem;
}
.stat-card {
    flex: 1 1 140px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .75rem 1rem;
}
.stat-card .label { font-size: .80rem; color: var(--muted); margin-bottom: .4rem; }
.stat-card .value {
    font-size: clamp(.9rem, 4.5vw, 1.35rem);
    font-weight: 600;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-all;
}
.stat-card .sub   { font-size: .80rem; color: var(--muted); margin-top: .25rem; }

table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--border);
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface2); }
tbody td {
    padding: .55rem .75rem;
    font-size: .8rem;
    border-bottom: 1px solid rgba(42,47,66,.6);
    vertical-align: middle;
}

.status-badge {
    display: inline-block;
    font-size: .7rem;
    font-weight: 500;
    font-family: 'DM Mono', monospace;
    padding: .2rem .65rem;
    border-radius: 999px;
}
.s-completed, .s-received, .s-delivered, .s-paid { background: rgba(52,211,153,.12); color: var(--success); }
.s-processing, .s-in-progress, .s-in-transit, .s-sent { background: rgba(56,189,248,.12); color: var(--accent2); }
.s-pending, .s-draft, .s-scheduled { background: rgba(251,191,36,.12); color: var(--warning); }
.s-cancelled, .s-on-hold, .s-overdue { background: rgba(248,113,113,.12); color: var(--danger); }

.mono { font-family: 'DM Mono', monospace; font-size: .8rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; }

.alert { padding: .8rem 1rem; border-radius: 8px; font-size: .875rem; margin-bottom: 1rem; }
.alert-danger  { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); color: var(--danger); }
.alert-success { background: rgba(52,211,153,.1);  border: 1px solid rgba(52,211,153,.3);  color: var(--success); }

/* Modal */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(2px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.75rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .78rem; font-weight: 500; color: var(--muted); margin-bottom: .35rem; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: .6rem .85rem;
    font-size: .884rem;
    font-family: inherit;
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group select option { background: var(--surface2); }

/* ── Login page (auth/*) ───────────────── */
html, body { height: 100%; }
body.login-page {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4f8;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.login-page .card {
    background: #fff;
    border: none;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
}

body.login-page .logo { text-align: center; margin-bottom: 1.75rem; }
body.login-page .logo h1 { font-size: 1.6rem; font-weight: 700; color: #1a202c; }
body.login-page .logo p { color: #718096; font-size: .9rem; margin-top: .25rem; }

body.login-page .form-group { margin-bottom: 1.1rem; }
body.login-page label { display: block; font-size: .85rem; font-weight: 600; color: #4a5568; margin-bottom: .4rem; }

body.login-page input[type="email"],
body.login-page input[type="password"] {
    width: 100%;
    padding: .65rem .9rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: .95rem;
    color: #2d3748;
    transition: border-color .2s;
    outline: none;
}
body.login-page input:focus { border-color: #4f46e5; }

body.login-page .btn {
    width: 100%;
    padding: .75rem;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: .5rem;
    transition: background .2s;
}
body.login-page .btn:hover { background: #4338ca; }

body.login-page .error {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
    border-radius: 8px;
    padding: .7rem .9rem;
    font-size: .88rem;
    margin-bottom: 1rem;
}

body.login-page .footer-text { text-align: center; margin-top: 1.25rem; font-size: .88rem; color: #718096; }
body.login-page .footer-text a { color: #4f46e5; text-decoration: none; font-weight: 600; }
body.login-page .footer-text a:hover { text-decoration: underline; }

