/* ============================================================
   Hardware Shop — slate & brass
   Dense, high-contrast admin theme built for fast counter entry.
   ============================================================ */
:root {
    --ink:        #1A2733;
    --ink-2:      #22323F;
    --ink-3:      #33465A;
    --brand:      #0F4C81;
    --brand-dark: #0B3A63;
    --brass:      #C08A2E;
    --brass-soft: #F6EEDD;
    --ok:         #12805C;
    --warn:       #B54708;
    --danger:     #B42318;
    --canvas:     #EEF1F5;
    --surface:    #FFFFFF;
    --line:       #DCE3EB;
    --line-soft:  #EDF1F5;
    --text:       #1E2A36;
    --muted:      #64748B;
    --radius:     10px;
    --sidebar-w:  244px;
    --shadow:     0 1px 2px rgba(16,32,48,.06), 0 4px 14px rgba(16,32,48,.05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--canvas);
    color: var(--text);
    font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* numbers line up in columns — matters on every money screen */
.num, td.num, th.num, .amount, input[type=number] {
    font-family: 'JetBrains Mono', ui-monospace, 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
}
.num, td.num, th.num { text-align: right; white-space: nowrap; }

/* Reference numbers — invoice no, GSTIN, IP, bill no. They want the tabular
   typeface but read left to right, so right-aligning them under a left-aligned
   header just looked broken. */
.mono, td.mono, th.mono {
    font-family: 'JetBrains Mono', ui-monospace, 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
    text-align: left;
    white-space: nowrap;
}

/* ---------------- sidebar ---------------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--ink); color: #C7D3DF;
    display: flex; flex-direction: column; z-index: 1040;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-mark {
    width: 34px; height: 34px; border-radius: 8px; flex: none;
    background: var(--brass); color: var(--ink);
    display: grid; place-items: center; font-size: 17px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 14px; letter-spacing: .2px; }
.brand-text small { color: #7E93A8; font-size: 11px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0 20px; }
.nav-group {
    padding: 14px 16px 6px; font-size: 10px; font-weight: 700;
    letter-spacing: .13em; text-transform: uppercase; color: #6B8199;
}
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px; color: #BDCBD9; font-size: 13.5px;
    border-left: 3px solid transparent; text-decoration: none;
}
.sidebar-nav .nav-link i { width: 18px; font-size: 15px; color: #7E93A8; }
.sidebar-nav .nav-link:hover { background: var(--ink-2); color: #fff; }
.sidebar-nav .nav-link:hover i { color: #BDCBD9; }
/* brass edge marks the screen you are on */
.sidebar-nav .nav-link.active {
    background: var(--ink-2); color: #fff;
    border-left-color: var(--brass); font-weight: 600;
}
.sidebar-nav .nav-link.active i { color: var(--brass); }

.sidebar-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.07); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .avatar {
    width: 32px; height: 32px; border-radius: 50%; flex: none;
    background: var(--brand); color: #fff; display: grid; place-items: center;
    font-weight: 600; font-size: 13px;
}
.user-chip span span, .user-chip > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.user-chip strong { color: #fff; font-size: 12.5px; }
.user-chip small { color: #7E93A8; font-size: 11px; }

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(12,20,28,.5);
    z-index: 1035; display: none;
}
.sidebar-backdrop.show { display: block; }

/* ---------------- shell ---------------- */
.shell { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 0 20px; height: 56px;
}
.page-title { font-size: 16px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar .today { color: var(--muted); font-size: 12.5px; }
.btn-icon {
    background: transparent; border: 1px solid var(--line); color: var(--ink-3);
    border-radius: 8px; width: 34px; height: 34px; padding: 0;
    display: inline-grid; place-items: center;
}
.btn-icon:hover { background: var(--line-soft); }
.content { padding: 20px; }

/* ---------------- cards & panels ---------------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2, .card-head h3 { font-size: 14px; font-weight: 650; margin: 0; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px; }
.section-label {
    font-size: 10.5px; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: var(--muted); margin: 0 0 8px;
}

/* ---------------- stat tiles ---------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; }
.tile {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
    border-top: 3px solid var(--brand);
}
.tile.brass { border-top-color: var(--brass); }
.tile.ok    { border-top-color: var(--ok); }
.tile.warn  { border-top-color: var(--warn); }
.tile.bad   { border-top-color: var(--danger); }
.tile label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.tile .value {
    font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums;
    font-size: 21px; font-weight: 600; letter-spacing: -.02em;
}
.tile .sub { font-size: 11.5px; color: var(--muted); }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid thead th {
    background: #F4F7FA; color: var(--ink-3);
    font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid thead th a { color: inherit; text-decoration: none; }
table.grid thead th a:hover { color: var(--brand); }
table.grid tbody td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tbody tr:hover { background: #F8FAFC; }
table.grid tfoot td { padding: 10px; border-top: 2px solid var(--ink); font-weight: 650; background: #F4F7FA; }
.grid .item-main { font-weight: 550; }
.grid .item-sub { font-size: 11.5px; color: var(--muted); }
.row-low { background: #FFF9EC !important; }

/* ---------------- the pack chip: 1 SET = 6 PCS ---------------- */
.pack-chip {
    display: inline-block; font-family: 'JetBrains Mono', monospace; font-size: 10.5px;
    background: var(--brass-soft); color: #7A5714; border: 1px solid #E6D2A6;
    border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}
.spec-strip {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
    padding: 8px 12px; background: var(--brass-soft);
    border: 1px solid #E6D2A6; border-radius: 8px; font-size: 12px; color: #7A5714;
}

/* ---------------- badges ---------------- */
.badge-soft {
    display: inline-block; font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.badge-open    { background: #E7F0F9; color: var(--brand); }
.badge-ok      { background: #E3F5EE; color: var(--ok); }
.badge-warn    { background: #FDF0E3; color: var(--warn); }
.badge-bad     { background: #FDECEA; color: var(--danger); }
.badge-neutral { background: #EEF1F5; color: var(--ink-3); }

/* ---------------- filter bar ---------------- */
.filterbar {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 12px; margin-bottom: 14px;
    box-shadow: var(--shadow);
}
.filterbar .row { --bs-gutter-x: .6rem; --bs-gutter-y: .6rem; }
.filterbar label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.filter-count { font-size: 12px; color: var(--muted); }

/* ---------------- forms ---------------- */
.form-label { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 3px; }
.form-control, .form-select {
    border-color: var(--line); border-radius: 7px; font-size: 13.5px; padding: 6px 10px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,76,129,.12);
}
.form-control-sm, .form-select-sm { font-size: 12.5px; padding: 4px 8px; }
.req::after { content: " *"; color: var(--danger); }

.btn { border-radius: 7px; font-size: 13.5px; font-weight: 550; }
.btn-sm { font-size: 12.5px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-brass { background: var(--brass); border-color: var(--brass); color: #23180A; }
.btn-brass:hover { background: #A9781F; border-color: #A9781F; color: #fff; }
.btn-outline-secondary { border-color: var(--line); color: var(--ink-3); }
.btn-outline-secondary:hover { background: var(--line-soft); color: var(--ink); border-color: var(--line); }

/* ---------------- document entry ---------------- */
.entry-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.entry-table thead th {
    background: #F4F7FA; font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--ink-3);
    padding: 8px; border-bottom: 1px solid var(--line); text-align: left;
}
.entry-table tbody td { padding: 5px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.entry-table input, .entry-table select { width: 100%; }
.entry-table .line-note { font-size: 11px; color: var(--muted); margin-top: 3px; display: block; }
.stock-hint { font-size: 11px; }
.stock-hint.low { color: var(--warn); font-weight: 600; }
.stock-hint.out { color: var(--danger); font-weight: 600; }

.totals-panel { background: #F8FAFC; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.totals-panel .line { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.totals-panel .line.grand {
    border-top: 2px solid var(--ink); margin-top: 8px; padding-top: 8px;
    font-size: 17px; font-weight: 700;
}
.totals-panel .line .amount { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }

.charge-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; }

/* ---------------- login ---------------- */
.auth-page {
    min-height: 100vh; display: grid; place-items: center;
    background: linear-gradient(150deg, var(--ink) 0%, #24384A 55%, #2E4759 100%);
    padding: 20px;
}
.auth-card {
    width: 100%; max-width: 380px; background: var(--surface);
    border-radius: 14px; padding: 30px 28px; box-shadow: 0 18px 50px rgba(8,16,24,.36);
}
.auth-card .brand-mark { width: 44px; height: 44px; font-size: 21px; margin-bottom: 14px; }
.auth-card h1 { font-size: 19px; font-weight: 700; margin: 0 0 3px; }
.auth-card p.lead-sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.auth-hint {
    margin-top: 18px; padding: 10px 12px; background: var(--brass-soft);
    border: 1px solid #E6D2A6; border-radius: 8px; font-size: 11.5px; color: #7A5714;
}

/* ---------------- misc ---------------- */
.alert { border-radius: var(--radius); font-size: 13.5px; border-width: 1px; }
.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-state i { font-size: 34px; color: #B7C3D0; display: block; margin-bottom: 10px; }
.empty-state h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; flex-wrap: wrap; }
.pager .info { color: var(--muted); font-size: 12.5px; margin-right: auto; }
.rights-table td { text-align: center; }
.rights-table td:first-child { text-align: left; font-weight: 550; }
.rights-table input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; }
.dl-inline { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; font-size: 13px; margin: 0; }
.dl-inline dt { color: var(--muted); font-weight: 500; }
.dl-inline dd { margin: 0; font-weight: 550; }

/* Data tables carry more columns than a phone is wide. Give them a floor so they
   scroll inside their wrapper instead of crushing every column to nothing. */
.table-wrap { -webkit-overflow-scrolling: touch; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .shell { margin-left: 0; }
    .content { padding: 14px; }
}

/* ---- phones ---- */
@media (max-width: 767.98px) {
    /* Below tablet width these carry more columns than the screen, so give them a
       floor and let the wrapper scroll rather than crushing every column. */
    table.grid { min-width: 640px; }
    .entry-table { min-width: 620px; }
    /* Folded, the grid fits a much narrower screen without scrolling. */
    .entry-table.fold-loose.fold-lot { min-width: 480px; }
}

@media (max-width: 575.98px) {
    body { font-size: 13.5px; }
    .content { padding: 10px; }

    .topbar { padding: 0 12px; gap: 8px; }
    .topbar .today { display: none; }
    .page-title { font-size: 15px; }

    .card-head { padding: 10px 12px; }
    .card-body { padding: 12px; }

    /* A row of buttons in a card header has to wrap, not overflow the card. */
    .card-head .btn { flex: 0 0 auto; }
    .card-head .spacer { flex-basis: 100%; height: 0; margin: 0; }

    .tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
    .tile { padding: 12px; }
    .tile .value { font-size: 18px; }

    .totals-panel .line.grand { font-size: 15px; }
    .charge-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

    /* Label above value reads better than a 130px gutter on a narrow screen. */
    .dl-inline { grid-template-columns: 1fr; gap: 0 0; }
    .dl-inline dt { margin-top: 6px; font-size: 11.5px; }

    .filterbar { padding: 10px; }
    .pager { padding: 10px; }
    .pager .info { flex-basis: 100%; margin-bottom: 6px; }

    .empty-state { padding: 30px 14px; }
    .auth-card { padding: 24px 20px; }
}



@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

@media print {
    .sidebar, .topbar, .filterbar, .no-print, .pager { display: none !important; }
    .shell { margin-left: 0; }
    .content { padding: 0; }
    .card { border: none; box-shadow: none; }
    body { background: #fff; font-size: 11px; }
}

/* The unit master edits in place. Each row is its own form, so the fields live in an
   inner table that inherits the outer column widths — otherwise nothing lines up
   under its header. */
.uom-inline { width: 100%; border-collapse: collapse; table-layout: fixed; }
.uom-inline td { padding: 5px 10px; vertical-align: middle; border: none; }

/* Fixed layout on the outer table too, so its header columns take the declared
   widths rather than sizing themselves off the header text — otherwise the inner
   row and the header above it drift apart. */
.grid-fixed { table-layout: fixed; }
.uom-row-form { margin: 0; }

/* Search box beside the item dropdown rather than above it — stacking them made
   every entry row three times taller than the data in it. */
.item-pick { display: flex; gap: 6px; align-items: center; }
.item-pick .f-search { flex: 0 0 34%; min-width: 96px; }
.item-pick .f-item { flex: 1 1 auto; min-width: 0; }
@media (max-width: 767.98px) {
    .item-pick { flex-wrap: wrap; }
    .item-pick .f-search, .item-pick .f-item { flex: 1 1 100%; }
}

/* ---- entry grid density -------------------------------------------------
   A bill is many lines, not one. The loose and lot columns are empty on most
   of them, so they fold away by default and a row that actually uses them
   keeps them on screen. */
.entry-table.tight td { padding: 3px 4px; }
.entry-table.tight .form-control-sm,
.entry-table.tight .form-select-sm { padding: 3px 6px; font-size: 12px; }
.entry-table.tight tbody td { border-bottom: 1px solid var(--line-soft); }
.entry-table.tight .line-note { font-size: 10.5px; margin-top: 1px; }

.entry-table.fold-loose thead th.col-loose,
.entry-table.fold-loose tbody tr:not(.has-loose) td.col-loose { display: none; }
.entry-table.fold-lot thead th.col-lot,
.entry-table.fold-lot td.col-lot { display: none; }

/* A row that does use a sub unit needs its labels back, so it carries them
   inline rather than relying on a hidden header. */
.entry-table.fold-loose tr.has-loose td.col-loose::before {
    content: attr(data-label);
    display: block; font-size: 9.5px; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 2px;
}

.grid-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.grid-tools .form-check { margin: 0; }
.grid-tools .form-check-label { font-size: 12px; color: var(--muted); }

/* ---- statements ---------------------------------------------------------
   A bill, then its items, then its charges. The indent carries the hierarchy
   so the bill line stays the one your eye lands on. */
.statement tr.lvl-0 td { border-top: 1px solid var(--line); font-weight: 500; }
.statement tr.lvl-1 td, .statement tr.lvl-2 td {
    border-top: none; padding-top: 2px; padding-bottom: 2px;
    background: #FCFDFE; font-size: 12.5px;
}
.statement tr.lvl-2 td { color: var(--muted); }
.stmt-item   { padding-left: 18px; display: inline-block; }
.stmt-charge { padding-left: 34px; display: inline-block; font-style: italic; }
@media print { .statement tr.lvl-1 td, .statement tr.lvl-2 td { background: none; } }
