/* Endurance Masters: dark sidebar back-office. Shop staff use it, often not computer people:
   big type, big targets, plain words. Charcoal sidebar, white work area, Endurance red for the main actions. */
:root {
    --side: #1D1E22;
    --side-hover: #2A2C31;
    --side-line: #33363C;
    --side-ink: #A7ABB4;
    --paper: #F3F4F6;
    --surface: #FFFFFF;
    --ink: #1B1C1F;
    --muted: #60656E;
    --line: #E1E3E7;
    --line-strong: #C3C7CE;
    --brand: #D0112B;
    --brand-dark: #A80D22;
    --brand-soft: #FDECEE;
    --ok-bg: #E6F4EB; --ok-ink: #17643A;
    --bad-bg: #FCEBEC; --bad-ink: #8E1424;
    --warn-bg: #FFF4D9; --warn-ink: #6A4A00;
    --radius: 12px;
    --radius-sm: 8px;
    --focus: 0 0 0 3px rgba(208, 17, 43, .3);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.5 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif; }
a { color: inherit; }
h1, h2 { line-height: 1.2; margin: 0; }
.muted { color: var(--muted); margin: 2px 0 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ico { flex: none; }
[hidden] { display: none !important; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 800; font-size: 21px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-weight: 800; font-size: 17px; letter-spacing: .01em; }
.brand-text small { font-size: 13px; color: var(--side-ink); font-weight: 500; margin-top: 2px; }

/* ---------- app frame: sidebar + work area ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); color: var(--side-ink); padding: 22px 14px 16px; }
.side .brand { padding: 0 8px 24px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a { position: relative; display: flex; align-items: center; gap: 13px; padding: 12px 14px; border-radius: 9px; text-decoration: none; font-weight: 600; font-size: 16px; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a:focus-visible { outline: none; box-shadow: var(--focus); }
.nav a.on { background: var(--side-hover); color: #fff; }
.nav a.on::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand); }
.nav a.on .ico { color: var(--brand); }
.me { display: flex; align-items: center; gap: 11px; padding: 14px 8px 0; border-top: 1px solid var(--side-line); }
.avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #3A3D44; color: #fff; font-weight: 700; flex: none; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; flex: 1; }
.me-text b { color: #fff; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-out { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; color: var(--side-ink); }
.me-out:hover { background: var(--side-hover); color: #fff; }

.work { padding: 30px 36px 48px; min-width: 0; max-width: 1340px; }
.work-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.work-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-weight: 600; font-size: 15px; }
.work-title { display: flex; align-items: center; gap: 14px; }
.work-ico { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 12px; background: var(--side); color: #fff; flex: none; }
.work-ico .ico { width: 26px; height: 26px; }

/* ---------- messages ---------- */
.msg { padding: 13px 16px; border-radius: var(--radius-sm); font-weight: 600; margin: 0 0 18px; border-left: 4px solid transparent; }
.msg.ok { background: var(--ok-bg); color: var(--ok-ink); border-left-color: var(--ok-ink); }
.msg.bad { background: var(--bad-bg); color: var(--bad-ink); border-left-color: var(--bad-ink); }
.msg.warn { background: var(--warn-bg); color: var(--warn-ink); border-left-color: var(--warn-ink); }

/* ---------- home tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.tile { display: flex; flex-direction: column; gap: 8px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; min-height: 220px; transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: var(--line-strong); box-shadow: 0 6px 18px rgba(20, 22, 26, .07); }
.tile:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--brand); }
.tile-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tile-ico { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--side); color: #fff; }
.tile-ico .ico { width: 24px; height: 24px; }
.tile-n { font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile-name { font-size: 21px; font-weight: 800; }
.tile-blurb { color: var(--muted); font-size: 15px; flex: 1; }
.tile-go { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--brand); font-size: 15px; }
.tile-go .ico { width: 18px; height: 18px; }

/* ---------- the list (full width) + the popup form ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; min-width: 0; }
.card h2 { font-size: 19px; font-weight: 800; margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field { margin-bottom: 15px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.req { color: var(--brand); }
.hint { display: block; color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.in { width: 100%; min-height: 48px; padding: 10px 13px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.in:hover { border-color: #9EA3AC; }
.in:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.in[readonly] { background: var(--paper); color: var(--muted); }

/* buttons: Save in red, Delete warns, the rest stay quiet */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 48px; padding: 0 18px; font: 600 16px 'Figtree', system-ui, sans-serif; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--bad-ink); }
.btn.danger:hover { border-color: var(--bad-ink); background: var(--bad-bg); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); border-color: var(--line-strong); }
.btn.wide { width: 100%; margin-top: 6px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--line-strong); background: var(--surface); }
.tag { display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); font-size: 12.5px; font-weight: 700; white-space: nowrap; vertical-align: 1px; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14.5px; gap: 5px; }
.btn.sm .ico { width: 17px; height: 17px; }

/* the list */
.list-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 16px; align-items: center; margin-bottom: 16px; }
.list-head h2 { margin: 0; }
.count { display: inline-block; margin-left: 6px; padding: 1px 10px; border-radius: 999px; background: var(--side); color: #fff; font-size: 13.5px; font-weight: 700; vertical-align: middle; font-variant-numeric: tabular-nums; }
.search { display: flex; gap: 8px; flex-wrap: wrap; }
.search-in { position: relative; display: block; }
.search-in .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-in .in { width: 250px; min-height: 44px; padding-left: 40px; }
.search .btn { min-height: 44px; }
.empty { color: var(--muted); padding: 34px 0; text-align: center; margin: 0; }
.table-wrap { overflow: auto; max-height: 640px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
th { position: sticky; top: 0; z-index: 1; background: #F7F8F9; text-align: left; font-size: 13.5px; font-weight: 700; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td:first-child { min-width: 170px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FAFAFB; }
tbody tr.on td { background: var(--brand-soft); }
tbody tr.on td:first-child { box-shadow: inset 4px 0 0 var(--brand); }
td.acts { white-space: nowrap; text-align: right; width: 1%; }
td.acts form { display: inline; margin: 0 0 0 6px; }

/* ---------- reports ---------- */
.head-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.rtabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.rtabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); text-decoration: none; font-weight: 600; font-size: 15px; }
.rtabs a:hover { border-color: var(--ink); }
.rtabs a.on { background: var(--side); border-color: var(--side); color: #fff; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 14px; align-items: end; padding: 18px 20px 4px; margin-bottom: 16px; }
.filters .f-btns { display: flex; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip { padding: 7px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14.5px; }
.chip b { font-variant-numeric: tabular-nums; }
.rcard { padding: 14px; }
.rtable { max-height: 70vh; }
.rtable table { font-size: 14.5px; }
.rtable td, .rtable th { padding: 9px 12px; white-space: nowrap; }
.rtable td:first-child { min-width: 0; }
tfoot td { position: sticky; bottom: 0; background: #F7F8F9; font-weight: 800; border-top: 2px solid var(--line-strong); border-bottom: 0; }
.print-head { display: none; }

/* ---------- popup ---------- */
.modal { width: min(640px, calc(100vw - 32px)); max-height: min(90vh, 880px); padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(10, 12, 16, .35); }
.modal::backdrop { background: rgba(18, 20, 24, .58); }
.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal form { display: flex; flex-direction: column; max-height: inherit; }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 18px 20px 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head .work-ico { width: 42px; height: 42px; border-radius: 10px; }
.modal-head .work-ico .ico { width: 22px; height: 22px; }
.modal-head h2 { flex: 1; font-size: 21px; font-weight: 800; margin: 0; }
.modal-x { display: inline-grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.modal-x:hover { background: var(--paper); color: var(--ink); }
.modal-x:focus-visible { outline: none; box-shadow: var(--focus); }
.modal-body { padding: 20px 22px 6px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: #FAFAFB; border-radius: 0 0 16px 16px; }
.modal-foot .btn { min-width: 110px; }
.modal-foot .btn.primary { min-width: 150px; }
.modal-foot [hidden] { display: none; }
/* the product popup: wider, in sections */
.modal.wide { width: min(900px, calc(100vw - 32px)); }
.sec { font-size: 15px; font-weight: 800; margin: 6px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.sec:first-of-type { border-top: 0; padding-top: 0; }
.sec small { font-weight: 500; font-size: 13px; margin-left: 6px; }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field.span2 { grid-column: span 2; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 0 12px; align-items: end; }
.line .btn { margin-bottom: 15px; min-height: 48px; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
.tag.bad { background: var(--bad-bg); color: var(--bad-ink); }

/* ---------- sign in: dark brand panel + form ---------- */
.login-page { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; background: var(--surface); }
.login-side { display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding: 44px 56px; background: var(--side); color: var(--side-ink); }
.login-pitch h2 { color: #fff; font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; max-width: 15ch; margin-bottom: 30px; }
.login-pitch ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; max-width: 440px; }
.login-pitch li { display: flex; gap: 15px; align-items: flex-start; font-size: 15.5px; }
.login-pitch li .ico { width: 42px; height: 42px; padding: 10px; border-radius: 10px; background: var(--side-hover); color: #fff; }
.login-pitch li b { display: block; color: #fff; font-size: 16.5px; margin-bottom: 1px; }
.login-foot { font-size: 13px; }
.login-main { display: grid; place-items: center; padding: 40px 24px; }
.login-box { width: 100%; max-width: 400px; }
.login-box .brand { display: none; }
.brand-dark-text .brand-text b { color: var(--ink); }
.brand-dark-text .brand-text small { color: var(--muted); }
.login-box h1 { font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.login-box .muted { margin: 6px 0 26px; }

/* ---------- smaller screens ---------- */

@media (max-width: 900px) {
    /* the sidebar turns into a top bar with the forms in a row */
    .app { grid-template-columns: minmax(0, 1fr); }
    .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 10px 14px; }
    .side .brand { padding: 0; order: 1; }
    .brand-mark { width: 36px; height: 36px; font-size: 19px; }
    .me { order: 2; margin-left: auto; padding: 0; border: 0; }
    .me-text, .avatar { display: none; }
    .nav { order: 3; flex: 1 1 100%; flex-direction: row; overflow-x: auto; gap: 4px; margin: 0 -4px; }
    .nav a { flex: 1 1 0; flex-direction: column; gap: 3px; padding: 8px 4px; font-size: 12.5px; min-width: 0; text-align: center; }
    .nav a.on::before { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
    .work { padding: 22px 16px 36px; }
    .work-head h1 { font-size: 25px; }
    .login-page { grid-template-columns: minmax(0, 1fr); }
    .login-side { display: none; }
    .login-box .brand { display: flex; margin-bottom: 28px; }
}
@media (max-width: 640px) {
    body { font-size: 16px; }
    .card { padding: 18px 16px; }
    .grid { grid-template-columns: 1fr; }
    .grid.g3, .grid.g4 { grid-template-columns: 1fr 1fr; }
    .field.span2 { grid-column: 1 / -1; }
    /* the popup fills the phone screen */
    .modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
    .modal form { height: 100%; }
    .modal-foot { display: grid; grid-template-columns: 1fr 1fr; }
    .modal-foot .btn.primary { grid-column: 1 / -1; }
    .work-ico { display: none; }
    .work-head .btn { width: 100%; }
    .search, .search-in, .search-in .in { width: 100%; }
    .search-in { flex: 1; }
    /* the list becomes cards */
    .table-wrap { max-height: none; border: 0; }
    thead { display: none; }
    table, tbody, tr, td { display: block; width: 100%; }
    tr { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 6px 0; }
    td { border: 0; padding: 4px 14px; }
    td[data-label]::before { content: attr(data-label); display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; }
    td[data-label="Name"]::before { display: none; }
    td.acts { text-align: left; width: 100%; padding-top: 8px; }
    tbody tr.on td:first-child { box-shadow: none; }
}
/* printing a report: just the table, small and black on white */
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    body { background: #fff; font-size: 11px; }
    .app { display: block; }
    .side, .no-print, .work-head .muted { display: none !important; }
    .work { padding: 0; max-width: none; }
    .work-head { display: none !important; }
    .print-head { display: flex; justify-content: space-between; margin: 0 0 8px; font-size: 13px; }
    .chips { margin-bottom: 8px; } .chip { border: 0; padding: 0 10px 0 0; font-size: 11px; }
    .card, .rcard { border: 0; padding: 0; }
    .table-wrap, .rtable { max-height: none; overflow: visible; border: 0; }
    .rtable table { font-size: 10px; } .rtable td, .rtable th { padding: 4px 6px; white-space: normal; }
    th { position: static; background: #eee !important; color: #000; font-size: 9.5px; } tfoot td { position: static; background: #eee !important; }
    .tag { background: none !important; color: #000 !important; padding: 0; margin: 0; font-size: 10px; }
    thead { display: table-header-group; } tr { page-break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
