/* =========================================================
   AquaStock theme
   Ink sidebar, lagoon primary, crate-yellow for pack counts.
   ========================================================= */
:root {
    --ink: #0f2233;
    --ink-2: #172f45;
    --ink-line: rgba(255, 255, 255, .09);
    --lagoon: #0a8ea6;
    --lagoon-dark: #076d80;
    --lagoon-soft: #dff1f5;
    --crate: #e9a820;
    --crate-soft: #fdf1d3;
    --mist: #edf2f5;
    --foam: #ffffff;
    --text: #22313f;
    --muted: #6a7b88;
    --line: #dce4ea;
    --danger: #c2453b;
    --danger-soft: #fbe6e3;
    --ok: #2f8f6b;
    --ok-soft: #dcf2e8;
    --radius: 10px;
    --sidebar-w: 248px;
    --font-head: 'Bricolage Grotesque', 'Segoe UI', sans-serif;
    --font-body: 'Public Sans', 'Segoe UI', system-ui, sans-serif;
}

html, body { height: 100%; }
body {
    font-family: var(--font-body);
    font-size: .92rem;
    color: var(--text);
    background: var(--mist);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5 { font-family: var(--font-head); font-weight: 700; letter-spacing: -.01em; }
a { color: var(--lagoon-dark); }
:focus-visible { outline: 2px solid var(--lagoon); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
    color: #cfdbe5; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: 1.25rem 1.25rem 1rem; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px; background: var(--lagoon); color: #fff;
    display: grid; place-items: center; font-size: 1.15rem;
}
.brand-name { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; color: #fff; letter-spacing: -.02em; }
.side-nav { padding: .25rem .75rem; flex: 1; }
.nav-group { margin: 1.1rem .6rem .35rem; font-size: .75rem; color: #7f94a6; font-weight: 600; letter-spacing: .02em; }
.side-nav .nav-link {
    display: flex; align-items: center; gap: .7rem; color: #cfdbe5; padding: .55rem .75rem;
    border-radius: 8px; border-left: 3px solid transparent; margin-bottom: 2px;
}
.side-nav .nav-link i { font-size: 1.05rem; opacity: .85; }
.side-nav .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav .nav-link.active { background: rgba(10, 142, 166, .22); color: #fff; border-left-color: var(--crate); }
.side-foot { padding: 1rem 1.1rem 1.25rem; border-top: 1px solid var(--ink-line); }
.who { display: flex; align-items: center; gap: .65rem; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--crate); color: var(--ink);
    display: grid; place-items: center; font-weight: 700;
}
.who-text { display: flex; flex-direction: column; line-height: 1.15; color: #fff; }
.who-text small { color: #93a8b9; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: .9rem; padding: .9rem 1.6rem; background: var(--foam);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 1.35rem; margin: 0; flex: 1; }
.content { padding: 1.4rem 1.6rem 2.5rem; }

/* ---------- panels ---------- */
.panel {
    background: var(--foam); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.toolbar .form-label { margin-bottom: .2rem; }

.form-label { font-weight: 600; font-size: .82rem; color: #405464; }
.form-control, .form-select, .ts-control { border-color: #cbd6de; border-radius: 8px; }
.form-control:focus, .form-select:focus, .ts-wrapper.focus .ts-control {
    border-color: var(--lagoon); box-shadow: 0 0 0 .2rem rgba(10, 142, 166, .16);
}
.form-control[readonly] { background: #f3f7f9; }

.btn { border-radius: 8px; font-weight: 600; }
.btn-primary { background: var(--lagoon); border-color: var(--lagoon); }
.btn-primary:hover, .btn-primary:focus { background: var(--lagoon-dark); border-color: var(--lagoon-dark); }
.btn-outline-primary { color: var(--lagoon-dark); border-color: var(--lagoon); }
.btn-outline-primary:hover { background: var(--lagoon); border-color: var(--lagoon); }
.btn-crate { background: var(--crate); border-color: var(--crate); color: var(--ink); }
.btn-crate:hover { background: #d19717; border-color: #d19717; color: var(--ink); }

/* ---------- KPI strip ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
.kpi {
    background: var(--foam); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1rem 1.1rem; border-top: 3px solid var(--lagoon);
}
.kpi.crate { border-top-color: var(--crate); }
.kpi.alert { border-top-color: var(--danger); }
.kpi .label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.kpi .value { font-family: var(--font-head); font-size: 1.75rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: .78rem; }

/* ---------- chips & badges ---------- */
.chip { display: inline-block; padding: .12rem .55rem; border-radius: 6px; font-weight: 600; font-size: .8rem; font-variant-numeric: tabular-nums; }
.chip-pack { background: var(--crate-soft); color: #7a5300; }
.chip-loose { background: var(--lagoon-soft); color: var(--lagoon-dark); }
.chip-zero { background: #eef1f3; color: #8a98a3; }
.chip-due { background: var(--danger-soft); color: var(--danger); }
.chip-clear { background: var(--ok-soft); color: var(--ok); }
.chip-role { background: #e8edf5; color: #34506f; }

/* ---------- Tabulator skin ---------- */
.tabulator { border: 1px solid var(--line); border-radius: var(--radius); background: var(--foam); font-size: .88rem; }
.tabulator .tabulator-header { background: #f4f8fa; border-bottom: 1px solid var(--line); color: #33485a; }
.tabulator .tabulator-header .tabulator-col { background: transparent; border-right: 1px solid #e6edf1; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content { padding: .55rem .6rem .35rem; }
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter { margin-top: 4px; }
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input {
    border: 1px solid #cbd6de; border-radius: 6px; padding: .18rem .45rem; font-size: .8rem; background: #fff;
}
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input:focus { border-color: var(--lagoon); outline: none; }
.tabulator-row { border-bottom: 1px solid #eef2f5; min-height: 38px; }
.tabulator-row.tabulator-row-even { background: #fafcfd; }
.tabulator-row:hover { background: var(--lagoon-soft) !important; }
.tabulator-row .tabulator-cell { border-right: 1px solid #f0f4f6; padding: .5rem .6rem; }
.tabulator-row .tabulator-cell .btn { padding: .1rem .45rem; }
.tabulator .tabulator-footer { background: #f4f8fa; border-top: 1px solid var(--line); color: var(--muted); }
.tabulator .tabulator-footer .tabulator-page.active { background: var(--lagoon); color: #fff; border-color: var(--lagoon); }
.tabulator .tabulator-footer .tabulator-page { border-radius: 6px; }
.tabulator-row.tabulator-calcs { background: #f4f8fa !important; font-weight: 700; }
.tabulator-row.tabulator-group {
    background: #e8f0f4; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line);
    padding: .5rem .8rem; font-weight: 600; color: var(--ink);
}
.tabulator-row.tabulator-group:hover { background: #dce9ef !important; }
.tabulator-row.tabulator-group span { color: var(--muted); font-weight: 500; }
.tabulator-row.tabulator-group .grp-out { float: right; color: var(--danger); font-weight: 700; }

/* ---------- entry grids (inward / payment) ---------- */
.entry-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.entry-table th {
    background: #f4f8fa; font-size: .8rem; color: #405464; padding: .55rem .6rem;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.entry-table td { padding: .45rem .5rem; border-bottom: 1px solid #eef2f5; vertical-align: middle; }
.entry-table .sr { width: 42px; color: var(--muted); text-align: center; }
.entry-table input.form-control { min-width: 96px; }
.entry-wrap { overflow-x: auto; border-radius: var(--radius); }
.total-bar {
    display: flex; justify-content: flex-end; gap: 2.2rem; padding: .9rem 1rem; background: #f4f8fa;
    border: 1px solid var(--line); border-radius: var(--radius); margin-top: .9rem; flex-wrap: wrap;
}
.total-bar .t-label { color: var(--muted); font-size: .8rem; display: block; }
.total-bar .t-value { font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- searchable dropdowns (Tom Select) ---------- */
.ts-dropdown { z-index: 1080; border-radius: 8px; border-color: #cbd6de; box-shadow: 0 10px 28px rgba(15, 34, 51, .18); }
.ts-dropdown .dropdown-input { border-radius: 6px; margin: .4rem; width: calc(100% - .8rem); }
.ts-dropdown .ts-dropdown-content { max-height: 260px; }
.ts-dropdown .active { background: var(--lagoon-soft); color: var(--ink); }

/* ---------- modal ---------- */
.modal-content { border: 0; border-radius: 14px; }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-title { font-family: var(--font-head); font-weight: 700; }
.modal-footer { border-top: 1px solid var(--line); }

/* ---------- login ---------- */
.login-body {
    min-height: 100vh; display: grid; place-items: center; padding: 1.2rem;
    background:
        radial-gradient(1200px 500px at 15% -10%, rgba(10, 142, 166, .35), transparent 60%),
        radial-gradient(900px 500px at 100% 110%, rgba(233, 168, 32, .22), transparent 60%),
        var(--ink);
}
.login-card {
    width: 100%; max-width: 380px; background: var(--foam); border-radius: 18px; padding: 2rem 1.8rem 1.6rem;
    box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
}
.login-card .brand { padding: 0 0 1.2rem; }
.login-card .brand-name { color: var(--ink); }
.pin-dots { display: flex; justify-content: center; gap: .9rem; margin: .6rem 0 1.2rem; }
.pin-dots span { width: 15px; height: 15px; border-radius: 50%; border: 2px solid #b8c7d2; background: transparent; transition: background .12s, border-color .12s; }
.pin-dots span.on { background: var(--lagoon); border-color: var(--lagoon); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.pin-key {
    border: 1px solid var(--line); background: #f6f9fb; border-radius: 12px; padding: .85rem 0;
    font-family: var(--font-head); font-size: 1.35rem; font-weight: 600; color: var(--ink);
}
.pin-key:hover { background: var(--lagoon-soft); border-color: var(--lagoon); }
.pin-key:active { background: var(--lagoon); color: #fff; }
.pin-key.util { font-size: 1rem; color: var(--muted); }
.login-error { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: .5rem .75rem; margin-bottom: .9rem; font-size: .85rem; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    .content { padding: 1rem; }
    .topbar { padding: .7rem 1rem; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
