:root {
    --bg:      #f4f6f9;
    --bg2:     #ffffff;
    --accent:  #1a5c9e;
    --accent2: #2272c3;
    --navy:    #1a2332;
    --text:    #1a2332;
    --muted:   #5a6a7a;
    --border:  #d0d7e0;
    --danger:  #c0392b;
    --success: #1e8449;
    --warn:    #c8820a;
    --zero:    #b8c2ce;
    --shadow:  0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Barlow', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Nav ---- */
nav {
    background: var(--navy);
    border-bottom: 3px solid var(--accent);
    display: flex; align-items: stretch; padding: 0; min-height: 64px;
    position: sticky; top: 0; z-index: 50;
}
.nav-brand {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 24px; background: #ffffff;
    border-right: 3px solid var(--accent); text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand img { height: 42px; width: auto; display: block; }
.nav-brand-text {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.95rem; font-weight: 700; color: var(--navy);
    letter-spacing: 0.08em; text-transform: uppercase;
}
nav a.nav-link {
    color: #ffffff; text-decoration: none; padding: 0 20px;
    font-size: 0.85rem; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; transition: color 0.15s, background 0.15s;
    border-right: 1px solid #2e3d55; display: flex; align-items: center;
}
nav a.nav-link:hover, nav a.nav-link.active {
    color: #ffffff; background: var(--accent2); text-decoration: none;
}
nav .admin-on {
    color: #7fe0a4 !important; font-weight: 700; cursor: default;
    display: flex; align-items: center; letter-spacing: 0.08em;
}
nav .admin-on:hover { background: transparent; }

.container { max-width: 1800px; margin: 0 auto; padding: 28px 24px; }

/* ---- Page header ---- */
.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid var(--border);
    flex-wrap: wrap; gap: 16px;
}
.page-title {
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.8rem;
    font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text);
}
.page-title span { color: var(--accent); }
.page-sub { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.page-sub strong { color: var(--text); }
.head-actions { display: flex; align-items: flex-end; gap: 12px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px;
    border: none; border-radius: 4px; font-family: 'Barlow', sans-serif;
    font-size: 0.85rem; font-weight: 500; letter-spacing: 0.04em;
    text-transform: uppercase; cursor: pointer; text-decoration: none; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); color: #fff; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: #f0f5fc; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }

.icon-btn {
    border: none; background: none; cursor: pointer; font-size: 15px;
    padding: 4px 7px; border-radius: 4px; color: var(--muted); line-height: 1;
}
.icon-btn:hover { background: #f0f5fc; color: var(--accent); }
.del-btn:hover { background: #fdf0ee; color: var(--danger); }

/* ---- Alerts ---- */
.alert { padding: 12px 18px; border-radius: 4px; margin-bottom: 20px; font-size: 0.9rem; border-left: 4px solid; }
.alert-success { background: #eafaf1; border-color: var(--success); color: #1a6e3c; }
.alert-warning { background: #fef9ec; border-color: var(--warn); color: #7d5a00; }
.alert-error,
.alert-danger { background: #fdf0ee; border-color: var(--danger); color: #922b21; }
.alert-info { background: #eaf4fb; border-color: #2980b9; color: #1a5276; }

/* ---- Stat pills (reusable summary cards) ---- */
.stat-row { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.stat-pill {
    flex: 1; min-width: 130px;
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
    padding: 14px 20px; font-family: 'Barlow Condensed', sans-serif; box-shadow: var(--shadow);
}
.stat-pill.accent { background: var(--navy); border-color: var(--navy); }
.stat-pill.accent .stat-num { color: #fff; }
.stat-pill.accent .stat-lbl { color: #aeb9c7; }
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-num.small { font-size: 1.1rem; }
.stat-editable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.stat-editable:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.10); }
.stat-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 4px; }
.stat-sub { font-size: 0.82rem; font-weight: 600; color: var(--success); margin-top: 3px; }
.stat-pill.accent .stat-sub { color: #7fe0a4; }
.stat-row-compact .stat-pill { padding: 11px 16px; min-width: 100px; }
.stat-row-compact .stat-num { font-size: 1.45rem; }

.sort-label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sort-label select {
    display: block; margin-top: 6px; padding: 8px 12px; background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 4px; font-family: 'Barlow', sans-serif; font-size: 0.9rem; cursor: pointer;
}

/* ---- Table (reusable data grid with sticky header) ---- */
/* No overflow wrapper on wide screens, so the sticky header resolves against
   the viewport (native sticky breaks inside an overflow-x container). Only
   enable horizontal scroll on narrow screens. The nav is sticky at top:0 and
   ~67px tall, so the header sticks at top:67px just beneath it. */
.table-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
@media (max-width: 1200px) {
    .table-wrap { overflow-x: auto; }
}
table.grid { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.grid thead tr { background: #f8f9fb; }
table.grid th {
    padding: 12px 14px; text-align: left; font-family: 'Barlow Condensed', sans-serif;
    font-size: 1rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--navy); border-bottom: 2px solid var(--border);
    white-space: nowrap; position: sticky; top: 67px; background: #f8f9fb; z-index: 20;
}
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover td { background: #f0f5fc; }
table.grid td.company { font-weight: 500; }
.zero { color: var(--zero); }
.total-col { background: #eef4fb; }
table.grid thead .total-col { background: #e6eef8; }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
table.grid thead .sticky-col { background: #f8f9fb; z-index: 21; }
table.grid tbody tr:hover .sticky-col { background: #f0f5fc; }
table.grid tfoot td {
    border-top: 2px solid var(--navy); background: #f8f9fb;
    font-variant-numeric: tabular-nums; font-weight: 700;
}
table.grid tfoot .sticky-col { background: #f8f9fb; }
.actions-col { text-align: center; width: 74px; }

/* ---- Cards ---- */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.card-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    font-family: 'Barlow Condensed', sans-serif; font-size: 0.9rem; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
    background: #f8f9fb; border-radius: 6px 6px 0 0;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-body { padding: 20px; }

/* ---- Modal ---- */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(26,35,50,.55);
    align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 6px; width: 100%; max-width: 540px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3); border-top: 4px solid var(--accent); }
.modal-head {
    padding: 16px 22px; border-bottom: 1px solid var(--border);
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.15rem; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase; color: var(--text);
}
.modal-body { padding: 22px; }
.field { display: block; margin-bottom: 18px; }
.field-label {
    display: block; margin-bottom: 6px; font-size: 0.78rem; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.field input, .modal input.minput {
    width: 100%; padding: 9px 13px; background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 4px;
    font-family: 'Barlow', sans-serif; font-size: 0.92rem; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .modal input.minput:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.12);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

/* ---- Login (standalone, full-page gate) ---- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px; background: var(--bg);
}
.login-card {
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    border-top: 4px solid var(--accent); box-shadow: 0 6px 24px rgba(0,0,0,.10);
    padding: 34px 32px; width: 100%; max-width: 380px; text-align: center;
}
.login-logo { height: 46px; width: auto; margin: 0 auto 14px; display: block; }
.login-title {
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.15rem; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--navy);
    margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.login-hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 12px; }
.login-card input {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 5px;
    font-size: 1rem; margin-bottom: 16px; text-align: center; letter-spacing: 3px;
    font-family: 'Barlow', sans-serif;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.12); }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: 0.95rem; }
.login-card .alert { text-align: left; }

/* ---- Settings ---- */
.settings-wrap { max-width: 560px; }

/* ---- Footer ---- */
.foot {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 1800px; margin: 20px auto 0; padding: 20px 24px 30px;
    border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8rem;
}
.foot .mono { font-family: 'Barlow Condensed', sans-serif; letter-spacing: 0.05em; text-transform: uppercase; }
@media (max-width: 640px) { .foot { flex-direction: column; gap: 6px; text-align: center; } }


/* =========================================================================
   Part Number Database - app-specific additions (built on the shared tokens)
   ========================================================================= */

/* Nav search box + signed-in user */
.nav-search { display: flex; align-items: center; margin-left: auto; padding: 0 12px; }
.nav-search input {
    width: 320px; max-width: 40vw; padding: 8px 12px; border: 1px solid #2e3d55; border-radius: 4px;
    background: #24314a; color: #fff; font-family: 'Barlow', sans-serif; font-size: 0.88rem;
}
.nav-search input::placeholder { color: #8a99b0; }
.nav-search input:focus { outline: none; border-color: var(--accent2); background: #2b3a56; }
nav .nav-user { color: #7fe0a4; cursor: default; text-transform: none; letter-spacing: 0.02em; font-weight: 600; }
nav .nav-user:hover { background: transparent; }

/* Home page search */
.big-search { display: flex; gap: 10px; margin-bottom: 24px; }
.big-search input {
    flex: 1; padding: 13px 16px; border: 1px solid var(--border); border-radius: 5px;
    font-family: 'Barlow', sans-serif; font-size: 1.05rem; background: #fff;
}
.big-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.12); }
a.stat-pill { text-decoration: none; color: inherit; display: block; }
a.stat-pill:hover { text-decoration: none; }

/* Discipline tags */
.tag {
    display: inline-block; padding: 2px 9px; border-radius: 3px; font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; vertical-align: middle;
}
.tag-mech { background: #e3eefb; color: var(--accent); }
.tag-elec { background: #fdf1e0; color: #9a5f00; }
.page-title .tag { font-size: 0.85rem; position: relative; top: -4px; margin-right: 4px; }

/* Table cells */
.mono-num { font-family: 'Barlow Condensed', sans-serif; font-size: 1rem; font-weight: 600; letter-spacing: 0.04em; }
table.grid td.wrap { white-space: normal; min-width: 260px; max-width: 520px; }
table.grid td.empty { text-align: center; color: var(--muted); padding: 28px; white-space: normal; }
.muted { color: var(--muted); }
.inactive-row td { color: var(--muted); background: #fafbfc; }
.inline-input {
    width: 100%; min-width: 140px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 4px;
    font-family: 'Barlow', sans-serif; font-size: 0.88rem; background: #fff;
}
.inline-input:focus { outline: none; border-color: var(--accent); }

/* Filter bar above the lists */
.filter-bar, .inline-form {
    display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
    background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 14px 18px; margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.inline-form { margin-bottom: 0; border: none; box-shadow: none; padding: 0; }
.filter-bar input[type=search], .filter-bar input[type=text], .inline-form input[type=text], .inline-form input[type=password] {
    display: block; margin-top: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px;
    font-family: 'Barlow', sans-serif; font-size: 0.9rem; background: #fff; width: 100%;
}
.filter-bar input:focus, .inline-form input:focus { outline: none; border-color: var(--accent); }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; padding-bottom: 1px; }
.check-label input[type=checkbox] { display: block; margin-top: 12px; width: 18px; height: 18px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 18px; }

/* Part form */
.form-grid { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } }
.field select, .field textarea {
    width: 100%; padding: 9px 13px; background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 4px;
    font-family: 'Barlow', sans-serif; font-size: 0.92rem;
}
.field textarea { resize: vertical; line-height: 1.4; }
.field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.12); }
.field-help { display: block; margin-top: 5px; font-size: 0.78rem; color: var(--muted); }
.req { color: var(--danger); }
.number-display {
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.9rem; font-weight: 700; letter-spacing: 0.06em;
    color: var(--accent); padding: 8px 0 2px;
}
.number-display.small { font-size: 1.05rem; color: var(--text); font-weight: 600; letter-spacing: 0.03em; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

/* Part detail */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-list { display: grid; grid-template-columns: 170px 1fr; gap: 9px 16px; font-size: 0.92rem; }
.detail-list dt { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.detail-list dd { margin: 0; word-break: break-word; }
.pre { white-space: pre-wrap; }
.plain-list { list-style: none; }
.plain-list li { padding: 5px 0; border-bottom: 1px solid #eef1f5; }
.plain-list li:last-child { border-bottom: none; }
.history { list-style: none; }
.history > li { padding: 9px 0; border-bottom: 1px solid #eef1f5; font-size: 0.88rem; }
.history > li:last-child { border-bottom: none; }
.history-head { color: var(--muted); }
.history-head strong { color: var(--text); }
.history-changes { list-style: none; margin-top: 5px; padding-left: 10px; border-left: 2px solid var(--border); }
.history-changes li { padding: 2px 0 2px 8px; font-size: 0.84rem; word-break: break-word; }
.hk { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.hold { color: var(--danger); text-decoration: line-through; opacity: 0.8; }
.hnew { color: var(--success); font-weight: 500; }

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

/* List tables: let long text wrap so all columns fit without horizontal scroll
   (the number column stays on one line). */
table.grid.parts td { white-space: normal; vertical-align: top; }
table.grid.parts td.mono-num { white-space: nowrap; }
table.grid.parts td.wrap { min-width: 200px; max-width: 460px; }
nav .nav-user { white-space: nowrap; }
table.grid.parts { font-size: 0.85rem; }
table.grid.parts th { padding: 10px 11px; font-size: 0.92rem; letter-spacing: 0.06em; }
table.grid.parts td { padding: 8px 11px; }
