:root {
  --ground: #EDF2EF; --paper: #FFFFFF; --ink: #12302C; --ink-2: #44605A; --line: #D3DDD8;
  --blue: #1D5FA6; --blue-ink: #164B84; --blue-fill: #E1ECF8;
  --amber: #9A5400; --amber-fill: #F7E6CB; --gold: #E0A82E; --rust: #A33A22; --rust-fill: #F6DED8;
  --teal: #1E6B5C; --teal-fill: #DCEDE7;
  --radius-s: 6px; --radius-m: 10px; --radius-l: 16px;
  --font: "Readex Pro", "Segoe UI", Tahoma, system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--ground); color: var(--ink); font-size: 16px; line-height: 1.5;
  font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent; }
:root { padding-top: env(safe-area-inset-top, 0px); }
a { color: var(--blue); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 248px; flex-shrink: 0; background: var(--ink); color: #DCE6E2; display: flex; flex-direction: column;
  padding: 24px 14px; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.brand-mark { width: 42px; height: 42px; border-radius: 11px; background: var(--blue); display: grid; place-items: center; flex-shrink: 0; }
.brand b { display: block; font-weight: 600; color: #fff; }
.brand span { font-size: .8rem; color: #A9BDB7; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-m);
  color: #C7D5D1; text-decoration: none; font-size: .95rem; }
.nav a:hover { background: #1C413C; color: #fff; }
.nav a[aria-current="page"] { background: #24504A; color: #fff; font-weight: 500; }
.nav svg { flex-shrink: 0; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 14px 8px 0; border-top: 1px solid #24504A; font-size: .875rem; }
.side-foot button { justify-content: flex-start; }
.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 96px; }
.page { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }

.tabbar { display: none; }
@media (max-width: 860px) {
  .side { display: none; }
  .main { padding-top: 18px; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--paper);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px;
    justify-content: center; font-size: .72rem; color: var(--ink-2); text-decoration: none; background: none; border: 0; font-family: inherit; min-width: 0; }
  .tabbar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tabbar [aria-current="page"] { color: var(--blue); font-weight: 600; }
  h1 { font-size: 1.45rem; }
}
.sheet-backdrop { position: fixed; inset: 0; background: rgba(18, 48, 44, .45); z-index: 30; display: flex; align-items: flex-end; }
.sheet { background: var(--paper); width: 100%; border-radius: var(--radius-l) var(--radius-l) 0 0; padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 2px; max-height: 80vh; overflow-y: auto; }
.sheet a, .sheet button { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: var(--radius-m);
  color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; text-align: start; }

/* surfaces */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 18px; }

/* readout strip: one band, not four cards */
.readout { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l); }
.readout > div { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.readout > div + div { border-inline-start: 1px solid var(--line); }
.readout .v { font-size: 2.1rem; font-weight: 600; line-height: 1; }
.readout .v small { font-size: .95rem; font-weight: 400; color: var(--ink-2); margin-inline-start: 4px; }
.readout .l { font-size: .875rem; color: var(--ink-2); }
.readout a.v { color: var(--ink); text-decoration: none; }
@media (max-width: 760px) {
  .readout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readout > div:nth-child(3) { border-inline-start: 0; }
  .readout > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* the graduated cylinder — MEL's signature element */
.cyl { --fill: 50; width: 46px; height: 120px; position: relative; flex-shrink: 0; }
.cyl .tube { position: absolute; inset: 8px 4px 0; border: 2px solid var(--ink); border-top: 0; border-radius: 0 0 12px 12px; overflow: hidden; background: #F5F8F7; }
.cyl .lip { position: absolute; top: 0; left: 0; right: 0; height: 10px; border: 2px solid var(--ink); border-bottom: 0; border-radius: 6px 6px 0 0; }
.cyl .liquid { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--fill) * 1%); background: var(--blue); transition: height .9s cubic-bezier(.2, .8, .2, 1); }
.cyl .liquid::before { content: ""; position: absolute; top: -3px; left: 0; right: 0; height: 6px; border-radius: 50%; background: #3D7EC4; }
.cyl .ticks { position: absolute; inset: 14px 4px 6px auto; width: 10px; background: repeating-linear-gradient(to bottom, var(--ink) 0 1px, transparent 1px 20%); opacity: .35; }
.cyl.gold .liquid { background: var(--gold); } .cyl.gold .liquid::before { background: #EDC260; }
.cyl.big { width: 92px; height: 260px; }
.cyl.mid { width: 66px; height: 180px; }
.cyl.mid .tube { inset: 12px 6px 0; border-width: 2.5px; border-radius: 0 0 16px 16px; }
.cyl.mid .lip { height: 14px; }
.cyl.big .tube { inset: 16px 8px 0; border-width: 3px; border-radius: 0 0 22px 22px; }
.cyl.big .lip { height: 18px; border-width: 3px; }
@media (prefers-reduced-motion: reduce) { .cyl .liquid { transition: none; } }

.top-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.top-item { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.top-item .meta { display: flex; flex-direction: column; gap: 0; }
.top-item .cls { font-size: 1.3rem; font-weight: 600; }
.top-item .pct { font-size: 1.05rem; }

/* lists & tables */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid #E4EAE7; flex-wrap: wrap; }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.when { min-width: 74px; display: flex; flex-direction: column; }
.when b { font-size: 1.05rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; background: var(--paper); }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid #E4EAE7; vertical-align: middle; }
th { font-weight: 500; color: var(--ink-2); background: #F6F9F8; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th.cth { white-space: normal; min-width: 96px; max-width: 130px; font-size: .8rem; line-height: 1.3; }
td.sname { min-width: 170px; }
bdi { unicode-bidi: isolate; }

.chip { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.chip.pending { background: var(--amber-fill); color: #6E3C00; }
.chip.approved { background: var(--blue-fill); color: var(--blue-ink); }
.chip.completed { background: var(--teal-fill); color: #134A3F; }
.chip.rejected, .chip.cancelled, .chip.out, .chip.damaged { background: var(--rust-fill); color: #7D2A17; }
.chip.low, .chip.expiring { background: var(--amber-fill); color: #6E3C00; }
.chip.maintenance { background: var(--blue-fill); color: var(--blue-ink); }

/* controls */
button, .btn { font-family: inherit; font-size: .95rem; min-height: 44px; padding: 0 16px; border-radius: var(--radius-m);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; text-decoration: none; font-weight: 500; }
button:hover, .btn:hover { border-color: #AFC0B9; }
.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.primary:hover { background: var(--blue-ink); border-color: var(--blue-ink); }
.ghost { background: transparent; border-color: transparent; color: inherit; }
.danger, .ghost.danger { color: var(--rust); }
button:disabled { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; min-height: 38px; background: transparent; color: var(--ink-2); font-weight: 400; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 500; }
form, .form { display: flex; flex-direction: column; gap: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--ink); min-height: 44px; }
input, select, textarea { font: inherit; font-size: 1rem; color: var(--ink); background: var(--paper); border: 1px solid #B9C8C2;
  border-radius: var(--radius-s); padding: 9px 11px; min-height: 44px; width: 100%; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--blue); }
textarea { min-height: 84px; resize: vertical; }
input.score { width: 74px; text-align: center; padding: 8px 4px; }

/* evaluation */
.crit { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 18px; align-items: center; padding: 12px 0; border-top: 1px solid #E4EAE7; }
.crit:first-child { border-top: 0; }
.crit .bar { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; }
.crit .bar button { min-width: 44px; padding: 0 8px; }
.crit .bar button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.total-bar { position: sticky; bottom: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; z-index: 5; }
@media (max-width: 860px) { .total-bar { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); } }
.total-bar .big { font-size: 1.8rem; font-weight: 600; }
.absent td { color: #8A9B96; }

/* banners & toasts */
.banner { background: var(--amber-fill); color: #5A3100; border-radius: var(--radius-m); padding: 12px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.banner.info { background: var(--blue-fill); color: #123D6B; }
.error-box { background: var(--rust-fill); color: #6D2414; border-radius: var(--radius-m); padding: 12px 14px; }
.toast-zone { position: fixed; inset-inline: 0; bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; padding: 0 16px; }
@media (max-width: 860px) { .toast-zone { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius-m); max-width: 520px; pointer-events: auto; }
.toast.bad { background: var(--rust); }
.empty { color: var(--ink-2); padding: 18px 0; }

/* sign in */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-art { background: var(--ink); color: #fff; padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; gap: 32px; overflow: hidden; }
.login-art h1 { font-size: clamp(2.2rem, 4.5vw, 3.6rem); font-weight: 600; max-width: 12ch; }
.login-art .ar { font-size: clamp(1.4rem, 2.6vw, 2rem); color: #A9BDB7; }
.rack { display: flex; gap: 18px; align-items: flex-end; }
.rack .cyl .tube { border-color: #DCE6E2; background: #1C413C; } .rack .cyl .lip { border-color: #DCE6E2; }
.rack .cyl .ticks { background: repeating-linear-gradient(to bottom, #DCE6E2 0 1px, transparent 1px 20%); }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-form form { width: 100%; max-width: 380px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { padding-bottom: 24px; } .rack { display: none; } }

/* honor board (in app) */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: clamp(10px, 3vw, 36px); padding: 12px 0 0; flex-wrap: wrap; }
.podium .place { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 110px; }
.podium .place .cls { font-size: 1.6rem; font-weight: 600; }
.podium .place.first .cls { font-size: 2.2rem; }
.podium .rank { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; background: var(--ground); }
.podium .first .rank { background: var(--gold); }
.award-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.award { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px; display: flex; gap: 12px; align-items: center; }
.award .ic { width: 44px; height: 44px; border-radius: 10px; background: var(--amber-fill); display: grid; place-items: center; flex-shrink: 0; color: var(--amber); }
.award b { font-size: 1.2rem; display: block; }

[dir="rtl"] .flip { transform: scaleX(-1); }
