:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --ink: #17202a;
    --muted: #657282;
    --line: #dfe5ec;
    --accent: #0f8b8d;
    --accent-dark: #0a6365;
    --warn: #b7791f;
    --danger: #b42318;
    --ok: #13795b;
    --shadow: 0 14px 40px rgba(23, 32, 42, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}
a { color: inherit; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    background: #102027;
    color: #f8fbfc;
    padding: 22px 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    margin-bottom: 24px;
    font-size: 20px;
}
.brand span {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 8px;
    font-weight: 800;
}
nav { display: grid; gap: 4px; }
nav a {
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 7px;
    color: #c9d4da;
}
nav a.active, nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.main { margin-left: 248px; padding: 26px; min-height: 100vh; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; margin-bottom: 16px; }
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 18px;
}
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stats.report-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats article {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.stats span { display: block; color: var(--muted); margin-bottom: 10px; }
.stats strong { font-size: 24px; }
.stats small { display: block; color: var(--muted); margin-top: 8px; line-height: 1.35; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}
.form-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
label span { font-weight: 650; }
input, select, textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
textarea { min-height: 86px; resize: vertical; }
.wide { grid-column: 1 / -1; }
.check {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: 14px;
}
.check input { width: 18px; min-height: 18px; }
.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 9px 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-dark); }
.button.ghost { background: transparent; }
.button.danger { background: #fff1f0; border-color: #ffc9c4; color: var(--danger); }
.filters {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.line-items {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    overflow-x: auto;
    overflow-y: visible;
}
.line-item-head,
.line-item-row {
    display: grid;
    gap: 8px;
    align-items: center;
}
.line-item-head {
    color: var(--muted);
    font-size: 12px;
    font-weight: 760;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 0 6px;
}
.line-item-head.purchase,
.line-item-row.purchase { grid-template-columns: minmax(260px, 1.8fr) minmax(110px, .65fr) minmax(150px, .8fr) minmax(150px, .8fr) 42px; }
.line-item-head.sale,
.line-item-row.sale { grid-template-columns: minmax(220px, 1.8fr) minmax(150px, 1fr) minmax(130px, .9fr) minmax(94px, .65fr) minmax(120px, .8fr) 42px; }
.line-item-row {
    background: rgba(255,255,255,.46);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 8px;
}
.product-search-cell {
    position: relative;
    min-width: 0;
}
.product-suggestions {
    display: none;
    position: static;
    z-index: 30;
    max-height: 250px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 18px 42px rgba(0,0,0,.14);
    padding: 6px;
    margin-top: 6px;
    grid-template-columns: 1fr;
}
.product-suggestions.open { display: grid; gap: 4px; }
.product-suggestions button {
    width: 100%;
    justify-content: flex-start;
    min-height: 36px;
    border-radius: 11px;
    background: transparent;
    color: var(--ink);
    box-shadow: none;
    padding: 8px 10px;
    text-align: left;
    font-weight: 650;
}
.product-suggestions button:hover {
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
}
.product-search-popover {
    display: none;
    position: fixed;
    z-index: 2147483647;
    max-height: min(360px, calc(100vh - 40px));
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 22px 60px rgba(0,0,0,.22);
    padding: 6px;
}
.product-search-popover.open {
    display: grid;
    gap: 4px;
}
.product-search-popover button,
.product-popover-empty {
    width: 100%;
    min-height: 38px;
    border-radius: 11px;
    background: transparent;
    color: var(--ink);
    box-shadow: none;
    padding: 8px 10px;
    text-align: left;
    font-weight: 650;
}
.product-search-popover button {
    justify-content: flex-start;
}
.product-search-popover button:hover {
    background: var(--brand-primary-soft);
    color: var(--brand-primary);
}
.product-popover-empty {
    color: var(--muted);
    display: flex;
    align-items: center;
}
.icon-button {
    width: 40px;
    min-height: 40px;
    padding: 0;
    font-size: 21px;
    line-height: 1;
}
.control-price {
    min-height: 40px;
    display: grid;
    align-content: center;
    gap: 2px;
    padding: 9px 10px;
    border-radius: 16px;
    background: rgba(255,255,255,.54);
    color: var(--ink);
    font-weight: 760;
    white-space: normal;
    line-height: 1.2;
    min-width: 0;
    overflow-wrap: anywhere;
}
.control-price span {
    display: block;
    font-size: 12px;
}
.control-price strong {
    display: block;
    font-size: 13px;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 10px 9px;
    vertical-align: top;
}
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.link { color: var(--accent-dark); font-weight: 700; text-decoration: none; }
.pill {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 700;
}
.pill.ok { background: #dff6ee; color: var(--ok); }
.pill.off { background: #eef1f4; color: var(--muted); }
.is-canceled {
    color: var(--muted);
    background: #f3f5f7;
}
.is-canceled td {
    opacity: .72;
}
.cancel-form {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
    gap: 6px;
    min-width: 360px;
}
.cancel-form input {
    min-height: 36px;
}
.cancel-form .button {
    min-height: 36px;
    padding: 7px 10px;
}
.flash {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    background: #eef8f6;
    color: var(--ok);
}
.flash.error { background: #fff1f0; color: var(--danger); }
.install {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
}
.install-card {
    width: min(620px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
}
dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 700; }

@media (max-width: 980px) {
    .sidebar { position: static; width: auto; }
    .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .main { margin-left: 0; padding: 18px; }
    .grid.two, .grid.three, .stats, .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
}

/* Mr. Wash / YWash2 inspired shell */
:root {
    --brand-primary: #d71920;
    --brand-accent: #ffd23f;
    --brand-primary-soft: rgba(215,25,32,.10);
    --brand-primary-line: rgba(215,25,32,.20);
    --bg: #f5f5f7;
    --surface: rgba(255,255,255,.72);
    --surface-strong: rgba(255,255,255,.88);
    --line: rgba(0,0,0,.075);
    --line-light: rgba(255,255,255,.72);
    --ink: #1d1d1f;
    --muted: #86868b;
    --accent: #d71920;
    --accent-dark: #a70f18;
    --shadow: 0 18px 54px rgba(0,0,0,.075);
    --accent-grad: linear-gradient(135deg,#ff4b55 0%,#d71920 72%,#a70f18 100%);
}
body {
    background:
        radial-gradient(circle at 18% 6%,rgba(255,255,255,.95),transparent 22rem),
        linear-gradient(135deg,#fbfaf8 0%,#f5f5f7 42%,#eceef2 100%);
    font-family: -apple-system,BlinkMacSystemFont,"SF Pro Display","SF Pro Text","Segoe UI",Roboto,Helvetica,Arial,sans-serif;
    letter-spacing: 0;
}
body:before, body:after {
    content: "";
    position: fixed;
    z-index: -2;
    pointer-events: none;
    border-radius: 999px;
    filter: blur(86px);
    opacity: .62;
}
body:before { width: 520px; height: 520px; left: -190px; top: -170px; background: rgba(215,25,32,.14); }
body:after { width: 560px; height: 560px; right: -230px; top: 120px; background: rgba(255,210,63,.14); }
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 282px minmax(0,1fr);
    gap: 18px;
    padding: 18px;
}
.glass-panel, .panel, .stats article, .login-card, .user-card {
    background: var(--surface-strong);
    border: 1px solid var(--line-light);
    border-radius: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
}
.sidebar {
    position: sticky;
    inset: auto;
    top: 18px;
    width: auto;
    min-height: calc(100vh - 36px);
    max-height: calc(100vh - 36px);
    padding: 18px;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow: auto;
}
.main { margin-left: 0; padding: 0; min-width: 0; }
.brand, .brand.has-logo {
    display: grid;
    gap: 10px;
    padding: 2px 2px 18px;
    border-bottom: 1px solid rgba(0,0,0,.06);
    color: var(--ink);
}
.brand-logo {
    display: grid;
    place-items: center;
    width: 100%;
    height: 76px;
}
.brand-logo img { max-width: 184px; max-height: 54px; object-fit: contain; }
.brand strong { font-weight: 760; font-size: 21px; }
.brand small { color: var(--muted); }
nav { gap: 6px; }
nav a {
    min-height: 42px;
    padding: 10px 13px;
    border-radius: 14px;
    color: #3a3a3c;
    font-weight: 660;
}
nav a.active, nav a:hover {
    background: rgba(255,255,255,.72);
    color: var(--brand-primary);
}
.topbar {
    min-height: 96px;
    display: grid;
    grid-template-columns: auto minmax(0,1fr) auto;
    padding: 20px 22px;
    border-radius: 28px;
}
.window-dots { display: flex; gap: 7px; align-self: start; padding-top: 3px; }
.window-dots span { width: 12px; height: 12px; border-radius: 999px; display: block; }
.window-dots span:nth-child(1) { background: #ff5f57; }
.window-dots span:nth-child(2) { background: #ffbd2e; }
.window-dots span:nth-child(3) { background: #28c840; }
.eyebrow { text-transform: uppercase; font-size: 11px; font-weight: 720; letter-spacing: .12em; }
.button, button {
    border: 0;
    border-radius: 999px;
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 10px 22px rgba(215,25,32,.18);
}
.button.ghost { background: rgba(255,255,255,.62); color: var(--ink); border: 1px solid rgba(0,0,0,.06); }
input, select, textarea {
    border-radius: 16px;
    background: rgba(255,255,255,.72);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--brand-primary-line);
    box-shadow: 0 0 0 5px var(--brand-primary-soft);
}
.user-card { margin-top: auto; padding: 15px; border-radius: 22px; }
.user-card strong, .user-card small { display: block; }
.branch-context-form { display: grid; gap: 7px; margin-top: 12px; }
.branch-context-form label { margin: 0; font-size: 12px; color: var(--muted); }
.account-actions { margin-top: 12px; }
.account-actions a {
    display: flex;
    justify-content: center;
    min-height: 38px;
    border-radius: 999px;
    background: rgba(255,255,255,.62);
    border: 1px solid var(--line);
    align-items: center;
    font-weight: 700;
}
.login-body { min-height: 100vh; }
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}
.login-card { width: min(410px, 100%); padding: 32px; }
.login-brand { display: grid; justify-items: center; gap: 8px; margin-bottom: 24px; text-align: center; }
.login-brand img { max-width: 180px; max-height: 78px; object-fit: contain; }
.login-brand strong { font-size: 24px; }
.login-brand small { color: var(--muted); }
@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; padding: 12px; }
    .sidebar { position: static; min-height: auto; max-height: none; }
    .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { grid-template-columns: 1fr; }
    .stats,
    .stats.report-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .line-item-head { display: none; }
    .line-item-row.purchase,
    .line-item-row.sale { grid-template-columns: 1fr 1fr; }
    .line-item-row .product-search-cell:first-child { grid-column: 1 / -1; }
    .icon-button { justify-self: end; }
}
