:root {
  color-scheme: light;
  font-family: system-ui, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: #192846;
  background: #f2f5fa;
  --ink: #192846;
  --muted: #4e5f78;
  --navy: #17284f;
  --accent: #2457a7;
  --line: #d8e1ed;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p { margin: 0; }
button, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid #2865d2; outline-offset: 3px; }

.wrap { width: min(1520px, calc(100% - 64px)); margin-inline: auto; }
.top { color: white; background: var(--navy); border-bottom: 3px solid #527fdd; }
.top-inner, .header-actions, .brand { display: flex; align-items: center; gap: 12px; }
.top-inner { min-height: 64px; justify-content: space-between; }
.brand { text-decoration: none; font-size: 1rem; font-weight: 750; }
.mark { flex: none; position: relative; width: 18px; height: 24px; border: 2px solid #bed2ff; border-radius: 4px; }
.mark::after { content: ""; position: absolute; inset: 9px 3px 3px; border-radius: 1px; background: #bed2ff; }
.mode { padding: 4px 8px; border: 1px solid #91aad8; border-radius: 5px; color: #e5eeff; font-size: .875rem; white-space: nowrap; }
.header-btn { color: white; border-color: #91aad8; background: transparent; }
.header-btn:hover { color: var(--navy); }
.skip { position: fixed; z-index: 3; top: 6px; left: 12px; padding: 10px; transform: translateY(-150%); background: white; }
.skip:focus { transform: none; }

.intro { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 29px 0 20px; }
.intro h1 { font-size: clamp(1.85rem, 4vw, 2.55rem); letter-spacing: -.045em; }
.intro p, .board-head p { color: var(--muted); margin-top: 5px; font-size: .94rem; }
.btn, .switch button, select, .text-btn {
  min-height: 42px; border: 1px solid #becce0; border-radius: 7px; padding: 7px 12px;
  background: #fff; color: var(--ink); font-weight: 650;
}
.btn, .text-btn, .switch button { transition: background .15s, border-color .15s, transform .15s; }
.btn:hover, .text-btn:hover, .switch button:hover { background: #e9f0ff; }
.btn:active, .text-btn:active, .switch button:active { transform: translateY(1px); }
.btn:disabled { cursor: wait; opacity: .65; }
.primary { color: #fff; background: var(--navy); }
.primary:hover { background: var(--accent); }
.text-btn { color: var(--accent); border-color: transparent; background: transparent; }
.notice { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: 12px 16px; margin-bottom: 15px; background: #fff; }
.notice.problem { border-left-color: #a85c13; background: #fff5e5; }

.summaries { display: grid; grid-template-columns: 1.15fr 1.15fr .8fr; gap: 12px; margin-bottom: 23px; }
.summary {
  display: grid; gap: 4px; justify-items: start; min-width: 0; padding: 14px 16px;
  color: var(--ink); border: 1px solid var(--line); border-top: 4px solid #7193ce; border-radius: 10px;
  background: white; text-align: left;
}
.summary-name { display: flex; align-items: center; gap: 7px; font-weight: 800; }
.summary-count { display: flex; align-items: baseline; gap: 5px; }
.summary-count strong { font-size: clamp(1.95rem, 4.3vw, 3.15rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.06em; }
.summary-count > span, .summary-hint { font-size: .875rem; }
.summary-hint { color: var(--muted); }
.alert { transition: box-shadow .15s, transform .15s; }
.alert:hover { transform: translateY(-2px); box-shadow: 0 4px 12px #25395c17; }
.alert[aria-pressed="true"] { box-shadow: inset 0 0 0 2px currentColor; }
.alert.attention { color: #8e2533; background: #fff0f1; border-color: #edc4ca; border-top-color: #c23f53; }
.alert.stale { color: #784715; background: #fff5e6; border-color: #edd6ad; border-top-color: #b87429; }
.alert.quiet { color: #384963; background: white; border-color: var(--line); }
.alert .dot { background: currentColor; }
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #567092; }
.dot.normal { background: #28806a; }
.dot.low { background: #b66a15; }
.dot.critical { background: #b93248; }
.dot.stale { background: #777e93; }
.dot.usage-today, .slot.usage-today { --tile: #dcf4e7; --tone: #11553e; --dot: #248261; }
.dot.usage-week, .slot.usage-week { --tile: #e1efff; --tone: #214c8b; --dot: #366fc1; }
.dot.usage-month, .slot.usage-month { --tile: #eee5fa; --tone: #62328a; --dot: #9463bb; }
.dot.usage-older, .slot.usage-older { --tile: #fff0d8; --tone: #774911; --dot: #b77a2b; }
.dot.usage-none, .slot.usage-none { --tile: #ebeff5; --tone: #485870; --dot: #748398; }
.legend .dot { background: var(--dot, #567092); }
.legend .dot.normal { --dot: #28806a; }
.legend .dot.low { --dot: #b66a15; }
.legend .dot.critical { --dot: #b93248; }
.legend .dot.stale { --dot: #777e93; }

.board { padding-bottom: 32px; }
.board-head, .toolbar, .inventory-key, .cart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.board-head h2 { font-size: 1.35rem; }
.actions, .tools, .filters, .jump { display: flex; align-items: center; gap: 8px; }
.actions, .tools { flex-wrap: wrap; justify-content: flex-end; }
.jump { white-space: nowrap; color: var(--muted); }
.jump select { max-width: 16rem; }
.toolbar { margin: 11px 0 4px; }
.switch { display: flex; gap: 4px; padding: 3px; border-radius: 8px; background: #e5ebf6; }
.switch button { border-color: transparent; background: transparent; white-space: nowrap; }
.switch button[aria-pressed="true"] { color: #184781; border-color: #c1cfea; background: #fff; }
.inventory-key { min-height: 44px; }
.legend { display: flex; flex-wrap: wrap; gap: 7px 13px; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: .875rem; }
.legend li { display: flex; align-items: center; gap: 5px; }

.fleet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 12px; }
.cart-card { min-width: 0; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.cart-card.current { border-color: #648bc7; box-shadow: 0 0 0 1px #648bc7; }
.cart-head { padding: 0 1px 9px; }
.cart-head h3 { font-size: 1.07rem; overflow-wrap: anywhere; scroll-margin-top: 14px; }
.cart-count { flex: none; padding: 2px 6px; border-radius: 4px; background: #edf2f9; color: #415778; font-size: .84rem; }
.slot-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.slot {
  --tile: #eaf4f1; --tone: #155b4d; --bar: #31836d;
  min-width: 0; min-height: 46px; display: grid; gap: 1px; align-content: center; justify-items: center;
  padding: 3px 0 4px; border: 1px solid #0000000c; border-radius: 5px; background: var(--tile); color: var(--tone);
  font-variant-numeric: tabular-nums; line-height: 1.13;
}
.slot > span { font-size: .72rem; }
.slot strong { font-size: .875rem; }
.slot:hover { border-color: currentColor; }
.slot.low { --tile: #fff2db; --tone: #79480c; --bar: #ab6617; }
.slot.critical { --tile: #fbe9ec; --tone: #90293a; --bar: #b8374b; }
.slot.stale, .slot.unknown { --tile: #e9edf5; --tone: #495973; }
.slot.stale strong, .slot.unknown strong { font-size: .73rem; }
.slot.usage-today strong, .slot.usage-week strong, .slot.usage-month strong, .slot.usage-older strong, .slot.usage-none strong { font-size: .77rem; }
.slot meter { appearance: none; display: block; width: calc(100% - 10px); height: 3px; margin-top: 2px; }
.slot meter::-webkit-meter-bar { height: 3px; border: 0; background: #17284f1c; }
.slot meter::-webkit-meter-optimum-value { background: var(--bar); }
.slot meter::-moz-meter-bar { background: var(--bar); }

.patrol, .usage { padding: 14px; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.patrol summary { cursor: pointer; font-weight: 750; }
.filters { margin: 10px 0; color: var(--muted); }
.filters select { min-height: 36px; padding: 4px 8px; }
.table-scroll { overflow: auto; }
.table-scroll table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
.table-scroll th, .table-scroll td { padding: 7px; border-bottom: 1px solid var(--line); }
.tag { display: inline-block; padding: 3px 6px; border-radius: 4px; font-size: .82rem; font-weight: 700; }
.tag.critical { background: #fbe9ec; color: #90293a; }
.tag.low { background: #fff2db; color: #79480c; }
.tag.stale, .tag.unknown { background: #e9edf5; color: #495973; }
.tag.normal { background: #eaf4f1; color: #155b4d; }
.empty, .usage p { color: var(--muted); padding: 10px 0; }
.usage strong { font-size: 2.75rem; color: var(--navy); }
.usage progress { width: 100%; height: 10px; accent-color: var(--accent); }
.feedback { position: fixed; z-index: 2; bottom: 18px; left: 50%; max-width: 85vw; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 9px 14px; border-radius: 6px; }
.dialog-inner { padding: 20px; }
dialog { width: min(430px, calc(100% - 28px)); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 0; }
dialog::backdrop { background: #162442bd; }
dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 15px; }
dialog dt { color: var(--muted); }
dialog dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 1120px) {
  .wrap { width: calc(100% - 44px); }
  .fleet { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .wrap { width: calc(100% - 24px); }
  .top-inner { min-height: 56px; }
  .brand { gap: 7px; font-size: .95rem; }
  .intro { padding: 19px 0 13px; }
  .summaries { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
  .summary { padding: 10px; }
  .summary.total { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; border-top-width: 1px; }
  .summary.total strong { font-size: 1.3rem; }
  .summary.total .summary-hint { margin-inline-start: auto; }
  .toolbar, .board-head { align-items: flex-start; flex-wrap: wrap; }
  .fleet { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}
@media (max-width: 410px) {
  .header-btn { padding-inline: 7px; font-size: .9rem; }
  .slot-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print {
  body { color: black; background: white; }
  .top, .intro, #dashboard, .notice, .feedback, .skip, dialog { display: none !important; }
  .wrap { width: 100%; }
  #print-sheet:not([hidden]) { display: block !important; }
  #print-sheet p, #print-sheet li { margin: 5px 0; }
}

