/* ==========================================================================
   Daily Reports — base styles
   --------------------------------------------------------------------------
   ALL colours, radii and fonts live in the :root block below. To match the
   MBARIZA look exactly, change the values in this one block.
   ========================================================================== */

:root {
    /* Brand */
    --ink:          #0d2b45;   /* sidebar background */
    --ink-2:        #16405f;   /* sidebar hover / raised */
    --ink-text:     #c8d7e6;   /* sidebar text */
    --primary:      #0b6bcb;
    --primary-600:  #0a5cae;
    --primary-50:   #eaf3fc;
    --accent:       #f2b705;   /* used for the net-earnings rule */

    /* Feedback */
    --success:      #1c7a49;
    --success-50:   #e5f4ec;
    --warning:      #96600a;
    --warning-50:   #fff3d9;
    --danger:       #b5372b;
    --danger-50:    #fdeceb;

    /* Surfaces & text */
    --bg:           #f3f6f9;
    --surface:      #ffffff;
    --border:       #dfe5ec;
    --border-strong:#c6d0db;
    --text:         #16232f;
    --muted:        #5a6b7b;

    /* Shape */
    --radius:       12px;
    --radius-sm:    8px;
    --shadow:       0 1px 2px rgba(13, 43, 69, .06), 0 6px 18px rgba(13, 43, 69, .05);
    --focus:        0 0 0 3px rgba(11, 107, 203, .35);

    /* Type */
    --font:  "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --sidebar-w: 264px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: .85em; background: var(--bg); padding: .1em .4em; border-radius: 4px; }
[hidden] { display: none !important; }

.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: -999px; top: 8px; z-index: 100;
    background: var(--surface); padding: .5rem .8rem; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.push-right { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.icon { flex: none; vertical-align: -3px; }
.is-positive { color: var(--success); }
.is-negative { color: var(--danger); }

/* ------------------------------------------------------------------ Shell */

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.content { width: 100%; max-width: 1180px; padding: 2rem 2rem 4rem; margin: 0 auto; flex: 1; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    background: var(--ink); color: var(--ink-text);
    display: flex; flex-direction: column; padding: 1.25rem 1rem;
}
.brand { display: flex; align-items: center; gap: .75rem; padding: .25rem .5rem 1.25rem; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 9px; flex: none;
    background: var(--primary);
    box-shadow: inset 0 -9px 0 -5px var(--accent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { color: #fff; font-size: 1rem; }
.brand-text small { font-size: .74rem; opacity: .8; }

.nav { display: flex; flex-direction: column; gap: .2rem; }
.nav-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .75rem; border-radius: var(--radius-sm);
    color: var(--ink-text); font-weight: 500; font-size: .95rem;
    background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font-family: inherit;
}
.nav-link:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--primary); color: #fff; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: .9rem; display: grid; gap: .5rem; }
.me { display: flex; align-items: center; gap: .65rem; padding: 0 .5rem; }
.me-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--ink-2); color: #fff;
    display: grid; place-items: center; font-weight: 600; flex: none;
}
.me-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.me-text strong { color: #fff; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { font-size: .78rem; opacity: .8; }

.topbar { display: none; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(13, 43, 69, .5); z-index: 40; }

/* ------------------------------------------------------------- Page head */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head .lead { margin: .35rem 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.crumbs { margin: 0 0 .4rem; font-size: .85rem; }

/* ------------------------------------------------------------------ Cards */

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1rem; }
.card-head h2 { white-space: nowrap; }
.card-head p { margin: .25rem 0 0; font-size: .9rem; }
.card-head.padded { padding: 1.25rem 1.25rem 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.two-col .card { margin-bottom: 0; }

/* ------------------------------------------------------------------ Stats */

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.15rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .2rem;
}
.stat-label { font-size: .85rem; color: var(--muted); }
.stat-value { font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.stat-note { font-size: .8rem; color: var(--muted); }
.stat-net { border-color: var(--ink); background: var(--ink); color: #fff; }
.stat-net .stat-label { color: var(--ink-text); }
.stat-net.is-negative .stat-value { color: #ffb4ab; }

.mini-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin: 0 0 1rem; }
.mini-figures dt { font-size: .8rem; color: var(--muted); }
.mini-figures dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }

.summary-strip {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 1.25rem; overflow: hidden;
}
.summary-strip > div { padding: .8rem 1.1rem; display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.summary-strip > div:last-child { border-right: 0; }
.summary-strip span { font-size: .8rem; color: var(--muted); }
.summary-strip strong { font-variant-numeric: tabular-nums; font-size: 1.05rem; overflow-wrap: anywhere; }

.period-card { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; padding: 1rem 1.25rem; }
.period-note { flex-basis: 100%; margin: 0; font-size: .85rem; }
.segmented { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; }
.segment { padding: .4rem .9rem; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: .9rem; }
button.segment { border: none; background: transparent; font-family: inherit; cursor: pointer; }
.segment:hover { text-decoration: none; color: var(--text); }
.segment.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.inline-field { display: flex; flex-direction: column; gap: .15rem; font-size: .8rem; color: var(--muted); }

/* ---------------------------------------------------------------- Buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .55rem 1rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .92rem;
    cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
    transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: progress; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-50); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9a2d22; }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-50); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn {
    display: inline-grid; place-items: center; width: 36px; height: 36px;
    border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-50); color: var(--danger); }

/* ------------------------------------------------------------------ Forms */

.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field label { font-weight: 600; font-size: .88rem; }
.input {
    width: 100%; padding: .55rem .7rem; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    min-height: 40px;
}
.input:hover { border-color: #9fb0c1; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-50); }
textarea.input { resize: vertical; min-height: 84px; }
.field-hint { margin: 0; font-size: .82rem; color: var(--muted); }
.field-error { margin: 0; font-size: .82rem; color: var(--danger); font-weight: 500; }
.field-hint.is-warning { color: var(--warning); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .9rem; }
.filters .field { flex: 0 1 170px; }
.filters .field-grow { flex: 1 1 240px; }
.filter-actions { display: flex; gap: .5rem; }

/* ----------------------------------------------------------------- Tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data th, .data td { padding: .75rem 1rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.data thead th {
    font-size: .8rem; font-weight: 600; color: var(--muted); background: #f8fafc; white-space: nowrap;
    border-bottom: 1px solid var(--border-strong);
}
.data tbody tr:hover { background: #fafcfe; }
.data tbody tr:last-child td { border-bottom: 0; }
.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data tfoot th, .data tfoot td { font-weight: 650; background: #f8fafc; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.data tfoot th { text-align: right; }
.actions-col { text-align: right; }
.row-buttons { display: flex; gap: .25rem; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.cell-sub { display: block; color: var(--muted); font-size: .82rem; font-weight: 400; }
.cell-wrap { max-width: 360px; overflow-wrap: anywhere; }
.table-foot { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-top: 1px solid var(--border); }

.pagination { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.page-link, .page-gap { padding: .3rem .65rem; border-radius: 6px; font-size: .88rem; }
.page-link { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.page-link:hover { background: var(--primary-50); text-decoration: none; }
.page-link.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.is-disabled { color: var(--muted); background: var(--bg); }

/* ----------------------------------------------------------------- Badges */

.badge { display: inline-block; padding: .18rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-draft     { background: #eceff3; color: #4a5866; }
.badge-submitted { background: var(--warning-50); color: var(--warning); }
.badge-reviewed  { background: var(--success-50); color: var(--success); }
.badge-deleted   { background: #fbe4e4; color: #a3282f; }
.badge-product   { background: #e6f0fb; color: #1c5aa8; }
.badge-service   { background: #eef0fb; color: #4842a8; }
.low-stock       { color: var(--danger, #b3261e); font-weight: 600; }
.is-deleted-row  { opacity: .6; }
.is-deleted-row td strong { text-decoration: line-through; }
.assignment-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.assignment-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem .75rem; background: #f7f8fa; border-radius: .5rem; }
.assign-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.assign-form .input { max-width: 320px; }

/* ----------------------------------------------------------------- Alerts */

.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.alert ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.alert-success { background: var(--success-50); border-color: #b7dfc8; color: #14583a; }
.alert-error   { background: var(--danger-50);  border-color: #f2c1bc; color: #8c2a20; }
.alert-warning { background: var(--warning-50); border-color: #f0d7a0; color: #6d4507; }
.alert-info    { background: var(--primary-50); border-color: #bcd8f3; color: #0a4a8d; }
.alert a { font-weight: 600; text-decoration: underline; }

.toast-region { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: grid; gap: .5rem; max-width: min(92vw, 380px); }
.toast {
    background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-size: .92rem; border-left: 4px solid var(--accent);
}
.toast-error { border-left-color: #ff8a7d; }
.toast-success { border-left-color: #58c98a; }

/* ------------------------------------------------------- Empty / dialogs */

.empty, .empty-inline { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty-inline { padding: 1rem; }
.empty p, .empty-inline p { margin-bottom: .75rem; }
.empty-inline p { margin: 0; }

.dialog {
    border: 0; border-radius: var(--radius); padding: 0; width: min(92vw, 520px); max-height: 90vh;
    box-shadow: 0 20px 60px rgba(13, 43, 69, .35); color: var(--text); background: var(--surface);
}
.dialog::backdrop { background: rgba(13, 43, 69, .55); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 1.25rem; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 var(--radius) var(--radius); }
.dialog-message { margin: 0; color: var(--text); }
.category-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.category-list li, .category-add { display: flex; gap: .5rem; align-items: center; }

/* ------------------------------------------------------------- Auth pages */

.auth-page { background: var(--ink); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card {
    background: var(--surface); width: min(100%, 420px); padding: 2rem; border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
.auth-card h1 { margin: .5rem 0 .4rem; }
.auth-card .brand-text strong { color: var(--text); }
.auth-card .brand-text small { color: var(--muted); }
.brand-auth { padding: 0 0 .75rem; }
.error-code { font-size: 3rem; font-weight: 700; margin: 0; color: var(--primary); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- Responsive */

@media (max-width: 1000px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary-strip > div:nth-child(2) { border-right: 0; }
    .summary-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}

@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 50;
        transform: translateX(-102%); transition: transform .2s ease; overflow-y: auto;
    }
    .sidebar.is-open { transform: none; }
    .topbar {
        display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem;
        background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
    }
    .topbar-title { font-weight: 650; }
    .content { padding: 1.25rem 1rem 3rem; }
    h1 { font-size: 1.4rem; }
    .two-col { grid-template-columns: minmax(0, 1fr); }
    .filters .field { flex: 1 1 140px; }
}

@media (max-width: 520px) {
    .stat-grid { grid-template-columns: minmax(0, 1fr); }
    .mini-figures { grid-template-columns: minmax(0, 1fr); }
    .segmented { width: 100%; }
    .segment { flex: 1; text-align: center; padding-inline: .4rem; }
    .btn { white-space: normal; }
    .page-actions .btn { flex: 1 1 auto; }
    .auth-card { padding: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
