/* MBS Hub theme: MBS colours (MBS App Brand Guide) in a clean Apple-style layout, with practical
   Microsoft (Fluent) touches on desktop: a side navigation rail, command rows and clear tables.
   Colours are tokens only; components never use hex values. */
:root {
  --brand-orange: #F07D2D;
  --brand-black:  #181617;
  --brand-white:  #FFFFFF;

  --color-bg:            #F2F2F7;
  --color-surface:       #FFFFFF;
  --color-surface-2:     #EEEEF3;
  --color-border:        #E1E1E6;
  --color-border-strong: #C7C7CC;
  --color-bar:           rgb(255 255 255 / .82);   /* frosted bars */

  --color-text:       #181617;
  --color-text-muted: #636366;
  --color-text-on-primary: #181617;     /* text on orange is always black */

  --color-primary:       #F07D2D;
  --color-primary-hover: #D9661A;
  --color-primary-text:  #A84C14;
  --color-primary-soft:  #FEF1E8;

  --color-header-bg:     rgb(24 22 23 / .92);
  --color-header-text:   #FFFFFF;
  --color-header-muted:  #C7C7CC;
  --color-header-accent: #F07D2D;
  --color-thead-bg:   #F7F7FA;
  --color-thead-text: #636366;

  --color-success: #1E7B34;  --color-success-soft: #E6F4EA;
  --color-danger:  #C62828;  --color-danger-soft:  #FDECEC;  --color-on-danger: #FFFFFF;
  --color-warning: #F2B705;  --color-warning-soft: #FFF6D6;  --color-warning-text: #7A5A00;
  --color-info:    #636366;  --color-info-soft:    #EEEEF3;

  --shadow-card: 0 1px 2px rgb(0 0 0 / .05), 0 2px 10px rgb(0 0 0 / .04);
  --shadow-raised: 0 1px 3px rgb(0 0 0 / .12), 0 1px 1px rgb(0 0 0 / .04);
  --focus-ring: 0 0 0 3px #181617, 0 0 0 5px #F07D2D;
  --backdrop: rgb(0 0 0 / .45);

  /* The device's own font: San Francisco on iPhone and Mac, Segoe UI on Windows, Roboto on Android. */
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, system-ui, sans-serif;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-card: 16px;
  --tabbar-h: 64px;
  --rail-w: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #000000; --color-surface: #1C1C1E; --color-surface-2: #2C2C2E;
    --color-border: #38383A; --color-border-strong: #545458; --color-bar: rgb(28 28 30 / .82);
    --color-text: #F2F2F7; --color-text-muted: #A1A1A6; --color-text-on-primary: #181617;
    --color-primary: #F07D2D; --color-primary-hover: #F59551; --color-primary-text: #F59551; --color-primary-soft: #2E1D10;
    --color-header-bg: rgb(0 0 0 / .88); --color-header-text: #F2F2F7; --color-header-muted: #A1A1A6;
    --color-thead-bg: #2C2C2E; --color-thead-text: #A1A1A6;
    --color-success: #4ADE80; --color-success-soft: #0F2A17;
    --color-danger: #FF6B6B; --color-danger-soft: #2E1212; --color-on-danger: #181617;
    --color-warning: #FACC15; --color-warning-soft: #2A2205; --color-warning-text: #FACC15;
    --color-info: #A1A1A6; --color-info-soft: #2C2C2E;
    --shadow-card: none; --shadow-raised: 0 1px 2px rgb(0 0 0 / .6);
    --focus-ring: 0 0 0 3px #000000, 0 0 0 5px #F07D2D;
    --backdrop: rgb(0 0 0 / .65);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --color-bg: #000000; --color-surface: #1C1C1E; --color-surface-2: #2C2C2E;
  --color-border: #38383A; --color-border-strong: #545458; --color-bar: rgb(28 28 30 / .82);
  --color-text: #F2F2F7; --color-text-muted: #A1A1A6; --color-text-on-primary: #181617;
  --color-primary: #F07D2D; --color-primary-hover: #F59551; --color-primary-text: #F59551; --color-primary-soft: #2E1D10;
  --color-header-bg: rgb(0 0 0 / .88); --color-header-text: #F2F2F7; --color-header-muted: #A1A1A6;
  --color-thead-bg: #2C2C2E; --color-thead-text: #A1A1A6;
  --color-success: #4ADE80; --color-success-soft: #0F2A17;
  --color-danger: #FF6B6B; --color-danger-soft: #2E1212; --color-on-danger: #181617;
  --color-warning: #FACC15; --color-warning-soft: #2A2205; --color-warning-text: #FACC15;
  --color-info: #A1A1A6; --color-info-soft: #2C2C2E;
  --shadow-card: none; --shadow-raised: 0 1px 2px rgb(0 0 0 / .6);
  --focus-ring: 0 0 0 3px #000000, 0 0 0 5px #F07D2D;
  --backdrop: rgb(0 0 0 / .65);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--color-bg); color: var(--color-text); font: 400 17px/1.45 var(--font-body); letter-spacing: -.01em; }
img { max-width: 100%; }
a { color: var(--color-primary-text); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.skip { position: absolute; left: -9999px; top: 0; background: var(--color-surface); padding: 8px 12px; z-index: 20; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- Header (frosted black bar with the orange line) ---------- */
.top {
  position: sticky; top: 0; z-index: 6;
  background: var(--color-header-bg); color: var(--color-header-text);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 2px solid var(--color-header-accent);
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top-inner { max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 8px; }
.brand-left { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; text-decoration: none; }
.logo-plate { background: var(--brand-white); border-radius: var(--radius-sm); padding: 3px 6px; display: flex; flex: none; }
.logo-plate img { height: 32px; width: auto; display: block; }
.app-name { font: 600 1.15rem/1 var(--font-display); letter-spacing: -.01em; }
.who { font-size: .85rem; color: var(--color-header-muted); min-width: 0; display: flex; gap: 8px; align-items: center; }
#who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 420px) { #who { display: none; } }
.headbtn {
  flex: none; background: rgb(255 255 255 / .12); border: 0; color: var(--color-header-text);
  border-radius: 999px; min-height: 36px; padding: 4px 14px; font: 600 .85rem var(--font-body); cursor: pointer;
}
.headbtn:hover { background: rgb(255 255 255 / .2); }

/* ---------- Bottom tab bar (phone) / side rail (desktop) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex;
  background: var(--color-bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--color-border);
  padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
}
.tabbar a {
  flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--color-text-muted); font: 500 .72rem var(--font-body); letter-spacing: 0; border-radius: var(--radius-sm);
}
.tabbar a.on { color: var(--color-primary-text); font-weight: 600; }
.tabbar a.tab-report:not(.on) svg { color: var(--color-primary-text); }

@media (min-width: 1000px) {
  /* Desktop: a Fluent-style navigation rail down the left. */
  .tabbar {
    top: calc(52px + env(safe-area-inset-top, 0px)); bottom: 0; right: auto; width: var(--rail-w);
    flex-direction: column; justify-content: flex-start; gap: 2px; padding: 16px 12px;
    border-top: 0; border-right: 1px solid var(--color-border); background: var(--color-surface);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .tabbar a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 44px; padding: 0 12px; font-size: .95rem; position: relative; color: var(--color-text); }
  .tabbar a:hover { background: var(--color-surface-2); }
  .tabbar a.on { background: var(--color-surface-2); color: var(--color-text); }
  .tabbar a.on::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--color-primary); }
  .tabbar a.on svg { color: var(--color-primary-text); }
  body:has(.tabbar:not([hidden])) main { margin-left: var(--rail-w); }
  body:has(.tabbar:not([hidden])) #toast { left: calc(50% + var(--rail-w) / 2); bottom: 24px; }
}

/* ---------- Layout ---------- */
main {
  max-width: 720px; margin: 0 auto; outline: none; box-shadow: none !important;
  padding-block: 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main:has(.wide) { max-width: 1120px; }
@media (min-width: 1000px) {
  main { padding-block: 28px 48px; padding-inline: 32px; }
  body:has(.tabbar:not([hidden])) main { max-width: none; }
  body:has(.tabbar:not([hidden])) main > * { max-width: 760px; margin-inline: auto; }
  body:has(.tabbar:not([hidden])) main > .wide { max-width: 1120px; }
}
.view { display: grid; gap: 20px; min-width: 0; }
.view > * { min-width: 0; }
.stack { display: grid; gap: 16px; min-width: 0; }
.stack-sm { display: grid; gap: 8px; min-width: 0; }
h2 { margin: 0; font: 700 2rem/1.15 var(--font-display); letter-spacing: -.025em; }
h3 { margin: 0; font: 600 1.15rem/1.25 var(--font-display); letter-spacing: -.015em; }
h3.section { margin: 8px 0 -8px 16px; font: 500 .8rem/1.3 var(--font-body); text-transform: uppercase; letter-spacing: .03em; color: var(--color-text-muted); }
.page-head { display: flex; align-items: center; gap: 4px; min-width: 0; }
.page-head.split { justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.back { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; color: var(--color-primary-text); margin-left: -12px; border-radius: 999px; }
.muted { color: var(--color-text-muted); margin: 0; }
.small, small { font-size: .85rem; }
p { margin: 0; }
.warn-text { color: var(--color-warning-text); font-weight: 600; }
.notice { background: var(--color-primary-soft); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; }
.notice.ok { background: var(--color-success-soft); }
.notice.danger { background: var(--color-danger-soft); }
.notice ol { margin: 4px 0 0; padding-left: 20px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--color-text-muted); padding: 24px 0; }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--color-surface-2); border-top-color: var(--color-primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.empty { text-align: center; color: var(--color-text-muted); padding: 32px 16px; background: var(--color-surface); border-radius: var(--radius-card); display: grid; gap: 12px; justify-items: center; }

/* ---------- Forms ---------- */
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 600; min-width: 0; }
input, select, textarea {
  font: 400 1.0625rem var(--font-body); color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 48px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--color-primary); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; }
input[type="search"] { border-radius: var(--radius); background: var(--color-surface-2); border-color: transparent; }
textarea { resize: vertical; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .fields { grid-template-columns: 1fr; } }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 8px; }
legend { font-size: .9rem; font-weight: 600; padding: 0; margin-bottom: 8px; }
.card-inset { background: var(--color-surface-2); border-radius: var(--radius); padding: 14px; }
.card-inset legend { float: left; width: 100%; }
.card-inset legend + * { clear: both; }
.field-error { color: var(--color-danger); font-weight: 600; }
.field-error::before { content: "⚠ "; }
.check { display: flex; flex-direction: row; align-items: flex-start; gap: 12px; background: var(--color-surface); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; font-weight: 400; box-shadow: var(--shadow-card); }
.card-inset .check, .card .check { box-shadow: none; background: var(--color-surface-2); }
.card-inset .check { background: var(--color-surface); }
.check input { width: 22px; height: 22px; min-height: 0; flex: none; margin: 1px 0 0; accent-color: var(--color-primary); }
/* Segmented control */
.seg { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius); background: var(--color-surface-2); }
.seg label { flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; min-height: 46px; cursor: pointer; font-weight: 600; border-radius: 9px; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--color-surface); box-shadow: var(--shadow-raised); }
.seg label.sev-high:has(input:checked) { background: var(--color-danger); color: var(--color-on-danger); }
.seg label:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--color-surface); border: 1px solid var(--color-border-strong); cursor: pointer; font-weight: 500; }
.pill input { width: 18px; height: 18px; min-height: 0; accent-color: var(--color-primary); }
.pill:has(input:checked) { background: var(--color-primary-soft); border-color: var(--color-primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  font: 600 1rem var(--font-body); min-height: 48px; padding: 10px 18px; border-radius: var(--radius);
  border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text); cursor: pointer;
}
.btn:hover { background: var(--color-surface-2); }
.btn.primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text-on-primary); }
.btn.primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn.danger { background: var(--color-danger); border-color: var(--color-danger); color: var(--color-on-danger); }
.btn.go { background: var(--color-success); border-color: var(--color-success); color: var(--color-bg); }
.btn.big { min-height: 56px; font-size: 1.1rem; width: 100%; border-radius: 14px; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: .9rem; border-radius: 10px; }
.btn.on-dark { color: inherit; border-color: currentColor; background: transparent; }
.btn:disabled { opacity: .4; cursor: progress; }
.textbtn { background: none; border: 0; padding: 4px 0; color: var(--color-primary-text); font: 600 1rem var(--font-body); cursor: pointer; justify-self: start; min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; }
.textbtn:hover { text-decoration: underline; }
.textbtn.danger { color: var(--color-danger); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 999px; border: 0; background: var(--color-surface-2); display: inline-flex; align-items: center; justify-content: center; color: var(--color-text); text-decoration: none; font-weight: 700; cursor: pointer; }
.icon-btn.call { background: var(--color-success); color: var(--color-bg); }

/* ---------- Sign-in ---------- */
.gate { max-width: 420px; width: 100%; margin: 4vh auto 0; background: var(--color-surface); border-radius: 20px; padding: 28px 24px; display: grid; gap: 16px; overflow: hidden; box-shadow: var(--shadow-card); }
.gate-logo { display: block; width: 200px; max-width: 70%; margin: 0 auto; background: var(--brand-white); border-radius: var(--radius); padding: 8px 12px; }
.gate-title { margin: 0; font: 700 1.75rem/1.1 var(--font-display); letter-spacing: -.02em; text-align: center; }
.checker { height: 6px; margin: -28px -24px 0; background: repeating-conic-gradient(var(--brand-black) 0 25%, var(--brand-white) 0 50%) 0 0 / 12px 12px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--color-text-muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }

/* ---------- Chips, cards and grouped lists ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; font: 600 .78rem/1.4 var(--font-body); padding: 3px 10px; border-radius: 999px; background: var(--color-info-soft); color: var(--color-text); white-space: nowrap; letter-spacing: 0; }
.chip.ok, .chip.st-fixed, .chip.st-approved, .chip.st-closed { background: var(--color-success-soft); color: var(--color-success); }
.chip.warn, .chip.st-in-progress, .chip.st-waiting-for-approval { background: var(--color-warning-soft); color: var(--color-warning-text); }
.chip.st-open { background: var(--color-primary-soft); color: var(--color-primary-text); }
.chip.st-danger, .chip.st-declined { background: var(--color-danger-soft); color: var(--color-danger); }
.chip.big { font-size: .95rem; padding: 10px 14px; }
.card { background: var(--color-surface); border-radius: var(--radius-card); padding: 16px; min-width: 0; box-shadow: var(--shadow-card); }
.card.off { opacity: .55; }
/* Lists are inset groups with hairline separators, like iOS Settings. */
.list { list-style: none; margin: 0; padding: 0; display: grid; background: var(--color-surface); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-card); }
.list > li + li { border-top: 1px solid var(--color-border); }
.list > li > .card, .list > li.card { border-radius: 0; box-shadow: none; }
.list > li > .empty, .list > li.empty { border-radius: 0; }
.row-link { display: grid; gap: 4px; text-decoration: none; color: var(--color-text); }
.row-link:hover, a.row-item:hover { background: var(--color-surface-2); }
.row-link.bad { box-shadow: inset 4px 0 0 var(--color-danger); }
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 60px; text-decoration: none; color: var(--color-text); }
.row-item .grow small { display: block; }
.chev { color: var(--color-border-strong); font-size: 1.6rem; line-height: 1; }
.row-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.body { white-space: pre-line; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--color-text-muted); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--color-surface-2); color: var(--color-text); font: 600 .9rem var(--font-body); display: inline-flex; align-items: center; justify-content: center; }
.avatar.dot-in { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-success); }
.avatar.dot-late { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-warning); }
.avatar.dot-leave { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-info); }
.grow { flex: 1; min-width: 0; display: grid; }

/* ---------- KPI tiles (Fluent cards) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.tile { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-card); }
.tile b { font: 700 2rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile span { color: var(--color-text-muted); font-size: .9rem; }
.tile.ok b { color: var(--color-success); }
.tile.warn b { color: var(--color-warning-text); }

/* ---------- Home ---------- */
.hello h2 { font-size: 2.1rem; }
.urgent { display: flex; gap: 12px; background: var(--color-danger); color: var(--color-on-danger); border-radius: var(--radius-card); padding: 16px; }
.urgent svg { flex: none; }
.urgent > div { display: grid; gap: 6px; }
.urgent .title { font: 700 1.2rem/1.25 var(--font-display); }
.urgent .btn { justify-self: start; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.quick { display: grid; gap: 10px; align-content: start; min-height: 96px; padding: 14px; background: var(--color-surface); border-radius: var(--radius-card); color: var(--color-text); text-decoration: none; box-shadow: var(--shadow-card); }
.quick svg { width: 36px; height: 36px; padding: 7px; border-radius: 10px; background: var(--color-primary); color: var(--color-text-on-primary); }
.quick span { display: grid; }
.quick small { color: var(--color-text-muted); }
.quick.on svg { background: var(--color-success); color: var(--color-bg); }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filter { flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px; border-radius: 999px; background: var(--color-surface-2); color: var(--color-text); font-weight: 600; font-size: .9rem; text-decoration: none; }
.filter[aria-current] { background: var(--color-text); color: var(--color-bg); }
.post { display: grid; gap: 10px; }
.post.must { box-shadow: var(--shadow-card), inset 0 0 0 2px var(--color-primary); }
.kicker { font: 700 .75rem var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--color-primary-text); }
.byline { display: flex; align-items: center; gap: 10px; }
.byline > span:nth-child(2) { display: grid; flex: 1; min-width: 0; }
.byline small { color: var(--color-text-muted); }
.ack .btn { width: 100%; }

/* ---------- More menu (Settings-style rows with icon tiles) ---------- */
.menu { display: grid; background: var(--color-surface); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-card); }
.menu-item { display: flex; align-items: center; gap: 14px; min-height: 60px; padding: 10px 16px; color: var(--color-text); text-decoration: none; position: relative; }
.menu-item + .menu-item::before { content: ""; position: absolute; top: 0; left: 62px; right: 0; height: 1px; background: var(--color-border); }
.menu-item:hover { background: var(--color-surface-2); }
.menu-item svg { flex: none; width: 32px; height: 32px; padding: 6px; border-radius: 8px; background: var(--color-primary); color: var(--color-text-on-primary); }
.menu-item span { display: grid; flex: 1; }
.menu-item small { color: var(--color-text-muted); }
.menu-item::after { content: "›"; color: var(--color-border-strong); font-size: 1.6rem; line-height: 1; }

/* ---------- Reporting ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .cat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cat { display: grid; gap: 12px; align-content: start; min-height: 112px; padding: 14px; background: var(--color-surface); border-radius: var(--radius-card); color: var(--color-text); text-decoration: none; box-shadow: var(--shadow-card); }
.cat b { line-height: 1.25; font-weight: 600; }
.cat-icon { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--color-surface-2); }
.tone-warn .cat-icon { background: var(--color-primary); color: var(--color-text-on-primary); }
.tone-danger .cat-icon { background: var(--color-danger); color: var(--color-on-danger); }
.cat-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); background: var(--color-surface); box-shadow: var(--shadow-card); }
.cat-banner.tone-warn { background: var(--color-primary-soft); box-shadow: none; }
.cat-banner.tone-danger { background: var(--color-danger-soft); box-shadow: none; }
.cat-banner b { flex: 1; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 88px; height: 88px; border-radius: var(--radius); background: var(--color-surface-2); overflow: hidden; display: block; padding: 0; border: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.add { border: 1.5px dashed var(--color-border-strong); background: var(--color-surface); display: grid; place-items: center; align-content: center; gap: 4px; font: 600 .85rem var(--font-body); color: var(--color-primary-text); cursor: pointer; }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .65); color: var(--brand-white); font-size: 1.1rem; cursor: pointer; }
.timeline { list-style: none; margin: 0 0 0 8px; padding: 0 0 0 20px; border-left: 2px solid var(--color-border); display: grid; gap: 16px; }
.timeline li { display: grid; gap: 2px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -27px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--color-primary); box-shadow: 0 0 0 3px var(--color-bg); }

/* ---------- Prestart ---------- */
.pitem { background: var(--color-surface); border-radius: var(--radius-card); padding: 14px; box-shadow: var(--shadow-card); }
.pitem legend { float: left; width: 100%; margin-bottom: 10px; font-weight: 600; font-size: 1rem; }
.pitem legend small { color: var(--color-primary-text); font-weight: 600; }
.pitem legend + * { clear: both; }
.pa-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pa { display: flex; flex-direction: row; justify-content: center; align-items: center; min-height: 50px; border-radius: var(--radius); background: var(--color-surface-2); cursor: pointer; font-weight: 600; position: relative; }
.pa input { position: absolute; opacity: 0; pointer-events: none; }
.pa:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.pa-ok:has(input:checked) { background: var(--color-success); color: var(--color-bg); }
.pa-fault:has(input:checked) { background: var(--color-danger); color: var(--color-on-danger); }
.pa-na:has(input:checked) { background: var(--color-text); color: var(--color-bg); }
.fault-note { margin-top: 8px; }
.prestart-summary { position: sticky; bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom, 0px)); padding: 14px 16px; border-radius: var(--radius); background: var(--color-bar); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: var(--shadow-raised); font-weight: 600; }
@media (min-width: 1000px) { .prestart-summary { bottom: 12px; } }
.prestart-summary.good { background: var(--color-success); color: var(--color-bg); }
.prestart-summary.warn { background: var(--color-warning); color: var(--brand-black); }
.prestart-summary.bad { background: var(--color-danger); color: var(--color-on-danger); }

/* ---------- Time and leave ---------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.week-nav .spacer { width: 80px; }
.tally { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 4px; color: var(--color-text-muted); flex-wrap: wrap; }
.tally b { font: 700 2rem/1 var(--font-display); color: var(--color-text); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.clock-card { display: grid; gap: 10px; padding: 20px; border-radius: 20px; background: var(--brand-black); color: var(--brand-white); }
.clock-card .big-line { font: 700 1.6rem/1.15 var(--font-display); letter-spacing: -.02em; }
.entry { display: flex; align-items: center; gap: 12px; }
.entry .hrs { flex: none; }
.hrs { font: 600 1.05rem var(--font-body); font-variant-numeric: tabular-nums; text-align: right; }
.day { display: grid; gap: 10px; }
.day-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.day-fields label { font-size: .8rem; color: var(--color-text-muted); font-weight: 500; }
.bal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.bal { display: grid; gap: 2px; }
.bal b { font: 700 2rem/1.1 var(--font-display); color: var(--color-primary-text); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.bal b span { font: 500 1rem var(--font-body); color: var(--color-text-muted); }
.leave-row { display: grid; gap: 4px; }

/* ---------- People ---------- */
.person { display: flex; align-items: center; gap: 12px; }

/* ---------- Production ---------- */
.station-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.station { display: grid; gap: 6px; }
.kpi { font: 700 2rem/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi span { font: 500 1rem var(--font-body); color: var(--color-text-muted); }
.bar { height: 8px; border-radius: 4px; background: var(--color-surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--color-primary); border-radius: 4px; }
.table-wrap { overflow-x: auto; background: var(--color-surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 12px 14px; text-align: left; vertical-align: top; }
td .chip { margin-left: 6px; }
thead th { background: var(--color-thead-bg); color: var(--color-thead-text); font: 600 .78rem var(--font-body); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--color-border); }
tbody tr + tr td { border-top: 1px solid var(--color-border); }
tbody tr:hover td { background: var(--color-surface-2); }
.cell-sub { display: block; color: var(--color-text-muted); }
/* On phones, tables become stacked rows instead of scrolling sideways. */
@media (max-width: 560px) {
  table.stack-on-phone, .stack-on-phone tbody, .stack-on-phone tr, .stack-on-phone td { display: block; }
  .stack-on-phone thead { display: none; }
  .stack-on-phone tr { padding: 12px 16px; }
  .stack-on-phone tbody tr + tr { border-top: 1px solid var(--color-border); }
  .stack-on-phone tbody tr + tr td { border-top: 0; }
  .stack-on-phone td { padding: 2px 0; }
  .stack-on-phone td[data-label]:not(:first-child)::before { content: attr(data-label) ": "; color: var(--color-text-muted); }
}

/* ---------- Manage (Fluent-style navigation pane on desktop) ---------- */
.manage-layout { display: grid; gap: 16px; min-width: 0; }
.manage-body { min-width: 0; }
.subtabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.subtabs a { flex: none; min-height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; background: var(--color-surface-2); color: var(--color-text); font: 600 .9rem var(--font-body); text-decoration: none; }
.subtabs a[aria-current] { background: var(--color-text); color: var(--color-bg); }
@media (min-width: 900px) {
  .manage-layout { grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: start; }
  .subtabs { flex-direction: column; gap: 2px; position: sticky; top: 80px; }
  .subtabs a { min-height: 40px; border-radius: var(--radius-sm); background: transparent; position: relative; font-weight: 500; }
  .subtabs a:hover { background: var(--color-surface-2); }
  .subtabs a[aria-current] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-card); font-weight: 600; }
  .subtabs a[aria-current]::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--color-primary); }
}
/* Phones: start and finish side by side with the break; the day picker gets its own row. */
.entry-edit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 4.5rem; gap: 8px; align-items: center; padding: 10px; background: var(--color-surface-2); border-radius: var(--radius); }
.entry-edit > b, .entry-edit > small, .entry-edit > .row-actions, .entry-edit > .early { grid-column: 1 / -1; }
.entry-edit input { min-width: 0; width: 100%; }
/* Room for "3:32 PM" on a phone: drop the clock icon (tapping the box still opens the picker). */
@media (max-width: 719px) { .entry-edit input[type=time] { padding-inline: 8px; } .entry-edit input[type=time]::-webkit-calendar-picker-indicator { display: none; } }
.entry-edit > input[type=date] { grid-column: 1 / -1; }
@media (min-width: 720px) { .entry-edit { grid-template-columns: 110px 1fr 1fr 90px auto; } .entry-edit > input[type=date] { grid-column: auto; } .entry-edit > b { grid-column: auto; } .entry-edit > small { grid-column: 2 / 4; } }
details summary { cursor: pointer; font-weight: 600; min-height: 32px; }

/* ---------- Receipts ---------- */
.seg a.seg-link { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 9px; color: var(--color-text); text-decoration: none; font-weight: 600; }
.seg a.seg-link[aria-selected="true"] { background: var(--color-surface); box-shadow: var(--shadow-raised); }
.row-actions.split { justify-content: space-between; }

/* Receipt scanner (crop / flatten / clean up), from the Receipts app */
.scan { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--brand-black); color: var(--brand-white);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
.scan-title { margin: 0; padding: 14px 16px; font: 600 1.1rem/1.2 var(--font-display); text-align: center; border-bottom: 2px solid var(--brand-orange); }
.scan-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 8px; }
.scan-canvas { touch-action: none; display: block; position: absolute; inset: 0; }
.scan-result { max-width: 100%; max-height: 100%; object-fit: contain; background: var(--brand-white); }
.scan-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 12px 16px 16px; background: var(--brand-black); }
.scan-bar .btn { min-height: 48px; flex: 1 1 auto; }
.scan-bar .btn.scan-ghost { color: var(--brand-white); border-color: rgb(255 255 255 / .5); background: transparent; }
.scan-bar .btn.primary { flex: 1 1 140px; }
.scan-modes { display: flex; flex: 1 1 100%; order: -1; border: 1.5px solid rgb(255 255 255 / .5); border-radius: var(--radius); overflow: hidden; }
.scan-modes .btn { flex: 1; border: 0; border-radius: 0; background: transparent; color: var(--brand-white); }
.scan-modes .btn[aria-pressed="true"] { background: var(--brand-orange); color: var(--brand-black); }

/* ---------- Photo viewer ---------- */
dialog.photo-view { border: 0; border-radius: var(--radius-card); padding: 12px; background: var(--color-surface); color: var(--color-text); max-width: 94vw; max-height: 92vh; }
dialog.photo-view::backdrop { background: var(--backdrop); }
dialog.photo-view img { display: block; max-width: 100%; max-height: 78vh; margin: 0 auto; border-radius: var(--radius); }
dialog.photo-view form { display: flex; justify-content: center; margin-top: 12px; }

/* ---------- Toast (iOS-style HUD) ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 16px); z-index: 30;
  background: rgb(28 28 30 / .94); color: var(--brand-white); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  padding: 12px 18px; border-radius: 14px; font-weight: 600; box-shadow: 0 8px 30px rgb(0 0 0 / .25);
  transition: transform .2s ease, opacity .2s ease; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
  opacity: 0; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ---------- Kiosk (tablet on the floor, always dark) ---------- */
.kiosk-body { background: var(--color-bg); min-height: 100vh; }
.kiosk-body #kiosk { padding: 24px max(24px, env(safe-area-inset-right, 0px)) 24px max(24px, env(safe-area-inset-left, 0px)); max-width: 1400px; margin: 0 auto; }
.kiosk-body #toast { bottom: 24px; }
.k-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 16px; border-bottom: 2px solid var(--color-primary); }
.k-logo { height: 52px; background: var(--brand-white); border-radius: var(--radius); padding: 4px 8px; }
.k-clock { font: 700 3.25rem/1 var(--font-display); text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.k-date { color: var(--color-text-muted); text-align: right; }
.k-title { font: 700 2rem/1.2 var(--font-display); letter-spacing: -.02em; margin: 24px 0 16px; }
.k-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.k-name { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; text-align: left; min-height: 88px; padding: 14px 16px; border-radius: 18px; border: 0; background: var(--color-surface); color: var(--color-text); font: 600 1.15rem var(--font-body); cursor: pointer; }
.k-name:active { transform: scale(.98); }
.k-name .avatar { grid-row: 1 / 3; width: 54px; height: 54px; font-size: 1.1rem; background: var(--color-surface-2); }
.k-name small { color: var(--color-text-muted); font-weight: 500; }
.k-name.in .avatar { box-shadow: 0 0 0 3px var(--color-surface), 0 0 0 5px var(--color-success); }
.k-name.in small { color: var(--color-success); font-weight: 600; }
.k-foot { margin-top: 24px; color: var(--color-text-muted); text-align: center; }
.k-pin-body { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
@media (max-width: 760px) { .k-pin-body { grid-template-columns: 1fr; } }
.k-cam { display: grid; gap: 8px; }
.k-video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 20px; background: var(--color-surface); transform: scaleX(-1); }
.k-pad-wrap { display: grid; gap: 14px; justify-items: center; }
.k-dots { font: 700 2rem/1 var(--font-display); letter-spacing: .3em; text-align: center; min-height: 48px; padding: 8px; }
/* Phone-style round keypad */
.k-pad { display: grid; grid-template-columns: repeat(3, 88px); gap: 16px 24px; }
.k-key { width: 88px; height: 88px; border-radius: 50%; border: 0; background: var(--color-surface-2); color: var(--color-text); font: 500 2.1rem var(--font-display); cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; }
.k-key:active { background: var(--color-border-strong); }
.k-key.go { background: var(--color-primary); color: var(--color-text-on-primary); font: 600 1rem var(--font-body); }
.k-done { min-height: 80vh; display: grid; place-content: center; justify-items: center; gap: 16px; text-align: center; }
.k-done h1 { font: 700 3rem/1.1 var(--font-display); letter-spacing: -.03em; margin: 0; }
.k-done p { font-size: 1.5rem; color: var(--color-text-muted); }
.k-done.in svg { color: var(--color-success); }
.k-done.out svg { color: var(--color-primary); }
