/* ==========================================================================
   PHREATIC — POS & Inventory Management
   Design system: industrial, high-contrast, dense but readable.
   No framework, no build step, no external requests.
   ========================================================================== */

:root {
    /* Brand — deep water blue with a steel/graphite base */
    --brand-900: #062338;
    --brand-800: #0a3450;
    --brand-700: #0e4568;
    --brand-600: #12587f;
    --brand-500: #1a6f9c;
    --brand-400: #3d8fb8;
    --brand-100: #dceaf3;
    --brand-050: #f0f7fb;

    --accent-600: #b45309;   /* copper — restocking, warnings */
    --accent-500: #d97706;
    --accent-100: #fef3c7;

    --ink-900: #0f172a;
    --ink-800: #1e293b;
    --ink-700: #334155;
    --ink-600: #475569;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-050: #f8fafc;
    --white: #ffffff;

    --ok-700: #15803d;
    --ok-600: #16a34a;
    --ok-100: #dcfce7;
    --warn-700: #a16207;
    --warn-600: #ca8a04;
    --warn-100: #fef9c3;
    --bad-700: #b91c1c;
    --bad-600: #dc2626;
    --bad-100: #fee2e2;
    --info-700: #1d4ed8;
    --info-100: #dbeafe;

    --radius-sm: 4px;
    --radius: 7px;
    --radius-lg: 11px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .09), 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 4px 12px rgba(15, 23, 42, .09), 0 1px 3px rgba(15, 23, 42, .05);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .16);

    --sidebar-w: 244px;
    --topbar-h: 58px;

    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

/* ------------------------------------------------------------------ reset */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink-800);
    background: var(--ink-100);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 650; color: var(--ink-900); line-height: 1.25; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
p  { margin: 0 0 10px; }
a  { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }

img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--ink-200); margin: 16px 0; }

::selection { background: var(--brand-100); }

/* ---------------------------------------------------------------- layout */

.app { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--brand-900);
    color: #cbd8e2;
    display: flex;
    flex-direction: column;
    z-index: 60;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    flex-shrink: 0;
    text-decoration: none;
}

/*
 * Logos are drawn for light stationery — dark type, no reversed-out version.
 * Rather than tint or invert someone's artwork, the dark chrome gives it a
 * white card to sit on. Works for any upload, including a transparent PNG.
 */
.logo-plate {
    display: flex; align-items: center; justify-content: center;
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    max-width: 100%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.logo-img {
    display: block;
    width: auto; height: auto;
    max-width: 100%;
    /* Intrinsic width/height are on the tag; this keeps the aspect ratio
       whichever axis ends up constraining it. */
    object-fit: contain;
}
.sidebar-brand .logo-plate { padding: 5px 9px; }
.sidebar-brand .logo-img { max-height: 30px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0 24px; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }

.nav-section {
    padding: 14px 16px 5px;
    font-size: 10px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #5c7d95;
    font-weight: 700;
}

.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px;
    color: #b9cbd8;
    font-size: 13.5px;
    border-left: 3px solid transparent;
    transition: background .12s, color .12s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active {
    background: rgba(61, 143, 184, .18);
    border-left-color: var(--brand-400);
    color: #fff; font-weight: 600;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.nav-link .badge-count {
    margin-left: auto;
    background: var(--bad-600); color: #fff;
    font-size: 10px; font-weight: 700;
    padding: 1px 6px; border-radius: 9px;
}
.nav-link.soon { opacity: .45; cursor: default; }
.nav-link.soon:hover { background: none; color: #b9cbd8; }
.nav-link .soon-tag {
    margin-left: auto; font-size: 9px; letter-spacing: .06em;
    text-transform: uppercase; color: #6d8fa6;
    border: 1px solid #33556c; padding: 0 4px; border-radius: 3px;
}

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--ink-200);
    display: flex; align-items: center; gap: 14px;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 40;
}
.topbar .menu-toggle { display: none; }
.topbar .page-title { font-size: 15px; font-weight: 650; color: var(--ink-900); }
.topbar .spacer { flex: 1; }

.topbar-search {
    position: relative;
    width: 260px;
}
.topbar-search input {
    width: 100%; height: 34px;
    padding: 0 10px 0 32px;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    background: var(--ink-050);
    font-size: 13px; font-family: inherit;
}
.topbar-search input:focus {
    outline: none; border-color: var(--brand-400);
    background: #fff; box-shadow: 0 0 0 3px var(--brand-100);
}
.topbar-search svg {
    position: absolute; left: 9px; top: 9px;
    width: 15px; height: 15px; color: var(--ink-400);
}

.icon-btn {
    position: relative;
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    background: #fff; color: var(--ink-600);
    cursor: pointer;
}
.icon-btn:hover { background: var(--ink-050); color: var(--ink-900); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .dot {
    position: absolute; top: -5px; right: -5px;
    min-width: 17px; height: 17px; padding: 0 4px;
    background: var(--bad-600); color: #fff;
    border-radius: 9px; font-size: 10px; font-weight: 700;
    display: grid; place-items: center; border: 2px solid #fff;
}

.user-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 4px 9px 4px 4px;
    border: 1px solid var(--ink-200);
    border-radius: 20px; background: #fff; cursor: pointer;
}
.user-chip:hover { background: var(--ink-050); }
.avatar {
    width: 27px; height: 27px; border-radius: 50%;
    background: var(--brand-600); color: #fff;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.user-chip .meta { text-align: left; line-height: 1.15; }
.user-chip .meta strong { display: block; font-size: 12.5px; color: var(--ink-900); }
.user-chip .meta span { font-size: 10.5px; color: var(--ink-500); }

.content { flex: 1; padding: 20px; max-width: 1680px; width: 100%; }

.page-head {
    display: flex; align-items: flex-start; gap: 16px;
    flex-wrap: wrap; margin-bottom: 18px;
}
.page-head .titles { flex: 1; min-width: 220px; }
.page-head h1 { margin-bottom: 3px; }
.page-head .sub { color: var(--ink-500); font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------- surfaces */

.card {
    background: var(--white);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: 16px; }
.card-head {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--ink-200);
}
.card-head h2, .card-head h3 { flex: 1; }
.card-head .sub { font-size: 12px; color: var(--ink-500); font-weight: 400; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-foot {
    padding: 11px 16px; border-top: 1px solid var(--ink-200);
    background: var(--ink-050);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    display: flex; align-items: center; gap: 10px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ------------------------------------------------------------- stat tiles */

.stat {
    background: var(--white);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-lg);
    padding: 14px 15px;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: ""; position: absolute; inset: 0 auto 0 0;
    width: 3px; background: var(--brand-500);
}
.stat.is-ok::before   { background: var(--ok-600); }
.stat.is-warn::before { background: var(--warn-600); }
.stat.is-bad::before  { background: var(--bad-600); }
.stat.is-accent::before { background: var(--accent-500); }

.stat .label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-500); font-weight: 650; margin-bottom: 5px;
    display: flex; align-items: center; gap: 6px;
}
.stat .label svg { width: 13px; height: 13px; }
.stat .value {
    font-size: 23px; font-weight: 700; color: var(--ink-900);
    letter-spacing: -.02em; line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.stat .value small { font-size: 13px; font-weight: 600; color: var(--ink-500); }
.stat .foot { margin-top: 5px; font-size: 11.5px; color: var(--ink-500); }

.delta { font-weight: 650; display: inline-flex; align-items: center; gap: 2px; }
.delta.up   { color: var(--ok-700); }
.delta.down { color: var(--bad-700); }
.delta.flat { color: var(--ink-500); }

/* ----------------------------------------------------------------- tables */

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

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data thead th {
    text-align: left;
    padding: 9px 12px;
    background: var(--ink-050);
    border-bottom: 1px solid var(--ink-200);
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-500); font-weight: 700;
    white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
}
table.data tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--ink-100);
    vertical-align: middle;
}
table.data tbody tr:hover { background: var(--brand-050); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
table.data th.num { text-align: right; }
table.data .mono { font-family: var(--mono); font-size: 12px; }
table.data tfoot td {
    padding: 10px 12px;
    background: var(--ink-050);
    border-top: 2px solid var(--ink-200);
    font-weight: 700; color: var(--ink-900);
}
table.data.compact tbody td, table.data.compact thead th { padding: 6px 10px; }

.cell-primary { font-weight: 600; color: var(--ink-900); }
.cell-sub { font-size: 11.5px; color: var(--ink-500); }

.empty {
    padding: 44px 20px; text-align: center; color: var(--ink-500);
}
.empty svg { width: 34px; height: 34px; color: var(--ink-300); margin: 0 auto 10px; }
.empty h3 { color: var(--ink-700); margin-bottom: 4px; }

/* ----------------------------------------------------------------- badges */

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    border-radius: 11px;
    font-size: 11px; font-weight: 650;
    letter-spacing: .01em; white-space: nowrap;
    border: 1px solid transparent;
}
.badge-success { background: var(--ok-100);   color: var(--ok-700);   border-color: #bbf7d0; }
.badge-warning { background: var(--warn-100); color: var(--warn-700); border-color: #fde68a; }
.badge-danger  { background: var(--bad-100);  color: var(--bad-700);  border-color: #fecaca; }
.badge-info    { background: var(--info-100); color: var(--info-700); border-color: #bfdbfe; }
.badge-muted   { background: var(--ink-100);  color: var(--ink-600);  border-color: var(--ink-200); }
.badge-brand   { background: var(--brand-100);color: var(--brand-700);border-color: #b9d7e8; }

.badge-dot::before {
    content: ""; width: 5px; height: 5px; border-radius: 50%;
    background: currentColor; display: inline-block;
}

.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: var(--radius);
    background: var(--ink-100); color: var(--ink-700);
    font-size: 11.5px; font-weight: 600;
}

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 36px; padding: 0 14px;
    border: 1px solid var(--ink-300);
    border-radius: var(--radius);
    background: #fff; color: var(--ink-800);
    font-family: inherit; font-size: 13.5px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: background .12s, border-color .12s, box-shadow .12s;
    text-decoration: none;
}
.btn:hover { background: var(--ink-050); text-decoration: none; color: var(--ink-900); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-100); }
.btn svg { width: 15px; height: 15px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--brand-600); border-color: var(--brand-600); color: #fff;
}
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }

.btn-accent {
    background: var(--accent-600); border-color: var(--accent-600); color: #fff;
}
.btn-accent:hover { background: #92400e; border-color: #92400e; color: #fff; }

.btn-success { background: var(--ok-600); border-color: var(--ok-600); color: #fff; }
.btn-success:hover { background: var(--ok-700); border-color: var(--ok-700); color: #fff; }

.btn-danger { background: #fff; border-color: #fca5a5; color: var(--bad-700); }
.btn-danger:hover { background: var(--bad-100); color: var(--bad-700); }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--ink-100); }

.btn-sm { height: 29px; padding: 0 10px; font-size: 12.5px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-xl { height: 54px; font-size: 16px; font-weight: 700; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; z-index: 1; }

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 14px; }
.field label, .label {
    display: block; margin-bottom: 5px;
    font-size: 12.5px; font-weight: 650; color: var(--ink-700);
}
.field .req { color: var(--bad-600); }
.field .hint { margin-top: 4px; font-size: 11.5px; color: var(--ink-500); }
.field .err  { margin-top: 4px; font-size: 11.5px; color: var(--bad-700); font-weight: 600; }

.input, .select, .textarea {
    width: 100%;
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--ink-300);
    border-radius: var(--radius);
    background: #fff;
    font-family: inherit; font-size: 13.5px; color: var(--ink-900);
    transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 80px; padding: 9px 11px; line-height: 1.5; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.input:disabled, .select:disabled { background: var(--ink-100); color: var(--ink-500); }
.input.is-invalid, .select.is-invalid { border-color: var(--bad-600); }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.input-group { display: flex; }
.input-group .addon {
    display: grid; place-items: center;
    padding: 0 10px; height: 38px;
    border: 1px solid var(--ink-300); border-right: 0;
    background: var(--ink-050);
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 12px; font-weight: 650; color: var(--ink-500);
}
.input-group .input { border-radius: 0 var(--radius) var(--radius) 0; }

.checkbox, .radio {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 13.5px; cursor: pointer; margin-bottom: 8px;
}
.checkbox input, .radio input { margin-top: 2px; width: 15px; height: 15px; accent-color: var(--brand-600); }
.checkbox .desc { display: block; font-size: 11.5px; color: var(--ink-500); font-weight: 400; }

.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }

fieldset.group {
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    padding: 14px 16px 2px;
    margin: 0 0 16px;
}
fieldset.group legend {
    padding: 0 7px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500);
}

.filters {
    display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-end;
}
.filters .field { margin-bottom: 0; min-width: 140px; }
.filters .grow { flex: 1; min-width: 200px; }

/* ------------------------------------------------------------------ alert */

.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: 13.5px;
    margin-bottom: 16px;
}
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--ok-100);   border-color: #bbf7d0; color: #14532d; }
.alert-error   { background: var(--bad-100);  border-color: #fecaca; color: #7f1d1d; }
.alert-warning { background: var(--warn-100); border-color: #fde68a; color: #713f12; }
.alert-info    { background: var(--brand-050);border-color: #bfdbfe; color: var(--brand-800); }
.alert .close { margin-left: auto; background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; }
.alert .close:hover { opacity: 1; }

.toast-stack {
    position: fixed; right: 18px; bottom: 18px;
    z-index: 200; display: flex; flex-direction: column; gap: 9px;
    max-width: 380px;
}
.toast {
    background: var(--ink-900); color: #fff;
    padding: 11px 15px; border-radius: var(--radius);
    box-shadow: var(--shadow-lg); font-size: 13.5px;
    display: flex; gap: 9px; align-items: flex-start;
    animation: toast-in .18s ease-out;
}
.toast.ok  { background: #14532d; }
.toast.bad { background: #7f1d1d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ----------------------------------------------------------------- modals */

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 100;
    display: none;
    align-items: flex-start; justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 520px;
    animation: modal-in .16s ease-out;
}
.modal.wide { max-width: 780px; }
.modal.narrow { max-width: 400px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-10px); } }
.modal-head {
    display: flex; align-items: center; gap: 12px;
    padding: 15px 18px; border-bottom: 1px solid var(--ink-200);
}
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px; }
.modal-foot {
    padding: 13px 18px; border-top: 1px solid var(--ink-200);
    display: flex; gap: 9px; justify-content: flex-end;
    background: var(--ink-050);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ------------------------------------------------------------- pagination */

.pagination {
    display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.pagination .page {
    min-width: 31px; height: 31px; padding: 0 8px;
    display: grid; place-items: center;
    border: 1px solid var(--ink-200); border-radius: var(--radius);
    font-size: 12.5px; font-weight: 600; color: var(--ink-700);
    background: #fff;
}
.pagination .page:hover { background: var(--ink-050); text-decoration: none; }
.pagination .page.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pagination .page.disabled { opacity: .4; pointer-events: none; }
.pagination .info { margin-right: auto; font-size: 12.5px; color: var(--ink-500); }

/* ------------------------------------------------------------------ misc */

.muted { color: var(--ink-500); }
.strong { font-weight: 650; color: var(--ink-900); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.tabular { font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.ok-text  { color: var(--ok-700); }
.bad-text { color: var(--bad-700); }
.warn-text{ color: var(--warn-700); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

.divider-list > * + * { border-top: 1px solid var(--ink-100); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; }
.kv dt { color: var(--ink-500); }
.kv dd { margin: 0; font-weight: 600; color: var(--ink-900); text-align: right; }

.thumb {
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    background: var(--ink-100); object-fit: cover;
    display: grid; place-items: center; color: var(--ink-400);
    flex-shrink: 0; overflow: hidden;
}
.thumb svg { width: 18px; height: 18px; }
.thumb.lg { width: 120px; height: 120px; border-radius: var(--radius); }
.thumb.lg svg { width: 40px; height: 40px; }

.progress {
    height: 6px; border-radius: 3px; background: var(--ink-200); overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--brand-500); border-radius: 3px; }
.progress.bad > span  { background: var(--bad-600); }
.progress.warn > span { background: var(--warn-600); }
.progress.ok > span   { background: var(--ok-600); }

kbd {
    display: inline-block;
    padding: 1px 5px; border-radius: 3px;
    border: 1px solid var(--ink-300); border-bottom-width: 2px;
    background: var(--ink-050);
    font-family: var(--mono); font-size: 10.5px; color: var(--ink-600);
    line-height: 1.5;
}

/* ------------------------------------------------- searchable select ----- */

.ss { position: relative; }
.ss .ss-native {
    /* The native select stays for form submission, but is never seen. */
    position: absolute; opacity: 0; pointer-events: none;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); border: 0;
}

.ss-toggle {
    display: flex; align-items: center; gap: 10px;
    width: 100%; min-height: 38px;
    padding: 6px 11px;
    border: 1px solid var(--ink-300);
    border-radius: var(--radius);
    background: #fff;
    font-family: inherit; font-size: 13.5px; color: var(--ink-900);
    text-align: left; cursor: pointer;
    transition: border-color .12s, box-shadow .12s;
}
.ss-toggle:hover { border-color: var(--ink-400); }
.ss-toggle:focus-visible,
.ss.is-open .ss-toggle {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.ss.is-disabled .ss-toggle { background: var(--ink-100); color: var(--ink-500); cursor: not-allowed; }

.ss-value { flex: 1; min-width: 0; line-height: 1.3; }
.ss-value.is-placeholder { color: var(--ink-400); }
.ss-value-label {
    display: block; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-value-meta {
    display: block; font-size: 11px; color: var(--ink-500);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-caret { flex-shrink: 0; color: var(--ink-500); transition: transform .15s; }
.ss.is-open .ss-caret { transform: rotate(180deg); }

.ss-panel {
    position: absolute; left: 0; right: 0; top: calc(100% + 5px);
    z-index: 80;
    background: #fff;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: ss-in .12s ease-out;
}
.ss.ss-up .ss-panel { top: auto; bottom: calc(100% + 5px); }
@keyframes ss-in { from { opacity: 0; transform: translateY(-4px); } }

.ss-searchbox {
    position: relative;
    padding: 9px;
    border-bottom: 1px solid var(--ink-200);
    background: var(--ink-050);
}
.ss-searchbox svg {
    position: absolute; left: 19px; top: 50%; transform: translateY(-50%);
    color: var(--ink-400); pointer-events: none;
}
.ss-search {
    width: 100%; height: 34px;
    padding: 0 10px 0 31px;
    border: 1px solid var(--ink-300);
    border-radius: var(--radius-sm);
    background: #fff;
    font-family: inherit; font-size: 13.5px; color: var(--ink-900);
}
.ss-search:focus {
    outline: none; border-color: var(--brand-500);
    box-shadow: 0 0 0 2px var(--brand-100);
}

.ss-list { max-height: 292px; overflow-y: auto; padding: 5px; }
.ss-list::-webkit-scrollbar { width: 8px; }
.ss-list::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 4px; }

.ss-group {
    padding: 9px 9px 4px;
    font-size: 10px; font-weight: 700; letter-spacing: .07em;
    text-transform: uppercase; color: var(--ink-500);
    position: sticky; top: 0; background: #fff; z-index: 1;
}
.ss-group:first-child { padding-top: 4px; }

.ss-option {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.ss-option.is-active { background: var(--brand-050); }
.ss-option.is-selected { background: var(--brand-100); }
.ss-option.is-selected .ss-opt-label { color: var(--brand-800); }
.ss-option.is-disabled { opacity: .5; cursor: not-allowed; }
.ss-option.is-disabled.is-active { background: none; }

.ss-opt-main { flex: 1; min-width: 0; }
.ss-opt-label {
    display: block; font-size: 13px; font-weight: 600; color: var(--ink-900);
    line-height: 1.35;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-opt-meta {
    display: block; font-size: 11px; color: var(--ink-500);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-opt-right {
    flex-shrink: 0; font-size: 12.5px; font-weight: 650;
    color: var(--ink-700); font-variant-numeric: tabular-nums;
}
.ss-opt-note {
    flex-shrink: 0; font-size: 10px; font-weight: 650;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--ok-700); background: var(--ok-100);
    padding: 1px 6px; border-radius: 9px;
}
.ss-option mark {
    background: #fde68a; color: inherit;
    padding: 0 1px; border-radius: 2px;
}

.ss-empty { padding: 26px 12px; text-align: center; color: var(--ink-500); font-size: 13px; }

@media (max-width: 720px) {
    .ss-list { max-height: 46vh; }
    .ss-toggle { min-height: 42px; }
}

/* --------------------------------------------------------------- dropdown */

.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 210px;
    background: #fff;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 5px;
    display: none; z-index: 70;
}
.dropdown-menu.open { display: block; }
.dropdown-menu.wide { min-width: 360px; }
.dropdown-menu a, .dropdown-menu button {
    display: flex; align-items: center; gap: 9px;
    width: 100%; padding: 7px 10px;
    border: 0; background: none; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13px; color: var(--ink-700);
    text-align: left; cursor: pointer; text-decoration: none;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--ink-100); color: var(--ink-900); text-decoration: none; }
.dropdown-menu svg { width: 15px; height: 15px; opacity: .75; }
.dropdown-menu .sep { height: 1px; background: var(--ink-200); margin: 5px 0; }
.dropdown-menu .head {
    padding: 8px 10px 6px; font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500);
    display: flex; align-items: center;
}
.dropdown-menu .danger { color: var(--bad-700); }

/* ---------------------------------------------------------- notifications */

.notif-list { max-height: 400px; overflow-y: auto; }
.notif-item {
    display: flex; gap: 10px; padding: 10px;
    border-radius: var(--radius-sm);
    text-decoration: none; color: inherit;
}
.notif-item:hover { background: var(--ink-050); text-decoration: none; }
.notif-item.unread { background: var(--brand-050); }
.notif-item .ico {
    width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; flex-shrink: 0;
    background: var(--ink-100); color: var(--ink-600);
}
.notif-item .ico svg { width: 15px; height: 15px; }
.notif-item.p-critical .ico { background: var(--bad-100); color: var(--bad-700); }
.notif-item.p-high .ico { background: var(--warn-100); color: var(--warn-700); }
.notif-item .body { min-width: 0; }
.notif-item .body strong { display: block; font-size: 12.5px; color: var(--ink-900); }
.notif-item .body p { margin: 1px 0 2px; font-size: 12px; color: var(--ink-600); }
.notif-item .body time { font-size: 10.5px; color: var(--ink-400); }

/* ------------------------------------------------------------------ auth */

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 460px;
    background: var(--brand-900);
}
.auth-hero {
    position: relative;
    padding: 48px;
    display: flex; flex-direction: column; justify-content: space-between;
    color: #dbe7f0;
    background:
        radial-gradient(900px 500px at 15% 10%, rgba(61,143,184,.28), transparent 60%),
        radial-gradient(700px 500px at 85% 90%, rgba(18,88,127,.4), transparent 60%),
        var(--brand-900);
    overflow: hidden;
}
.auth-hero::after {
    /* faint technical grid — reads as engineering, not decoration */
    content: ""; position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 44px 44px;
    pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero .logo { display: flex; align-items: center; }
.auth-hero .logo .logo-plate { padding: 12px 18px; border-radius: 12px; }
/* Scales with the viewport but never exceeds its natural size. */
.auth-hero .logo .logo-img { max-height: clamp(38px, 4.4vw, 58px); }
.auth-hero h1 { color: #fff; font-size: 32px; max-width: 15ch; line-height: 1.2; }
.auth-hero .lede { font-size: 15px; max-width: 46ch; color: #a9c2d3; margin-top: 12px; }
.auth-hero .points { display: grid; gap: 12px; margin-top: 26px; }
.auth-hero .point { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.auth-hero .point svg { width: 17px; height: 17px; color: var(--brand-400); flex-shrink: 0; margin-top: 1px; }
.auth-hero .foot { font-size: 12px; color: #6d8fa6; }

.auth-panel {
    background: #fff;
    padding: 48px 44px;
    display: flex; flex-direction: column; justify-content: center;
}
/* Shown only once the hero is dropped — see the responsive block below. */
.auth-panel .auth-brand { display: none; margin-bottom: 22px; }
.auth-panel .auth-brand .logo-img { max-height: 52px; max-width: 240px; }
.auth-panel h2 { font-size: 21px; margin-bottom: 5px; }
.auth-panel .sub { color: var(--ink-500); margin-bottom: 26px; }
.auth-panel .demo {
    margin-top: 26px; padding-top: 18px;
    border-top: 1px dashed var(--ink-200);
}
.auth-panel .demo h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-500); margin-bottom: 9px; }
.demo-accounts { display: grid; gap: 6px; }
.demo-account {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px; border: 1px solid var(--ink-200);
    border-radius: var(--radius); background: var(--ink-050);
    font-size: 12.5px; cursor: pointer; width: 100%;
    font-family: inherit; text-align: left;
}
.demo-account:hover { background: var(--brand-050); border-color: var(--brand-400); }
.demo-account .role { font-weight: 650; color: var(--ink-800); }
.demo-account .creds { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-500); }

/* ------------------------------------------------- branding (settings) */

.brand-slots { display: grid; gap: 14px; }
.brand-slot {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    padding: 14px;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    background: var(--ink-050);
}
.brand-preview {
    display: grid; place-items: center;
    min-height: 84px; padding: 12px;
    background: #fff;
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-sm);
    /* A soft chequerboard, so a transparent PNG reads as transparent rather
       than as a logo that happens to have a white background. */
    background-image:
        linear-gradient(45deg, var(--ink-100) 25%, transparent 25%, transparent 75%, var(--ink-100) 75%),
        linear-gradient(45deg, var(--ink-100) 25%, transparent 25%, transparent 75%, var(--ink-100) 75%);
    background-size: 14px 14px;
    background-position: 0 0, 7px 7px;
}
.brand-preview img { max-width: 100%; max-height: 60px; width: auto; height: auto; object-fit: contain; }
.brand-preview.square img { max-height: 72px; }
.brand-detail .brand-title {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-weight: 650; color: var(--ink-800); font-size: 14px;
}
.brand-detail .hint { margin-bottom: 9px; }
.brand-detail input[type="file"] { padding: 6px 8px; font-size: 12.5px; }
.brand-detail .checkbox { margin-top: 8px; }

.brand-variants { display: flex; gap: 10px; flex-wrap: wrap; }
.brand-variant {
    flex: 1 1 200px;
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--ink-200); border-radius: var(--radius);
    background: #fff; cursor: pointer;
}
.brand-variant:has(input:checked) { border-color: var(--brand-500); background: var(--brand-050); }
.brand-variant .swatch { flex: 1; min-width: 0; display: flex; justify-content: center; }
.brand-variant .swatch img { max-width: 100%; max-height: 30px; width: auto; height: auto; }
.brand-variant .name { font-size: 12.5px; color: var(--ink-600); white-space: nowrap; }

@media (max-width: 560px) {
    .brand-slot { grid-template-columns: minmax(0, 1fr); }
    .brand-variant { flex-direction: column; align-items: stretch; text-align: center; }
}

/* ------------------------------------------------------------------ print */

@media print {
    .sidebar, .topbar, .no-print, .page-head .actions { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .card { border: 0; box-shadow: none; }
    body { background: #fff; }
}

/* ------------------------------------------------------------ responsive */

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

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

@media (max-width: 980px) {
    :root { --sidebar-w: 260px; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open::after {
        content: ""; position: fixed; inset: 0;
        background: rgba(15,23,42,.5); z-index: 50;
    }
    .main { margin-left: 0; }
    .topbar .menu-toggle { display: grid; }
    .topbar-search { display: none; }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; }
}

@media (max-width: 720px) {
    .content { padding: 14px; padding-bottom: 76px; }
    .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); }
    h1 { font-size: 19px; }
    .user-chip .meta { display: none; }
    .page-head .actions { width: 100%; }
    .page-head .actions .btn { flex: 1; }

    /* Tables reflow into stacked records rather than shrinking to nothing. */
    table.data.responsive thead { display: none; }
    table.data.responsive tbody tr {
        display: block; padding: 10px 12px;
        border-bottom: 1px solid var(--ink-200);
    }
    table.data.responsive tbody td {
        display: flex; justify-content: space-between; gap: 14px;
        padding: 3px 0; border: 0; text-align: right;
    }
    table.data.responsive tbody td::before {
        content: attr(data-label);
        font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
        color: var(--ink-500); font-weight: 700; text-align: left;
    }
    table.data.responsive tbody td.num { text-align: right; }
    table.data.responsive tfoot { display: none; }
}

/* ------------------------------------------------- responsive: sign-in */

@media (max-width: 1080px) {
    /* Give the hero back some room before anything has to be dropped. */
    .auth-page { grid-template-columns: minmax(0, 1fr) 400px; }
    .auth-hero { padding: 36px 32px; }
    .auth-hero h1 { font-size: 27px; }
    .auth-panel { padding: 40px 32px; }
}

/*
 * Below this the two-column split stops working — the hero column is too
 * narrow to read and only crushes the form. Drop it entirely rather than
 * shrink it, and move the logo into the panel so the page still identifies
 * itself. The hero carries marketing copy only; nothing needed to sign in is
 * lost by hiding it.
 */
@media (max-width: 880px) {
    .auth-page {
        grid-template-columns: minmax(0, 1fr);
        background: var(--ink-100);
        place-items: start center;
    }
    .auth-hero { display: none; }
    .auth-panel {
        display: flex;
        width: 100%;
        max-width: 460px;
        min-height: 100vh;
        min-height: 100svh;
        padding: 40px 28px calc(40px + env(safe-area-inset-bottom));
    }
    .auth-panel .auth-brand { display: block; }
}

@media (max-width: 420px) {
    .auth-panel { padding: 28px 18px calc(28px + env(safe-area-inset-bottom)); }
    .auth-panel .auth-brand { margin-bottom: 18px; }
    .auth-panel .auth-brand .logo-img { max-height: 46px; max-width: 100%; }
    .auth-panel h2 { font-size: 19px; }
    .demo-account { flex-wrap: wrap; }
    .demo-account .creds { margin-left: 0; }
}

/* Bottom navigation for phones */
.bottom-nav { display: none; }
@media (max-width: 720px) {
    .bottom-nav {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        position: fixed; inset: auto 0 0 0;
        background: #fff;
        border-top: 1px solid var(--ink-200);
        z-index: 45;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .bottom-nav a {
        display: flex; flex-direction: column; align-items: center; gap: 2px;
        padding: 8px 2px 7px;
        font-size: 10px; font-weight: 600; color: var(--ink-500);
        text-decoration: none;
    }
    .bottom-nav a svg { width: 19px; height: 19px; }
    .bottom-nav a.active { color: var(--brand-600); }
}

/* ==========================================================================
   "Powered by Hashback" credit — sign-in, first-run setup and the portal.
   Rendered by app/Views/partials/powered-by.php.
   ========================================================================== */

.powered-by {
    display: inline-flex; align-items: center; gap: 7px;
    text-decoration: none;
    font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
    color: var(--ink-500);
    padding: 4px 2px;
    border-radius: var(--radius);
    /* The mark is quiet by default and comes forward on hover, so it credits
       without competing with the customer's own branding. */
    opacity: .72;
    transition: opacity .15s ease, color .15s ease;
}
.powered-by:hover,
.powered-by:focus-visible { opacity: 1; color: var(--brand-600); }
.powered-by:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* Height-constrained; width follows the 419x87 aspect ratio on its own. */
.powered-by img {
    height: 17px; width: auto; display: block;
}

/* On the dark hero panel the slate grey would disappear. */
.powered-by.is-dark { color: #8fb3c9; opacity: .78; }
.powered-by.is-dark:hover,
.powered-by.is-dark:focus-visible { color: #d7e8f2; opacity: 1; }

/* Portal footer strip. Sits under the page content, inside the main column so
   it lines up with the content rather than running under the sidebar. */
.app-footer {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px;
    margin-top: 28px; padding: 16px 0 4px;
    border-top: 1px solid var(--ink-200);
    font-size: 11.5px; color: var(--ink-400);
}
.app-footer .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

@media (max-width: 720px) {
    .app-footer { justify-content: center; text-align: center; }
    /* Clear the fixed bottom navigation. */
    .app-footer { margin-bottom: 68px; }
}

@media print {
    .app-footer, .powered-by { display: none !important; }
}

/* Credit at the foot of the sign-in / setup panel. */
.auth-credit {
    margin-top: 26px; padding-top: 16px;
    border-top: 1px solid var(--ink-200);
    text-align: center;
}
