/* Inklab — clean light theme */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --text: #101828;
    --muted: #667085;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #eff4ff;
    --danger: #d92d20;
    --danger-soft: #fef3f2;
    --success: #079455;

    /* status colours */
    --st-not-started: #667085;  --st-not-started-bg: #f2f4f7;
    --st-in-work: #b54708;      --st-in-work-bg: #fffaeb;
    --st-finished: #067647;     --st-finished-bg: #ecfdf3;
    --st-in-delivery: #175cd3;  --st-in-delivery-bg: #eff8ff;
    --st-split: #6941c6;        --st-split-bg: #f4f3ff;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 28px;
}
.brand {
    display: flex; align-items: center; gap: 9px;
    font-weight: 700; font-size: 16px; color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 26px; height: 26px; border-radius: 7px;
    background: var(--accent); color: #fff;
    display: grid; place-items: center; font-size: 14px;
}
.nav { display: flex; gap: 2px; height: 100%; }
.nav a {
    display: flex; align-items: center; gap: 8px;
    padding: 0 12px;
    color: var(--muted);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.nav a i { font-size: 13px; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); border-bottom-color: var(--accent); }
.badge {
    background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 600; line-height: 1;
    padding: 3px 6px; border-radius: 999px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.user { display: flex; align-items: center; gap: 6px; font-weight: 500; }

/* ---------- page ---------- */
.page {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 24px 40px;
    flex: 1;
}
.page-narrow { max-width: 880px; }
.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-header p { margin: 4px 0 0; color: var(--muted); }

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 20px;
}
.footer a { color: var(--muted); text-decoration: underline; }

/* ---------- cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.page > .card + .card { margin-top: 20px; }
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.card-body { padding: 18px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 13px; font-weight: 500; color: #344054; }
.input, .select, textarea.input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.select {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23667085' stroke-width='1.6' d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.input:focus, .select:focus, .multiselect-toggle:focus {
    outline: none;
    border-color: #84adff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}
.input::placeholder { color: #98a2b3; }

.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(12, 1fr); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.input-group { display: flex; gap: 8px; }
.input-group > :first-child { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    height: 28px; padding: 0 11px;
    font: inherit; font-size: 12px; font-weight: 500; color: #344054;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
    cursor: pointer;
}
.chip:hover { border-color: var(--border-strong); background: var(--surface); }
.chip.active { background: var(--accent-soft); border-color: #b2ccff; color: var(--accent); }

/* status multiselect */
.multiselect { position: relative; }
.multiselect-toggle {
    width: 100%; height: 38px; padding: 0 34px 0 12px;
    text-align: left; font: inherit; color: var(--text);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23667085' stroke-width='1.6' d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.multiselect-options {
    display: none;
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    padding: 4px;
}
.multiselect-options.show { display: block; }
.multiselect-options div {
    padding: 8px 10px 8px 32px; border-radius: 5px; cursor: pointer; position: relative;
}
.multiselect-options div:hover { background: var(--surface-2); }
.multiselect-options div::before {
    content: ''; position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; border: 1px solid var(--border-strong); border-radius: 4px;
}
.multiselect-options div.selected::before {
    background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='none' stroke='white' stroke-width='1.8' d='m2 5 2 2 4-4'/%3E%3C/svg%3E") no-repeat center;
    border-color: var(--accent);
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 14px;
    font: inherit; font-weight: 600; white-space: nowrap;
    color: #344054; background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; box-shadow: none; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.icon-btn {
    width: 30px; height: 30px; padding: 0;
    display: inline-grid; place-items: center;
    border: 1px solid transparent; border-radius: 6px;
    background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); border-color: #fecdca; color: var(--danger); }

.segmented {
    display: inline-flex; padding: 3px; gap: 2px;
    background: #f2f4f7; border-radius: 8px;
}
.segmented button {
    height: 30px; padding: 0 12px; border: 0; border-radius: 6px;
    font: inherit; font-weight: 500; font-size: 13px; color: var(--muted);
    background: transparent; cursor: pointer;
}
.segmented button:disabled { background: var(--surface); color: var(--text); box-shadow: var(--shadow); cursor: default; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; font-size: 12px; font-weight: 500; color: var(--muted);
    background: var(--surface-2);
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfcfd; }
td.right, th.right { text-align: right; }
td.nowrap { white-space: nowrap; }
.code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; font-weight: 500; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 14px; }

[contenteditable="true"] { border-radius: 5px; outline: 1px solid transparent; cursor: text; }
[contenteditable="true"]:hover { outline-color: var(--border-strong); background: var(--surface); }
[contenteditable="true"]:focus { outline: 2px solid #84adff; background: var(--surface); }
td.saved { animation: saved 1.2s ease; }
@keyframes saved { from { background: #dcfae6; } to { background: transparent; } }
.comments_row { min-width: 220px; max-width: 360px; font-size: 13px; color: #344054; }

/* order rows: whole row coloured per status (old colours) */
.orders-table tr.in-work td { background: #f3f387; }
.orders-table tr.in-delivery td { background: #979797; }
.orders-table tr.finished td { background: #ccffcc; }
.orders-table tr.has-hyphen td { background: #f8af99; }
.orders-table tbody tr td.late-cell { background: #d62222; color: #fff; }

/* back to top */
.backToTop {
    position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000;
    display: none; padding: 10px 16px;
    background: var(--accent); color: #fff; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); font-weight: 600;
}
.backToTop:hover { background: var(--accent-hover); text-decoration: none; }

/* pills */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.st-not_started { color: var(--st-not-started); background: var(--st-not-started-bg); }
.pill.st-in_work { color: var(--st-in-work); background: var(--st-in-work-bg); }
.pill.st-finished { color: var(--st-finished); background: var(--st-finished-bg); }
.pill.st-in_delivery { color: var(--st-in-delivery); background: var(--st-in-delivery-bg); }
.late-flag { color: var(--muted); }
.late-flag.late-cell { color: var(--danger); font-weight: 600; }
.status-select { height: 32px; font-size: 13px; width: 150px; }

/* ---------- toolbar + pagination ---------- */
.toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.toolbar-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.totals { display: flex; gap: 18px; font-size: 13px; }
.totals strong { font-size: 15px; }

.pagination { display: flex; align-items: center; gap: 4px; }
.pagination a, .pagination span {
    min-width: 32px; height: 32px; padding: 0 8px;
    display: inline-grid; place-items: center;
    border-radius: 6px; color: #344054; font-weight: 500; font-size: 13px;
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination a.current { background: var(--accent-soft); color: var(--accent); }
.pagination span { color: var(--muted); }
.card-footer {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 18px; border-top: 1px solid var(--border);
}

/* ---------- modal ---------- */
.modal {
    display: none;
    position: fixed; inset: 0; z-index: 100;
    background: rgba(16, 24, 40, .45);
    padding: 16px;
}
.modal.open { display: grid; place-items: center; }
.modal-content {
    width: min(420px, 100%);
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 22px;
    display: flex; flex-direction: column; gap: 14px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- toast ---------- */
.toast {
    position: fixed; bottom: 20px; left: 50%; z-index: 200;
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    background: #101828; color: #fff;
    padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg);
    font-weight: 500; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.alert {
    padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
    background: var(--danger-soft); color: var(--danger); border: 1px solid #fecdca;
}

/* ---------- layouts ---------- */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.stats-grid .wide { grid-column: 1 / -1; }

.chart {
    display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px;
    height: 220px; align-items: end;
    padding-top: 22px;
}
.chart-col { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bar {
    width: 100%; max-width: 46px; min-height: 2px;
    background: #b2ccff; border-radius: 5px 5px 2px 2px;
    position: relative; transition: background .15s;
}
.chart-col:last-child .chart-bar { background: var(--accent); }
.chart-col:hover .chart-bar { background: var(--accent-hover); }
.chart-bar span {
    position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
    font-size: 11px; color: var(--muted); white-space: nowrap;
}
.chart-label { font-size: 12px; color: var(--muted); overflow: hidden; max-width: 100%; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 140px 1fr 110px; gap: 12px; align-items: center; font-size: 13px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hbar .track { height: 10px; background: #f2f4f7; border-radius: 999px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.hbar .val { text-align: right; color: var(--muted); }

.stack { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #f2f4f7; gap: 2px; }
.stack div { min-width: 3px; }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.legend-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.legend-item strong { font-size: 15px; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 28px; }
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }

/* ---------- legal ---------- */
.prose h2 { margin: 22px 0 6px; }
.prose p { margin: 0 0 10px; color: #344054; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split, .stats-grid { grid-template-columns: minmax(0, 1fr); }
    .span-2, .span-3 { grid-column: span 4; }
}
@media (max-width: 760px) {
    .topbar-inner { padding: 0 16px; gap: 14px; height: auto; min-height: 56px; flex-wrap: wrap; }
    .nav { order: 3; width: 100%; height: 44px; overflow-x: auto; scrollbar-width: none; }
    .today, .hide-sm, .user { display: none; }
    .page { padding: 20px 16px 32px; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid > * { grid-column: 1 / -1; }
    .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
    .hbar { grid-template-columns: 90px 1fr 80px; }
    .chart { gap: 3px; }
    .chart-label { font-size: 10px; }
    .chart-bar span { display: none; }
}
