/* ────────────────────────────────────────────────────────────
   Skladex — "Dock Board" design system
   Palette: cool paper + graphite ink + amber beacon + teal secondary.
   Data (counts, sums, SKUs) is set in tabular monospace throughout —
   this is a warehouse ledger, numbers are the primary content.
──────────────────────────────────────────────────────────── */

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

:root {
    /* surfaces */
    --bg: #F1F3EE;
    --surface: #FFFFFF;
    --surface-2: #E8EBE3;
    --border: #DCE1D8;

    /* ink */
    --text: #1B2420;
    --muted: #626F68;

    /* beacon amber — primary actions, active states */
    --primary: #B25908;
    --primary-hover: #96490A;
    --primary-tint: #F7E9D6;

    /* teal — secondary accent, nav, links */
    --accent-2: #2B6C58;
    --accent-2-hover: #23594A;
    --accent-2-tint: #E1EDE8;

    /* semantic */
    --success: #227A56;
    --success-tint: #E3F1EA;
    --success-ink: #17563D;
    --warning: #8C7108;
    --warning-tint: #F5EDD4;
    --warning-ink: #6B5606;
    --error: #BF4433;
    --error-tint: #FBEAE6;
    --error-ink: #8F3226;

    /* text to place on top of a solid --primary/--warning/--error fill */
    --on-accent: #fff;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(27,36,32,.06), 0 1px 1px rgba(27,36,32,.04);
    --shadow-md: 0 8px 28px rgba(27,36,32,.12);

    --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

    color-scheme: light;
}

/* ─── Dark theme — "Night Board" ────────────────────────────
   Toggled via [data-theme="dark"] on <html>, set by the switch
   in the topbar and remembered in localStorage. Same hues as the
   light theme, re-tuned for a dark surface: warm accents read
   brighter (so they still work as text on a dark page), so the
   filled buttons/badges that need to stay readable swap to dark
   ink text via --on-accent instead of white.
──────────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
    --bg: #14171C;
    --surface: #1D211C;
    --surface-2: #262B23;
    --border: #333A30;

    --text: #E9E6DC;
    --muted: #9CA89A;

    --primary: #E8871E;
    --primary-hover: #F2984A;
    --primary-tint: #3A2A16;

    --accent-2: #5FB89A;
    --accent-2-hover: #78CBAF;
    --accent-2-tint: #17332B;

    --success: #4CAF7C;
    --success-tint: #16321F;
    --success-ink: #7FD9AC;
    --warning: #D1A927;
    --warning-tint: #332A0F;
    --warning-ink: #E8C55A;
    --error: #E2685A;
    --error-tint: #331C18;
    --error-ink: #F0968A;

    --on-accent: #1B2420;

    --shadow: 0 1px 2px rgba(0,0,0,.24), 0 1px 1px rgba(0,0,0,.18);
    --shadow-md: 0 8px 28px rgba(0,0,0,.4);

    color-scheme: dark;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    padding-top: 4px; /* clears the fixed beacon strip */
    transition: background .2s, color .2s;
}

/* the beacon strip: a thin dock marking across the very top of every page */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary) 45%, var(--accent-2) 100%);
    z-index: 300;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }

a { color: var(--accent-2); }

::selection { background: var(--primary-tint); color: var(--text); }

:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
}

table { font-variant-numeric: tabular-nums; }

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 1.5rem;
    height: 58px;
    position: sticky;
    top: 4px;
    z-index: 100;
    box-shadow: var(--shadow);
}

.topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
    color: var(--text);
    white-space: nowrap;
}

.topbar__brand::before {
    content: '';
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background-color: var(--text);
    background-image:
        linear-gradient(var(--bg), var(--bg)),
        linear-gradient(var(--bg), var(--bg)),
        linear-gradient(var(--primary), var(--primary));
    background-repeat: no-repeat;
    background-size: 3px 7px, 3px 11px, 3px 15px;
    background-position: 7px 16px, 12.5px 12px, 18px 8px;
}

.topbar__nav {
    display: flex;
    gap: .2rem;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: thin;
}

.topbar__link {
    padding: .4rem .8rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--muted);
    font-size: .87rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.topbar__link:hover { background: var(--bg); color: var(--text); }
.topbar__link--active { background: var(--accent-2-tint); color: var(--accent-2-hover); font-weight: 600; }

.topbar__user {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .83rem;
    color: var(--muted);
    white-space: nowrap;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: .95rem;
    line-height: 1;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle .theme-toggle__dark { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-toggle__light { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-toggle__dark { display: inline; }

/* ─── Layout ─────────────────────────────────────────────── */
.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.page-title {
    font-family: var(--font-display);
    font-size: 1.55rem;
    font-weight: 600;
    letter-spacing: -.01em;
    margin-bottom: 1.5rem;
}

.page-subtitle {
    color: var(--muted);
    margin-top: -.75rem;
    margin-bottom: 1.5rem;
}

/* ─── Login ──────────────────────────────────────────────── */
.login-page {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 1px 1px, rgba(27,36,32,.07) 1px, transparent 0) 0 0 / 22px 22px,
        linear-gradient(160deg, #EAEEE6 0%, var(--bg) 55%);
    padding: 1.5rem;
}

:root[data-theme="dark"] .login-page {
    background:
        radial-gradient(circle at 1px 1px, rgba(233,230,220,.06) 1px, transparent 0) 0 0 / 22px 22px,
        linear-gradient(160deg, #1A1E19 0%, var(--bg) 55%);
}

.theme-toggle--login {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 14px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.login-card__mark {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    background-color: var(--text);
    background-image:
        linear-gradient(var(--surface), var(--surface)),
        linear-gradient(var(--surface), var(--surface)),
        linear-gradient(var(--primary), var(--primary));
    background-repeat: no-repeat;
    background-size: 4px 10px, 4px 16px, 4px 22px;
    background-position: 10px 24px, 18px 18px, 26px 12px;
    margin: 0 auto 1.25rem;
}

.login-card__title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -.01em;
    text-align: center;
    margin-bottom: .25rem;
}

.login-card__subtitle {
    text-align: center;
    color: var(--muted);
    margin-bottom: 2rem;
    font-size: .9rem;
}

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .35rem;
}

.form-control {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-tint);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, opacity .15s, border-color .15s;
}

.btn--primary { background: var(--primary); color: var(--on-accent); }
.btn--primary:hover { background: var(--primary-hover); }

.btn--ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

.btn--danger { background: var(--error); color: var(--on-accent); }
.btn--danger:hover { opacity: .9; }

.btn--sm { padding: .3rem .7rem; font-size: .78rem; }
.btn--block { width: 100%; }

/* ─── Alerts ─────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: .9rem;
    border: 1px solid transparent;
}

.alert--success { background: var(--success-tint); border-color: var(--success); color: var(--success-ink); }
.alert--error   { background: var(--error-tint);   border-color: var(--error);   color: var(--error-ink); }
.alert--warning { background: var(--warning-tint); border-color: var(--warning); color: var(--warning-ink); }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow);
}

.stat-card:nth-child(4n+2) { border-left-color: var(--accent-2); }
.stat-card:nth-child(4n+3) { border-left-color: var(--success); }
.stat-card:nth-child(4n+4) { border-left-color: var(--warning); }

.stat-card__label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
.stat-card__value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 2rem;
    font-weight: 600;
    margin-top: .3rem;
}

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.table-wrap table { border: none; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

th, td {
    padding: .65rem .85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--surface-2);
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 600;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
}

.badge--green  { background: var(--success-tint); color: var(--success-ink); }
.badge--yellow { background: var(--warning-tint); color: var(--warning-ink); }
.badge--red    { background: var(--error-tint);   color: var(--error-ink); }
.badge--blue   { background: var(--accent-2-tint); color: var(--accent-2-hover); }
.badge--gray   { background: var(--surface-2); color: var(--muted); }

/* ─── Placeholder ────────────────────────────────────────── */
.coming-soon {
    text-align: center;
    padding: 3rem;
    color: var(--muted);
}

.coming-soon__icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
    .topbar { gap: .85rem; padding: 0 1rem; }
    .topbar__user span { display: none; }
    .container { padding: 1.25rem 1rem 2.5rem; }
    .page-title { font-size: 1.3rem; }
}

/* ─── Topbar settings menu (⚙️) ─────────────────────────── */
.topbar-menu { position: relative; }
.topbar-menu > summary { list-style: none; }
.topbar-menu > summary::-webkit-details-marker { display: none; }
.theme-toggle--active { background: var(--accent-2-tint); border-color: var(--accent-2-tint); }
.topbar-menu__list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: .3rem;
    display: flex;
    flex-direction: column;
    z-index: 200;
}
.topbar-menu__link {
    padding: .45rem .7rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-size: .87rem;
}
.topbar-menu__link:hover { background: var(--bg); }
.topbar-menu__link--active { background: var(--accent-2-tint); color: var(--accent-2-hover); font-weight: 600; }
