:root {
    color-scheme: light;
    --bg:        #faf9f7;
    --panel:     #ffffff;
    --panel-2:   #f5f4f0;
    --ink:       #14140f;
    --ink-2:     #43433c;
    --muted:     #6f6e66;
    --line:      #e8e6e1;
    --line-2:    #f0eeea;
    --violet:    #a78bfa;
    --magenta:   #d94f9a;
    --coral:     #f0684f;
    --grad: linear-gradient(96deg, var(--violet) 0%, var(--magenta) 52%, var(--coral) 100%);
    --accent:    #7c5cf0;
    --accent-dk: #6647d8;
    --accent-bg: #f3effe;
    --good:      #0f7b4f;
    --good-bg:   #e8f5ee;
    --bad:       #c0392f;
    --bad-bg:    #fbecea;
    --warn:      #9a5b00;
    --warn-bg:   #fdf3e1;
    /* chart slots: validated reference palette, slots 1 and 2 */
    --series-1:  #2a78d6;
    --series-2:  #eb6834;
    --grid:      #ecebe7;
    --sh-1: 0 1px 2px rgba(20, 20, 15, .04);
    --sh-2: 0 1px 2px rgba(20, 20, 15, .04), 0 8px 24px rgba(20, 20, 15, .05);
    --r-sm: 8px;
    --r:    12px;
    --r-lg: 16px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #121211; --panel: #1a1a19; --panel-2: #222220;
        --ink: #f0efec; --ink-2: #c9c8bf; --muted: #9a998f;
        --line: #2e2e2b; --line-2: #262624;
        --accent: #9d85ff; --accent-dk: #b3a0ff; --accent-bg: #26213d;
        --good: #4cc38a; --good-bg: #16291f; --bad: #ef7d73; --bad-bg: #331b19;
        --warn: #e0a64a; --warn-bg: #2e2412;
        --series-1: #3987e5; --series-2: #d95926; --grid: #2a2a28;
        --sh-1: none; --sh-2: none;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121211; --panel: #1a1a19; --panel-2: #222220;
    --ink: #f0efec; --ink-2: #c9c8bf; --muted: #9a998f;
    --line: #2e2e2b; --line-2: #262624;
    --accent: #9d85ff; --accent-dk: #b3a0ff; --accent-bg: #26213d;
    --good: #4cc38a; --good-bg: #16291f; --bad: #ef7d73; --bad-bg: #331b19;
    --warn: #e0a64a; --warn-bg: #2e2412;
    --series-1: #3987e5; --series-2: #d95926; --grid: #2a2a28;
    --sh-1: none; --sh-2: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 15px/1.55 "Poppins", "Outfit", "Figtree", "Avenir Next", -apple-system,
          BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -.025em; line-height: 1.2; margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* --- top bar --------------------------------------------------------- */
.top {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
}
.top-in {
    max-width: 1120px; margin: 0 auto; padding: 0 24px;
    display: flex; align-items: center; gap: 22px; height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.03em; }
.brand:hover { text-decoration: none; }
.brand .sub { color: var(--muted); font-weight: 500; }
.mark { width: 26px; height: 26px; border-radius: 9px; background: var(--grad); flex: none;
        box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.brand-name { color: var(--ink); }
.tabs { display: flex; gap: 4px; height: 100%; }
.tab {
    display: flex; align-items: center; padding: 0 12px; height: 100%;
    color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--muted); }
.link-btn { background: none; border: 0; padding: 4px 2px; cursor: pointer; color: var(--muted); }
.link-btn:hover { color: var(--ink); }

main { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }

/* --- common ---------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
             flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 28px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line);
       border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer;
              color: var(--muted); font-size: 13.5px; font-weight: 550; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--sh-1); }
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
        padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.chip.on { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-dk); }
.btn { border: 0; border-radius: 9px; padding: 9px 16px; cursor: pointer; font-weight: 600;
       background: var(--accent); color: #fff; font-size: 14px; }
.btn:hover { background: var(--accent-dk); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: none; color: var(--ink-2); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.muted { color: var(--muted); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
       padding: 2px 9px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); white-space: nowrap; }
.tag.product { background: var(--accent-bg); color: var(--accent-dk); }
.tag.internal { background: var(--good-bg); color: var(--good); }
.tag.infra { background: var(--warn-bg); color: var(--warn); }
.tag.draft { background: var(--warn-bg); color: var(--warn); }
.impact { display: inline-flex; gap: 3px; vertical-align: middle; }
.impact i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); display: block; }
.impact i.on { background: var(--accent); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink);
         color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; }

/* --- weeks list ------------------------------------------------------ */
.weeks { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.week-card { display: flex; flex-direction: column; color: inherit; overflow: hidden; transition: border-color .15s; }
.week-card:hover { text-decoration: none; border-color: var(--accent); }
.week-card .cover { aspect-ratio: 16 / 7; background: var(--grad); position: relative; overflow: hidden; }
.week-card .cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.week-card .cover .wk { position: absolute; left: 16px; bottom: 12px; color: #fff; font-weight: 650;
                        font-size: 13px; text-shadow: 0 1px 6px rgba(0,0,0,.35); }
.week-card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.week-card h3 { font-size: 17px; }
.week-card ol { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.week-card ol li { margin: 2px 0; }
.week-card .meta { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }

/* --- week detail ----------------------------------------------------- */
.crumbs { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; font-size: 14px; }
.crumbs .nav { display: flex; gap: 14px; }
.week-head { margin-bottom: 26px; }
.week-head .when { color: var(--muted); font-weight: 600; font-size: 14px; }
.week-head h1 { font-size: 32px; margin: 4px 0 10px; }
.week-head p { color: var(--ink-2); max-width: 760px; margin: 0; font-size: 16px; }
.draft-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
             padding: 14px 18px; margin-bottom: 24px; border-radius: var(--r); background: var(--warn-bg);
             border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); color: var(--ink); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
                 font-weight: 650; margin: 0 0 12px; }
.top3 { display: grid; gap: 18px; margin-bottom: 30px; }
.feature { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); overflow: hidden; }
.feature.noimg { grid-template-columns: 1fr; }
.feature .shot { background: var(--panel-2); border-right: 1px solid var(--line); min-height: 220px; }
.feature .shot img { width: 100%; height: 100%; object-fit: cover; object-position: top left; display: block; cursor: zoom-in; }
.feature .txt { padding: 22px 24px; display: flex; flex-direction: column; gap: 10px; }
.feature .num { font-size: 13px; font-weight: 700; color: var(--accent); }
.feature h2 { font-size: 21px; }
.feature p { margin: 0; color: var(--ink-2); }
.row-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.row-meta a { color: var(--muted); }
.more-btn { width: 100%; padding: 12px; border-radius: var(--r); border: 1px dashed var(--line);
            background: none; cursor: pointer; color: var(--ink-2); font-weight: 600; }
.more-btn:hover { background: var(--panel); }
.rest { display: grid; gap: 10px; margin-top: 12px; }
.rest-item { padding: 14px 18px; display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; }
.rest-item h3 { font-size: 15.5px; }
.rest-item p { margin: 0; color: var(--ink-2); font-size: 14px; grid-column: 1 / -1; }
.rest-item .row-meta { grid-column: 1 / -1; }
.rest-item img { grid-column: 1 / -1; max-width: 100%; border-radius: var(--r-sm); border: 1px solid var(--line); margin-top: 6px; cursor: zoom-in; }
.edit-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.edit-form { display: grid; gap: 10px; padding: 18px; }
.edit-form input, .edit-form textarea, .edit-form select, .form input, .form select {
    font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--panel); color: var(--ink); width: 100%; }
.edit-form textarea { min-height: 110px; resize: vertical; }
.edit-form .line { display: flex; gap: 10px; }

/* --- highlights ------------------------------------------------------ */
.hl-group { margin-bottom: 34px; }
.hl-group h2 { font-size: 22px; margin-bottom: 4px; }
.hl-group .muted { font-size: 14px; margin-bottom: 14px; }
.hl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 14px; }
.hl-item { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; color: inherit; }
.hl-item:hover { text-decoration: none; border-color: var(--accent); }
.hl-item h3 { font-size: 16px; }
.hl-item p { margin: 0; color: var(--ink-2); font-size: 14px; }
.hl-item img { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; object-position: top; border-radius: var(--r-sm); }

/* --- metrics --------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi.hero { grid-column: span 2; grid-row: span 2; justify-content: space-between; padding: 22px 24px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 550; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.03em; line-height: 1.15; }
.kpi.hero .value { font-size: 56px; }
.kpi .delta { font-size: 13px; font-weight: 600; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.flat { color: var(--muted); }
.kpi .spark { margin-top: 10px; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart { padding: 18px 18px 10px; position: relative; }
.chart h3 { font-size: 15px; }
.chart .sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 8px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.chart .legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart .legend i { width: 14px; height: 3px; border-radius: 2px; display: block; }
.legend i.s1, .sw.s1 { background: var(--series-1); }
.legend i.s2, .sw.s2 { background: var(--series-2); }
svg .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg .gridline { stroke: var(--grid); stroke-width: 1; }
svg .line1 { stroke: var(--series-1); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
svg .line2 { stroke: var(--series-2); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
svg .area1 { fill: var(--series-1); opacity: .08; }
svg .bar1 { fill: var(--series-1); }
svg .bar1.partial, svg .dot.partial { opacity: .4; }
svg .line1.partial, svg .line2.partial { stroke-dasharray: 3 4; }
svg .dot1 { fill: var(--series-1); stroke: var(--panel); stroke-width: 2; }
svg .dot2 { fill: var(--series-2); stroke: var(--panel); stroke-width: 2; }
svg .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
svg .hit { fill: transparent; cursor: crosshair; }
svg .spark-line { stroke: var(--muted); stroke-width: 1.5; fill: none; opacity: .7; }
svg .spark-dot { fill: var(--series-1); }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line);
       box-shadow: var(--sh-2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; z-index: 5; white-space: nowrap; }
.tip b { display: block; margin-bottom: 2px; }
.tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.note { font-size: 13px; color: var(--muted); margin-top: 22px; line-height: 1.6; }
.note summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }
.note ul { padding-left: 18px; }
.data-table-wrap { overflow-x: auto; margin-top: 18px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--muted); font-weight: 600; }
.banner { padding: 12px 16px; border-radius: var(--r); background: var(--warn-bg); color: var(--ink); margin-bottom: 18px; font-size: 14px; }

/* --- access ---------------------------------------------------------- */
.form { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px; margin-bottom: 18px; align-items: center; }
.form input { width: auto; flex: 1 1 200px; }
.form select { width: auto; }
.users td, .users th { text-align: left !important; }

/* --- lightbox -------------------------------------------------------- */
.lightbox { position: fixed; inset: 0; background: rgba(10,10,8,.82); display: flex; align-items: center;
            justify-content: center; z-index: 60; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* --- login ----------------------------------------------------------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 30px 28px; background: var(--panel);
              border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-2); }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 22px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-hint { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.login-card input { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line);
                    border-radius: 9px; background: var(--panel); color: var(--ink); margin-bottom: 14px; }
.login-code { letter-spacing: .4em; font-size: 20px !important; text-align: center; }
.login-card .btn { width: 100%; margin-top: 4px; }
.login-card .btn.ghost { margin-top: 8px; }
.login-error { color: var(--bad); font-size: 14px; margin: 14px 0 0; }

@media (max-width: 860px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .charts { grid-template-columns: 1fr; }
    .feature { grid-template-columns: 1fr; }
    .feature .shot { border-right: 0; border-bottom: 1px solid var(--line); min-height: 0; aspect-ratio: 16 / 9; }
}
@media (max-width: 600px) {
    .top-in { padding: 0 16px; gap: 12px; }
    .brand .sub, .top-right .who { display: none; }
    main { padding: 22px 16px 60px; }
    .weeks, .hl-list { grid-template-columns: 1fr; }
    .kpi.hero .value { font-size: 40px; }
    .week-head h1 { font-size: 25px; }
    .tab { padding: 0 8px; font-size: 14px; }
}

/* --- platform extras ------------------------------------------------- */
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; }
.users select { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); }
.login-card .btn { display: inline-block; text-align: center; }
.tokens-apps { margin-top: 28px; }
.login-card .btn.ghost { margin-top: 8px; width: 100%; }
.areas { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; max-width: 280px; }
.area-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; white-space: nowrap; }
.area-chip input { margin: 0; }
.users select.override { border-color: var(--accent); color: var(--accent-dk); }
