/* CandyShop — a 1950s soda-fountain counter.
   Mint walls, a navy back bar with a cherry-striped awning, white price tickets.
   One accent (cherry). Chart colours carry meaning everywhere:
   cherry = counts, mint green = pounds, butterscotch = stock, navy = deliveries. */

:root {
    --mint: #dcf1e7;
    --mint-line: #b9dfcd;
    --paper: #fffdf7;
    --navy: #1e2a4a;
    --navy-soft: #3a4769;
    --cherry: #c8213a;
    --cherry-dark: #9e1a2e;
    --money: #23806a;
    --butter: #e9a422;
    --pink: #f7c6d2;
    --ink: #1e2a4a;
    --ink-soft: #55607a;

    --display: "Cooper Black", "Cooper Std", "Bookman Old Style", "URW Bookman", "URW Bookman L", "Bookman", Georgia, serif;
    --body: "Futura", "Century Gothic", "Avenir Next", "URW Gothic", "URW Gothic L", "Trebuchet MS", sans-serif;

    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--mint);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--cherry-dark); }

:focus-visible { outline: 3px solid var(--cherry); outline-offset: 2px; border-radius: 4px; }

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

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.rail {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    background: var(--navy);
    color: #fff;
}

/* The awning: cherry and white stripes with a scalloped hem. */
.awning {
    height: 46px;
    background: repeating-linear-gradient(90deg, var(--cherry) 0 22px, var(--paper) 22px 44px);
    -webkit-mask: radial-gradient(circle 11px at 11px 35px, #000 98%, transparent) 0 0 / 22px 46px repeat-x,
                  linear-gradient(#000, #000) 0 0 / 100% 35px no-repeat;
            mask: radial-gradient(circle 11px at 11px 35px, #000 98%, transparent) 0 0 / 22px 46px repeat-x,
                  linear-gradient(#000, #000) 0 0 / 100% 35px no-repeat;
}

.brand { display: block; padding: var(--s4) var(--s5) var(--s5); color: #fff; text-decoration: none; }
.brand-name { display: block; font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1.1; letter-spacing: .01em; color: var(--pink); text-shadow: 2px 2px 0 var(--cherry); }
.brand-sub { display: block; margin-top: var(--s1); font-size: 14px; color: #c9cfe0; }

.nav-list { list-style: none; margin: 0; padding: 0 var(--s3); display: grid; gap: var(--s1); }

.nav-link {
    display: flex; align-items: center; gap: var(--s3);
    padding: 10px var(--s3);
    border-radius: 999px;
    color: #e6e9f2; text-decoration: none; font-size: 15px;
}
.nav-link:hover { background: var(--navy-soft); color: #fff; }
.nav-link.active { background: var(--paper); color: var(--navy); font-weight: 700; }
.nav-link.active .icon { color: var(--cherry); }
.nav-badge { margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--cherry); color: #fff; font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }

.rail-foot { margin-top: auto; padding: var(--s4) var(--s5) var(--s5); font-size: 13px; color: #c9cfe0; }
.live { display: inline-flex; align-items: center; gap: var(--s2); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #6fd3a8; box-shadow: 0 0 0 3px rgba(111, 211, 168, .25); }
.live-off .live-dot { background: var(--butter); box-shadow: 0 0 0 3px rgba(233, 164, 34, .25); }

.stage { padding: var(--s4) var(--s6) var(--s7); min-width: 0; }

.stage-bar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s4); font-size: 13px; color: var(--ink-soft); min-height: 24px; }
.updated { padding: 2px 10px; border-radius: 999px; transition: background-color .6s ease, color .6s ease; }
.updated-fresh { background: var(--paper); color: var(--money); }

/* ---------------------------------------------------------------- page heading */

.page-head { margin: var(--s3) 0 var(--s5); max-width: 70ch; }
.page-head h1 {
    margin: 0;
    font-family: var(--display); font-weight: 800;
    font-size: clamp(34px, 4vw, 48px); line-height: 1.05;
    color: var(--cherry);
    text-shadow: 3px 3px 0 var(--paper);
}
.lede { margin: var(--s2) 0 0; font-size: 17px; color: var(--ink-soft); }

.banner-error { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border-radius: 10px; background: #fde8eb; color: var(--cherry-dark); border: 2px solid var(--cherry); }

/* ---------------------------------------------------------------- tallies (price tickets) */

.tallies { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.tallies:empty { display: none; }

.tally {
    position: relative;
    display: flex; flex-direction: column; gap: 2px;
    padding: var(--s4) var(--s5);
    background: var(--paper);
    border: 2px solid var(--navy);
    border-radius: 6px;
    /* ticket notches at the sides */
    -webkit-mask: radial-gradient(circle 9px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                  radial-gradient(circle 9px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
            mask: radial-gradient(circle 9px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
                  radial-gradient(circle 9px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
}
.tally-value { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tally-label { font-size: 15px; }
.tally-hint { font-size: 13px; color: var(--ink-soft); }
.tally-cherry .tally-value { color: var(--cherry); }
.tally-mint .tally-value { color: var(--money); }
.tally-butter .tally-value { color: #a86f00; }
.tally-navy .tally-value { color: var(--navy); }

/* ---------------------------------------------------------------- panels */

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); align-items: start; }

.panel {
    min-width: 0;
    padding: var(--s5);
    background: var(--paper);
    border: 2px solid var(--navy);
    border-radius: 16px;
    box-shadow: 5px 5px 0 var(--navy);
}
.panel-wide { grid-column: 1 / -1; }
.tallies > .panel { grid-column: 1 / -1; }

.panel-head { margin-bottom: var(--s4); }
.panel-head h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1.2; color: var(--navy); }
.panel-note { margin: 2px 0 0; font-size: 14px; color: var(--ink-soft); }

.state { margin: 0; padding: var(--s5) 0; color: var(--ink-soft); }
.state-error { color: var(--cherry-dark); }
.state-loading { display: flex; align-items: center; gap: var(--s3); }

/* a spinning lollipop for loading */
.lollipop {
    width: 22px; height: 22px; border-radius: 50%;
    background: conic-gradient(var(--cherry) 0 25%, var(--paper) 0 50%, var(--cherry) 0 75%, var(--paper) 0);
    border: 2px solid var(--navy);
    animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.more { display: inline-block; margin-top: var(--s3); font-size: 14px; }

/* ---------------------------------------------------------------- bars (candy sticks) */

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.bar-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: var(--s3); font-size: 15px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 16px; border-radius: 999px; background: #eef3f0; overflow: hidden; }
.bar-fill {
    display: block; height: 100%; border-radius: 999px;
    background-color: var(--bar);
    background-image: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .28) 0 6px, transparent 6px 12px);
}
.bar-value { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.bars-cherry { --bar: var(--cherry); }
.bars-mint { --bar: var(--money); }
.bars-butter { --bar: var(--butter); }
.bars-navy { --bar: var(--navy); }

/* ---------------------------------------------------------------- columns (SVG) */

.columns { margin: 0; }
.columns svg { display: block; width: 100%; height: auto; overflow: visible; }
.columns .col { fill: var(--bar); }
.columns g:hover .col { fill: var(--bar-hover); }
.columns .gridline { stroke: #e3ebe7; stroke-width: 1; }
.columns .baseline { stroke: var(--navy); stroke-width: 1.5; }
.columns .tick, .columns .xlabel { font-family: var(--body); font-size: 12px; fill: var(--ink-soft); font-variant-numeric: tabular-nums; }
.columns .axis-title { font-family: var(--body); font-size: 12px; fill: var(--ink); font-weight: 700; }
.columns-cherry { --bar: var(--cherry); --bar-hover: var(--cherry-dark); }
.columns-mint { --bar: var(--money); --bar-hover: #17604f; }
.columns-navy { --bar: var(--navy); --bar-hover: #0f1730; }

/* ---------------------------------------------------------------- lists and tables */

.ticket-list { list-style: none; margin: 0; padding: 0; display: grid; }
.ticket { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s4); align-items: center; padding: 10px 0; border-bottom: 2px dotted var(--mint-line); }
.ticket:last-child { border-bottom: 0; }
.ticket-name { font-weight: 700; }
.ticket-figure { grid-column: 1 / -1; font-size: 14px; color: var(--ink); }
.ticket-figure small { display: block; color: var(--ink-soft); font-size: 13px; }
.ticket .stock-meter { grid-row: 1; grid-column: 2; width: 110px; }

.stock-meter { display: inline-block; width: 100%; max-width: 140px; height: 10px; border-radius: 999px; background: #f4ead2; overflow: hidden; vertical-align: middle; }
.stock-meter > span { display: block; height: 100%; background: var(--butter); border-radius: 999px; }
.stock-low > span, .ticket .stock-meter > span { background: var(--cherry); }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-weight: 700; font-size: 13px; color: var(--ink-soft); padding: 0 var(--s2) var(--s2); border-bottom: 2px solid var(--navy); }
.table td { padding: 10px var(--s2); border-bottom: 1px solid #e6eee9; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .sub { display: block; font-size: 13px; color: var(--ink-soft); }
.row-low td:first-child { box-shadow: inset 4px 0 0 var(--cherry); }
.row-muted td { color: var(--ink-soft); }

.chip { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--mint); border: 1px solid var(--mint-line); font-size: 13px; white-space: nowrap; }

/* ---------------------------------------------------------------- activity feed */

.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: grid; grid-template-columns: 36px 1fr auto; gap: var(--s3); align-items: start; padding: var(--s3) 0; border-bottom: 2px dotted var(--mint-line); }
.feed-item:last-child { border-bottom: 0; }
.feed-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--mint); color: var(--navy); }
.feed-created .feed-icon { background: #d8f0e4; color: var(--money); }
.feed-deleted .feed-icon { background: #fde8eb; color: var(--cherry); }
.feed-updated .feed-icon { background: #fdf0d3; color: #a86f00; }
.feed-headline { font-weight: 700; }
.feed-changes { margin: 2px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink-soft); }
.feed-time { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------------------------------------------------- toasts */

.toasts { position: fixed; right: var(--s5); bottom: var(--s5); z-index: 50; display: grid; gap: var(--s3); width: min(380px, calc(100vw - 32px)); }
.toast {
    display: grid; grid-template-columns: 20px 1fr auto; gap: var(--s3); align-items: start;
    padding: var(--s3) var(--s4);
    background: var(--paper); color: var(--ink);
    border: 2px solid var(--navy); border-left: 8px solid var(--navy);
    border-radius: 12px;
    box-shadow: 4px 4px 0 var(--navy);
    animation: toast-in .25s ease-out;
}
.toast-created { border-left-color: var(--money); }
.toast-updated { border-left-color: var(--butter); }
.toast-deleted { border-left-color: var(--cherry); }
.toast-body { display: grid; gap: 2px; min-width: 0; }
.toast-title { font-weight: 700; font-size: 14px; }
.toast-text { font-size: 14px; }
.toast-changes { font-size: 13px; color: var(--ink-soft); overflow-wrap: anywhere; }
.toast-close { border: 0; background: none; color: var(--ink-soft); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast-close:hover { color: var(--cherry); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- Blazor error bar */

#blazor-error-ui {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    padding: var(--s3) var(--s5);
    background: var(--butter); color: var(--navy);
}
#blazor-error-ui .reload { margin-left: var(--s3); color: var(--navy); font-weight: 700; }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 1100px) {
    .grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; }
    .rail { position: static; height: auto; }
    .awning { height: 34px; }
    .brand { padding: var(--s3) var(--s4); }
    .brand-name { font-size: 24px; }
    .brand-sub, .rail-foot { display: none; }
    .nav-list { display: flex; overflow-x: auto; padding: 0 var(--s3) var(--s3); }
    .nav-link { white-space: nowrap; }
    .stage { padding: var(--s3) var(--s4) var(--s6); }
    .stage-bar { justify-content: flex-start; }
}

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