/* =========================================================================
   MISYS: Mang Inasal store dashboard (PWA)
   Shell and conventions follow LaDolce One (one.ladolcecorp.com):
   max-width 480px phone shell, sticky app-bar, fixed 5-tab bottom nav,
   inline stroke icons, token-based colours with a dark-mode override.
   ========================================================================= */

:root {
    /* Brand: from the logo */
    --c-brand:        #0e6835;   /* green border */
    --c-brand-strong: #0a5229;
    --c-brand-wash:   #eaf4ee;
    --c-yellow:       #faef19;
    --c-red:          #e31f26;

    /* Ink */
    --c-ink:        #14201a;
    --c-ink-soft:   #26332c;
    --c-muted:      #5d6b63;
    --c-muted-soft: #8a968f;

    /* Surfaces */
    --c-page:        #f3f5f2;
    --c-surface:     #ffffff;
    --c-surface-sunk:#eef1ed;
    --c-border:      #e1e6e0;
    --c-shell-top:   #fffde6;    /* faint yellow wash behind the app-bar */

    /* Data: one series colour + target ink, per the house chart rules */
    --c-series:      #2a78d6;
    --c-series-on:   #184f95;
    --c-target:      #14201a;
    --c-track:       #edf0ec;

    /* Status: always paired with a label, never colour alone */
    --c-good:        #0b6b2e;
    --c-good-wash:   #e6f4ea;
    --c-warn:        #7a4f00;
    --c-warn-wash:   #fff4d6;
    --c-bad:         #b3261e;
    --c-bad-wash:    #fdecea;

    --r-sm: 12px; --r-md: 16px; --r-lg: 22px; --r-pill: 999px;
    --sh-1: 0 4px 12px rgba(15, 30, 20, .06);
    --sh-2: 0 10px 24px rgba(15, 30, 20, .08);
    --motion: .12s ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --c-brand-wash:   #13291c;
        --c-ink:        #eef2ee;
        --c-ink-soft:   #d7ddd8;
        --c-muted:      #a3ada6;
        --c-muted-soft: #78837b;
        --c-page:        #0d110e;
        --c-surface:     #161b17;
        --c-surface-sunk:#1e2520;
        --c-border:      #2a332c;
        --c-shell-top:   #141a15;
        --c-series:      #3987e5;
        --c-series-on:   #86b6ef;
        --c-target:      #eef2ee;
        --c-track:       #232a25;
        --c-good:        #6fd38f;  --c-good-wash: #12301d;
        --c-warn:        #f5c451;  --c-warn-wash: #33290f;
        --c-bad:         #ff8a80;  --c-bad-wash:  #3a1715;
        --sh-1: 0 4px 12px rgba(0,0,0,.4);
        --sh-2: 0 10px 24px rgba(0,0,0,.48);
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--c-page);
    color: var(--c-ink-soft);
    font-size: 15px;
    line-height: 1.45;
}
body { overscroll-behavior: none; }
a { color: var(--c-brand); }

/* ------------------------------------------------------------------ shell */

.app-shell {
    min-height: 100vh;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: linear-gradient(180deg, var(--c-shell-top) 0%, var(--c-page) 260px);
    position: relative;
    box-shadow: 0 0 30px rgba(0,0,0,.08);
}

.app-content { padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); }

/* ------------------------------------------------------------------ app-bar */

.app-bar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--c-shell-top) 88%, transparent);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--c-border);
}
.app-bar-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.app-bar-logo {
    width: 62px; height: 35px; flex: none;
    border-radius: 8px; overflow: hidden;
    box-shadow: 0 4px 10px rgba(14, 104, 53, .25);
}
.app-bar-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-bar-greeting { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.app-bar-hello { font-size: 11px; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: .04em; }
.app-bar-greeting strong { font-size: 16px; font-weight: 800; color: var(--c-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.app-bar-btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--r-pill);
    background: var(--c-surface); border: 1px solid var(--c-border);
    color: var(--c-brand); text-decoration: none; box-shadow: var(--sh-1);
}
.app-bar-dot {
    position: absolute; top: 7px; right: 8px; width: 9px; height: 9px; border-radius: 50%;
    background: var(--c-red); border: 2px solid var(--c-surface);
}

/* ------------------------------------------------------------------ bottom nav */

.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; margin: 0 auto;
    width: 100%; max-width: 480px;
    height: calc(72px + env(safe-area-inset-bottom));
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--c-border);
    display: grid; grid-template-columns: repeat(5, 1fr);
    box-shadow: 0 -8px 24px rgba(15, 30, 20, .08);
    z-index: 50;
}
.bottom-nav::before {   /* blur on a pseudo-element: see LaDolce One note on iOS fixed bars */
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: color-mix(in srgb, var(--c-surface) 96%, transparent);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.bottom-nav a {
    position: relative; text-decoration: none; color: var(--c-muted);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border-radius: 16px; min-height: 44px;
}
.bottom-nav a span { font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.bottom-nav a.active { color: var(--c-brand); background: var(--c-brand-wash); }
.bottom-nav-dot {
    position: absolute; top: 6px; left: calc(50% + 8px); width: 8px; height: 8px;
    border-radius: 50%; background: var(--c-red);
}

/* ------------------------------------------------------------------ page parts */

.page-title { margin: 6px 2px 14px; }
.page-title h1 { margin: 0; font-size: 22px; font-weight: 800; color: var(--c-ink); letter-spacing: -.3px; }
.page-title p { margin: 2px 0 0; color: var(--c-muted); font-size: 13px; }

.section-label {
    margin: 20px 2px 8px; font-size: 12px; font-weight: 800; color: var(--c-muted);
    text-transform: uppercase; letter-spacing: .05em;
    display: flex; justify-content: space-between; align-items: baseline;
}
.section-label a { text-transform: none; letter-spacing: 0; font-weight: 700; text-decoration: none; }

.card {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--sh-1);
}
.card + .card { margin-top: 10px; }
.card h2 { margin: 0 0 2px; font-size: 15px; font-weight: 800; color: var(--c-ink); }
.card .sub { font-size: 12.5px; color: var(--c-muted); }
.muted { color: var(--c-muted); }
.small { font-size: 12px; }

/* Day switcher */
.day-switch {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-pill);
    padding: 4px; box-shadow: var(--sh-1); margin-bottom: 12px;
}
.day-switch a, .day-switch span.disabled {
    width: 40px; height: 40px; border-radius: var(--r-pill); display: flex; align-items: center; justify-content: center;
    color: var(--c-brand); text-decoration: none;
}
.day-switch span.disabled { color: var(--c-muted-soft); }
.day-switch a:active { background: var(--c-brand-wash); }
.day-switch .day { text-align: center; line-height: 1.15; }
.day-switch .day small { display: block; font-size: 11px; color: var(--c-muted); font-weight: 600; }
.day-switch .day strong { font-size: 15px; color: var(--c-ink); }

/* Hero sales card */
.hero {
    background: linear-gradient(135deg, var(--c-brand), var(--c-brand-strong));
    color: #fff; border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--sh-2);
}
.hero-label { font-size: 12px; font-weight: 700; opacity: .85; text-transform: uppercase; letter-spacing: .05em; }
.hero-value { font-size: 34px; font-weight: 800; letter-spacing: -.8px; line-height: 1.1; margin-top: 2px; }
.hero-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 13px; }
.hero-pill {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill);
    font-weight: 800; font-size: 12.5px; background: rgba(255,255,255,.16);
}
.hero-pill.up { background: var(--c-yellow); color: #3a3000; }
.hero-bar { height: 8px; background: rgba(255,255,255,.22); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.hero-bar i { display: block; height: 100%; background: var(--c-yellow); border-radius: 4px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.kpi { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: 12px 14px; box-shadow: var(--sh-1); }
.kpi-label { font-size: 12px; color: var(--c-muted); font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--c-ink); letter-spacing: -.4px; margin-top: 1px; }
.kpi-delta { font-size: 12px; font-weight: 700; margin-top: 2px; }
.delta-good { color: var(--c-good); }
.delta-bad { color: var(--c-bad); }

/* Week bars (actual vs target) */
.wk { display: flex; align-items: flex-end; gap: 8px; height: 150px; border-bottom: 1px solid var(--c-border); margin-top: 12px; padding: 0 2px; }
.wk a { flex: 1 1 0; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; text-decoration: none; }
.wk .bar { width: 70%; max-width: 34px; background: var(--c-series); border-radius: 4px 4px 0 0; }
.wk a.on .bar { background: var(--c-series-on); }
.wk .tgt { position: absolute; left: 4%; right: 4%; border-top: 2px dashed var(--c-target); }
.wk .val { font-size: 10px; font-weight: 700; color: var(--c-ink); margin-bottom: 3px; }
.wk-days { display: flex; gap: 8px; padding: 5px 2px 0; }
.wk-days span { flex: 1 1 0; text-align: center; font-size: 11px; color: var(--c-muted); }
.wk-days span.on { color: var(--c-ink); font-weight: 800; }
.wk-days b { display: block; font-size: 10px; font-weight: 700; color: var(--c-ink-soft); margin-top: 1px; letter-spacing: -.2px; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--c-muted); margin-top: 8px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; background: var(--c-series); vertical-align: -1px; margin-right: 5px; }
.legend i.dash { height: 0; width: 14px; border-top: 2px dashed var(--c-target); background: none; border-radius: 0; vertical-align: 3px; }

/* Horizontal bar rows */
.hbars { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.hbar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.hbar-top .name { font-weight: 600; color: var(--c-ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-top .v { font-weight: 800; color: var(--c-ink); white-space: nowrap; }
.hbar-track { position: relative; height: 10px; background: var(--c-track); border-radius: 4px; margin-top: 4px; }
.hbar-track i { display: block; height: 100%; background: var(--c-series); border-radius: 4px; }
.hbar-track i.loss { background: #eb6834; }
.hbar-track b { position: absolute; top: -4px; bottom: -4px; border-left: 2px solid var(--c-target); }

/* Heatmap */
.heat { overflow-x: auto; margin-top: 10px; }
.heat table { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 400px; }
.heat th { font-size: 10px; font-weight: 600; color: var(--c-muted); }
.heat td { height: 30px; border-radius: 4px; text-align: center; font-size: 10px; font-weight: 600; }
.heat td.lbl { text-align: left; font-size: 11px; font-weight: 700; color: var(--c-ink); background: none; width: 34px; }
.ramp { display: flex; align-items: center; gap: 3px; margin-top: 8px; font-size: 11px; color: var(--c-muted); }
.ramp span { width: 22px; height: 9px; border-radius: 2px; }

/* Lists (alerts, news, checks) */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
    padding: 12px 14px; box-shadow: var(--sh-1); text-decoration: none; color: inherit;
}
.item-ico { flex: none; width: 36px; height: 36px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.item-ico.bad { background: var(--c-bad-wash); color: var(--c-bad); }
.item-ico.warn { background: var(--c-warn-wash); color: var(--c-warn); }
.item-ico.good { background: var(--c-good-wash); color: var(--c-good); }
.item-ico.info { background: var(--c-brand-wash); color: var(--c-brand); }
.item-body { min-width: 0; flex: 1; }
.item-title { font-weight: 700; color: var(--c-ink); font-size: 14px; }
.item-text { font-size: 13px; color: var(--c-muted); margin-top: 1px; }
.item-meta { font-size: 11.5px; color: var(--c-muted-soft); margin-top: 4px; }

.tag {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-pill);
    font-size: 11px; font-weight: 800; white-space: nowrap;
}
.tag.ok { color: var(--c-good); background: var(--c-good-wash); }
.tag.warn { color: var(--c-warn); background: var(--c-warn-wash); }
.tag.fail { color: var(--c-bad); background: var(--c-bad-wash); }
.tag.missing { color: var(--c-muted); background: var(--c-surface-sunk); }

.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 10px; }
.chip {
    flex: none; padding: 8px 14px; min-height: 36px; border-radius: var(--r-pill); font-size: 13px; font-weight: 700;
    background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-ink-soft); text-decoration: none;
}
.chip.on { background: var(--c-brand); border-color: var(--c-brand); color: #fff; }

/* Apps grid (home quick tiles + Apps tab) */
.apps-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tile {
    display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 4px 10px;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
    text-decoration: none; color: var(--c-ink-soft); text-align: center; box-shadow: var(--sh-1);
    transition: transform var(--motion);
}
.tile:active { transform: scale(.95); }
.tile-icon {
    width: 44px; height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
    color: #fff; background: linear-gradient(135deg, #22a35a, var(--c-brand));
    box-shadow: 0 4px 10px rgba(15, 30, 20, .14), inset 0 1px 0 rgba(255,255,255,.25);
}
.tile-icon svg { stroke-width: 2.2; }
.tile-icon.t-blue   { background: linear-gradient(135deg, #60a5fa, #1d4ed8); }
.tile-icon.t-orange { background: linear-gradient(135deg, #fb923c, #c2410c); }
.tile-icon.t-red    { background: linear-gradient(135deg, #f87171, #b91c1c); }
.tile-icon.t-violet { background: linear-gradient(135deg, #a78bfa, #6d28d9); }
.tile-icon.t-teal   { background: linear-gradient(135deg, #2dd4bf, #0f766e); }
.tile-icon.t-amber  { background: linear-gradient(135deg, #fbbf24, #b45309); }
.tile-icon.t-gray   { background: linear-gradient(135deg, #9ca3af, #4b5563); }
.tile-name { font-size: 11.5px; font-weight: 700; line-height: 1.2; }
.tile.soon { opacity: .55; }
@media (max-width: 340px) { .apps-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; color: var(--c-muted); font-weight: 600; padding: 6px 4px; }
.tbl td { padding: 8px 4px; border-top: 1px solid var(--c-border); vertical-align: top; }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; margin-top: 8px; }

/* Note / quote */
.note { margin-top: 8px; padding: 10px 12px; background: var(--c-surface-sunk); border-radius: var(--r-sm); font-size: 13px; color: var(--c-ink-soft); }

/* Profile */
.profile-head { display: flex; align-items: center; gap: 14px; }
.avatar {
    width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--c-brand-wash); color: var(--c-brand); font-weight: 800; font-size: 20px;
}
.rows { display: flex; flex-direction: column; }
.rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--c-border); font-size: 14px; }
.rows > div:first-child { border-top: 0; }
.rows span:first-child { color: var(--c-muted); }
.rows span:last-child { color: var(--c-ink); font-weight: 600; text-align: right; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 18px; border-radius: var(--r-pill); border: 0; cursor: pointer;
    background: var(--c-brand); color: #fff; font-weight: 800; font-size: 14px; text-decoration: none; font-family: inherit;
}
.btn.ghost { background: var(--c-surface); color: var(--c-brand); border: 1px solid var(--c-border); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

.empty { text-align: center; padding: 28px 16px; color: var(--c-muted); }
.empty svg { color: var(--c-muted-soft); }

.banner {
    display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm);
    background: var(--c-warn-wash); color: var(--c-warn); font-size: 12.5px; margin-bottom: 12px;
}

/* Login */
.login { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 12vh; }
.login-logo { border-radius: 12px; box-shadow: var(--sh-2); }
.login h1 { margin: 18px 0 2px; font-size: 26px; color: var(--c-ink); letter-spacing: -.4px; }
.login-card { width: 100%; max-width: 360px; margin-top: 22px; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 13px; font-weight: 700; color: var(--c-ink-soft); margin-top: 6px; }
.login-card input {
    font: inherit; font-size: 16px; min-height: 46px; padding: 10px 14px; border-radius: var(--r-sm);
    border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-ink);
}
.login-card input:focus { outline: 2px solid var(--c-brand); outline-offset: 1px; }
.login-card .btn { margin-top: 12px; }

/* ------------------------------------------------------------------ install prompt */

.btn-sm { min-height: 38px; padding: 7px 14px; font-size: 13px; gap: 6px; }
.btn-link {
    min-height: 38px; padding: 7px 8px; border: 0; background: none; cursor: pointer;
    font: inherit; font-size: 13px; font-weight: 700; color: var(--c-muted);
}

.install-sheet {
    position: fixed; left: 0; right: 0; margin: 0 auto; z-index: 60;
    width: calc(100% - 24px); max-width: 456px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px; border-radius: var(--r-lg);
    background: var(--c-surface); border: 1px solid var(--c-border); box-shadow: 0 14px 40px rgba(15, 30, 20, .22);
    animation: sheet-up .35s cubic-bezier(.2, .8, .2, 1);
}
.install-sheet.above-nav { bottom: calc(84px + env(safe-area-inset-bottom)); }
.install-sheet[hidden] { display: none; }
.install-sheet-icon { border-radius: 12px; flex: none; }
.install-sheet-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.install-sheet-body strong { color: var(--c-ink); font-size: 15px; }
.install-sheet-body > span { color: var(--c-muted); font-size: 13px; }
.install-sheet-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.install-sheet-actions [hidden] { display: none; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .install-sheet { animation: none; } }

.howto {
    width: min(440px, calc(100% - 24px)); max-height: calc(100vh - 40px); overflow-y: auto;
    border: 0; border-radius: var(--r-lg); padding: 18px 18px 16px;
    background: var(--c-surface); color: var(--c-ink-soft); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.howto::backdrop { background: rgba(10, 20, 14, .55); }
.howto-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.howto-head h2 { margin: 0; font-size: 19px; color: var(--c-ink); }
.howto-close { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--c-surface-sunk); color: var(--c-ink); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.howto-lead { margin: 4px 0 12px; font-size: 14px; }
.howto section[hidden], .howto [hidden] { display: none; }
.steps { list-style: none; counter-reset: step; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li {
    counter-increment: step; position: relative;
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 12px 12px 14px; border-radius: var(--r-sm); background: var(--c-surface-sunk); font-size: 14px; line-height: 1.4;
}
.steps li::before {
    content: counter(step); position: absolute; top: -6px; left: -6px;
    width: 22px; height: 22px; border-radius: 50%; background: var(--c-brand); color: #fff;
    font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.step-ico {
    flex: none; width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    background: var(--c-surface); color: var(--c-series); border: 1px solid var(--c-border);
}
.steps b { color: var(--c-ink); }
.howto .btn + .btn, .howto-done { margin-top: 8px; }
