/* =====================================================================
   Koul Chandan & Co. — Design tokens
   Ledger / index-tab aesthetic: ink sidebar, paper canvas, brass accent
   ===================================================================== */
:root {
    --ink: #16233f;
    --ink-2: #1f3157;
    --ink-3: #2a3f6b;
    --paper: #f2f1ec;
    --paper-raised: #ffffff;
    --line: #e0ddd3;
    --text: #1c1f26;
    --muted: #6b7280;
    --brass: #a97a34;
    --brass-light: #c99a52;
    --danger: #b0342d;
    --danger-bg: #fbeceb;

    --font-display: 'Source Serif 4', 'Georgia', serif;
    --font-body: 'IBM Plex Sans', 'Segoe UI', Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Consolas', monospace;

    --sidebar-w: 252px;
    --sidebar-w-collapsed: 68px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--text);
    font-size: 14px;
}

/* ---------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------- */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--ink);
    color: #dbe2f0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.18s ease;
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 30px;
}
.brand-mark {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 1.5px solid var(--brass-light);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--brass-light);
    transform: rotate(45deg);
}
.brand-mark span { transform: rotate(-45deg); }
.brand-text {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: #f2efe6;
    white-space: normal;
    overflow: visible;
    flex: 1;
    min-width: 0;
}
.brand-text small {
    display: block;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 10.5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8fa0c2;
    margin-top: 2px;
}
.sidebar.collapsed .brand-text { display: none; }

.sidebar-toggle {
    background: none;
    border: none;
    color: #8fa0c2;
    cursor: pointer;
    padding: 6px;
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    border-radius: 4px;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar.collapsed .sidebar-toggle { margin-left: 0; }
.sidebar.collapsed .sidebar-head { justify-content: center; }

/* ---------------------------------------------------------------------
   Nav
   --------------------------------------------------------------------- */
.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-eyebrow {
    font-size: 10px;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #5f7093;
    padding: 10px 10px 6px;
    font-weight: 600;
}
.sidebar.collapsed .nav-eyebrow { display: none; }

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 5px;
    color: #c3cee3;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
    background: var(--ink-3);
    color: #fff;
}
/* Signature: index-tab notch on the active item, biting into the content edge */
.nav-item.active::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 22px;
    background: var(--paper);
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
    border-top: 2px solid var(--brass);
    border-bottom: 2px solid var(--brass);
    border-left: 2px solid var(--brass);
}
.sidebar.collapsed .nav-item.active::after { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-label { display: none; }

.sidebar-foot {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 12px 10px;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
}
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ink-3);
    color: var(--brass-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}
.user-meta { overflow: hidden; white-space: nowrap; }
.user-name { font-size: 12.5px; font-weight: 600; color: #f2efe6; }
.user-role { font-size: 10.5px; color: #8fa0c2; text-transform: capitalize; }
.sidebar.collapsed .user-meta { display: none; }
.sidebar.collapsed .user-chip { justify-content: center; }

.logout-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin-top: 4px;
    color: #c3cee3;
    text-decoration: none;
    font-size: 13px;
    border-radius: 5px;
}
.logout-link:hover { background: rgba(176,52,45,0.18); color: #ffb3ad; }
.logout-link svg { flex-shrink: 0; width: 17px; height: 17px; }
.sidebar.collapsed .logout-link { justify-content: center; }
.sidebar.collapsed .logout-link .nav-label { display: none; }

/* ---------------------------------------------------------------------
   Main content
   --------------------------------------------------------------------- */
.app-main { flex: 1; min-width: 0; }
.container { max-width: 1100px; margin: 0 auto; padding: 32px 28px; }

.card {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 1px 2px rgba(22,35,63,0.04);
    margin-bottom: 20px;
}
.card h2 {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    margin: 0 0 14px;
    color: var(--ink);
}
.card h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 14px;
    color: var(--ink);
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
th {
    background: #faf9f5;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.18s ease; }
tbody tr:hover { background: #faf7ee; }

.btn {
    display: inline-block;
    background: var(--ink);
    color: #fff;
    padding: 8px 16px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    margin-bottom: 14px;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { background: var(--ink-2); transform: translateY(-2px); box-shadow: 0 8px 18px rgba(22,35,63,0.20); }

.stat-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.stat-box {
    flex: 1;
    min-width: 150px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 14px 16px;
    background: var(--paper-raised);
    position: relative;
    overflow: hidden;
    cursor: default;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.3s ease;
}
.stat-box::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--brass);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}
.stat-box:hover {
    background: var(--ink);
    transform: translateY(-4px);
    box-shadow: 0 14px 28px rgba(22,35,63,0.20);
}
.stat-box:hover::before { transform: scaleX(1); }
.stat-box .num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 26px;
    font-weight: 600;
    color: var(--ink);
    transition: color 0.3s ease;
}
.stat-box:hover .num { color: var(--brass-light); }
.stat-box .label { font-size: 12px; color: var(--muted); margin-top: 2px; transition: color 0.3s ease; }
.stat-box:hover .label { color: #c3cee3; }

.footer { text-align: center; padding: 18px; font-size: 11.5px; color: var(--muted); }

form input, form select, form textarea {
    width: 100%;
    padding: 8px 10px;
    margin: 6px 0 14px;
    border: 1px solid var(--line);
    border-radius: 5px;
    font-size: 13.5px;
    font-family: var(--font-body);
    background: var(--paper-raised);
}
form input:focus, form select:focus, form textarea:focus {
    outline: 2px solid var(--brass-light);
    outline-offset: 1px;
    border-color: var(--brass);
}
label { font-size: 12.5px; font-weight: 600; color: #444; }

@media (max-width: 720px) {
    .sidebar { position: fixed; left: 0; height: 100vh; }
    .container { padding: 20px 16px; }
}
