:root {
  color-scheme: light;
  --ink: #292f28;
  --muted: #68635f;
  --canvas: #f5f5f0;
  --paper: #fffefa;
  --line: #e0e2db;
  --sage: #a4b8ac;
  --sage-light: #dce1da;
  --gray: #8e929b;
  --pink: #fbe0d9;
  --pink-edge: #ecb7b3;
  --pink-wash: #fbefeb;
  --rose-ink: #694347;
  --sans: "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 14px/1.6 var(--sans); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid #935e64; outline-offset: 3px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; z-index: 5; top: 8px; left: 8px; padding: 8px 14px; background: var(--paper); transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.icon { width: 19px; height: 19px; vertical-align: middle; flex: none; }


body {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  min-height: 100vh;
  background: #f3f4ef;
}
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 25px;
  height: 100vh;
  padding: 24px 14px 18px;
  border-right: 1px solid var(--line);
  background: #fafaf6;
}
.brand { display: inline-flex; align-items: center; gap: 10px; align-self: flex-start; padding-inline: 5px; text-decoration: none; }
.brand-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--pink); color: var(--rose-ink); }
.brand-icon .icon { width: 23px; height: 23px; }
.brand strong { display: block; white-space: nowrap; font-size: 17px; line-height: 1.25; letter-spacing: .04em; }
.brand small { display: block; color: var(--muted); font-size: 9px; line-height: 1.4; letter-spacing: .16em; margin-top: 3px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 7px 10px; border-radius: 8px; color: #595e57; font-size: 13px; text-decoration: none; white-space: nowrap; }
.sidebar nav a:hover { background: #eef0ea; }
.sidebar nav a[aria-current="page"] { background: var(--pink-wash); color: var(--rose-ink); font-weight: 700; }
.sidebar nav .icon { width: 17px; }
.store-label { display: flex; align-items: center; gap: 10px; padding: 14px 5px 0; margin-top: auto; border-top: 1px solid var(--line); }
.store-label > span:first-child { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--sage-light); color: #40584b; }
.store-label strong, .store-label small { display: block; font-size: 12px; }
.store-label small { color: var(--muted); font-size: 10px; }
.workspace { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 65px; padding: 12px clamp(16px, 2.3vw, 32px); border-bottom: 1px solid var(--line); background: #fafaf6; }
#global-search { display: flex; align-items: center; gap: 8px; width: min(100%, 400px); min-width: 0; padding: 3px 4px 3px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
#global-search .icon { color: var(--muted); width: 16px; }
#global-search input { width: 100%; min-width: 0; background: transparent; border: 0; outline: none; font-size: 13px; }
#global-search:focus-within { outline: 2px solid #935e64; outline-offset: 1px; }
#global-search button { padding: 4px 9px; border: 0; border-radius: 5px; background: var(--pink-wash); color: var(--rose-ink); font-size: 12px; white-space: nowrap; }
#global-search button:hover { background: var(--pink); }
.demo-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px; background: #ecefe9; color: #535c51; white-space: nowrap; font-size: 11px; }
.demo-badge i { width: 6px; height: 6px; border-radius: 50%; background: #69796b; }
main { max-width: 1550px; margin: auto; padding: 25px clamp(16px, 2.3vw, 32px) 34px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: clamp(25px, 2.5vw, 34px); line-height: 1.2; }
.page-header p, .section-note, .muted { color: var(--muted); }
.dashboard-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 9px 12px; margin-bottom: 17px; }
.dashboard-heading p { color: var(--muted); margin-bottom: 0; font-size: 13px; }
.snapshot { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.snapshot .icon { width: 13px; height: 13px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 14px; }
.metric { position: relative; display: block; min-width: 0; padding: 14px 14px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); text-decoration: none; }
.metric:nth-child(2), .metric:nth-child(4) { background: #fcf3f0; border-color: #eee0dc; }
.metric:hover { border-color: #bc918e; }
.metric-label { display: block; margin-top: 9px; color: #555954; font-size: 13px; font-weight: 650; }
.metric-icon { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; }
.metric-icon .icon { width: 17px; height: 17px; }
.sage { color: #405b49; background: #e7eee6; }
.sand { color: #69522e; background: #f4ecdb; }
.peach { color: #803f38; background: #f9e3de; }
.gray { color: #4d5766; background: #eaecef; }
.metric strong { display: block; margin: 5px 0 2px; font-size: 30px; font-weight: 730; line-height: 1.05; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted); font-size: 11px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 13px; margin-bottom: 14px; }
.dashboard-trio { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-bottom { align-items: start; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); }
.panel-head { padding: 14px 15px 11px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
h2 { font-size: 16px; line-height: 1.35; margin-bottom: 3px; }
.section-note { margin: 0; font-size: 12px; }
.panel-head > a { flex-shrink: 0; margin-top: 3px; color: var(--rose-ink); text-decoration: none; font-size: 12px; font-weight: 650; }
.panel-head > a:hover, .table-title:hover { text-decoration: underline; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 1px 20px 14px; }
.search { display: flex; align-items: center; gap: 7px; flex: 1 1 150px; }
.search, .controls select, .status-field select, .limit-form input { border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); min-height: 38px; padding: 6px 9px; }
.search .icon { width: 16px; color: var(--muted); }
.search input { width: 100%; min-width: 0; border: 0; outline: none; background: transparent; }
.search:focus-within { outline: 2px solid #935e64; outline-offset: 1px; }
.controls input, .controls select { font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: var(--pink-wash); color: #594b4b; font-size: 11px; font-weight: 650; white-space: nowrap; }
th, td { padding: 9px 10px; border-bottom: 1px solid #f0e9e5; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 16px; }
td { font-size: 12px; }
.inventory-row:hover { background: #fcf6f3; }
.table-title { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; font-weight: 700; }
.item-code { display: block; color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: .03em; }
.quantity, .date-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.quantity strong { font-size: 15px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.tag .icon { width: 12px; height: 12px; }
.row-toggle { background: transparent; border: 0; border-radius: 6px; min-width: 28px; min-height: 34px; color: #6b595b; }
.row-toggle:hover { background: var(--pink-wash); }
.row-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.detail > td { background: #fcf6f3; padding: 14px 20px; }
.detail table { margin-top: 8px; }
.detail th:first-child, .detail td:first-child { padding-left: 9px; }
.detail th:last-child, .detail td:last-child { padding-right: 9px; }
.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 20px; color: var(--muted); font-size: 11px; }
.pagination { display: flex; gap: 6px; }
.pagination button, .plain-button, .save-button { padding: 5px 9px; min-height: 33px; border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); }
button:disabled { cursor: default; opacity: .45; }
.alert-stack { display: grid; gap: 10px; padding: 0 14px 14px; }
.alert-preview { display: block; padding: 8px 10px; border-left: 2px solid #d7aaa1; background: #fbf1ed; text-decoration: none; }
.alert-preview.news { background: #f1f1f2; border-color: #8e929b; }
.news .tag, .alert-card > .tag.sage { color: #4d5766; background: #e4e6ea; }
.alert-preview:hover strong { text-decoration: underline; }
.alert-preview strong { display: block; margin: 6px 0 2px; font-size: 13px; }
.alert-preview p { margin: 0 0 6px; color: var(--muted); font-size: 11px; }
.alert-preview footer { color: var(--muted); font-size: 11px; }
.line-short { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 14px 14px; padding: 10px 12px; border-block: 1px solid var(--line); color: var(--rose-ink); text-decoration: none; font-size: 12px; }
.line-short:hover { background: var(--pink-wash); }
.page-header { margin: 10px 0 32px; }

.alert-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.alert-card, .settings { padding: 20px; scroll-margin-top: 15px; }
.alert-card:target { outline: 2px solid #b2787d; }
.alert-card h2 { margin: 10px 0 2px; }
.alert-card p { margin-bottom: 10px; }
.alert-card dl, .settings dl { display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: 6px 12px; margin: 13px 0; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; }
.status-field { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.status-field select { min-height: 33px; font-size: 12px; }
.settings { max-width: 760px; }
.settings progress { width: 100%; accent-color: #a56870; }
.limit-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 13px; }
.limit-form input { width: 92px; }
.save-button { background: var(--pink); color: var(--rose-ink); border-color: var(--pink-edge); }
.feedback { font-size: 12px; color: #435d49; margin: 7px 0 0; }
.empty { text-align: center; padding: 25px; color: var(--muted); }
.site-foot { color: var(--muted); padding: 17px 1px 0; margin-top: 30px; border-top: 1px solid var(--line); font-size: 11px; }
.site-foot a { margin-left: 8px; }

.alert-controls { margin-left: 0; }
.inventory-login { max-width: 590px; }
.inventory-login .limit-form input { width: min(100%, 245px); }

.warehouse-table td, .warehouse-table th { padding-block: 6px; }
.warehouse-table tbody th { background: transparent; color: var(--ink); }
.warehouse-table tbody tr:nth-child(even) { background: #f7f8f3; }
.warehouse-table tbody a { display: inline-flex; gap: 8px; align-items: center; text-decoration: none; }
.warehouse-table tbody a:hover { text-decoration: underline; }
.warehouse-code { color: #526458; font-size: 10px; font-variant-numeric: tabular-nums; }
.warehouse-share { display: flex; gap: 6px; align-items: center; font-size: 11px; }
.stock-track { height: 5px; width: clamp(33px, 7vw, 112px); border-radius: 10px; background: #e9ebe6; overflow: hidden; }
.stock-track i { display: block; height: 100%; border-radius: inherit; background: var(--sage); }
.movement-chart { display: flex; flex-direction: column; }
.chart-summary { display: flex; align-items: baseline; gap: 7px; margin-inline: 15px; color: var(--muted); font-size: 12px; }
.chart-summary strong { color: var(--ink); font-size: 27px; }
.time-chart { display: flex; flex: 1; gap: 13px; margin: 9px 15px 14px; padding: 0; list-style: none; }
.time-chart li { display: grid; grid-template-rows: minmax(115px, 1fr) auto; flex: 1; min-width: 0; gap: 6px; text-align: center; color: var(--muted); font-size: 10px; }
.time-bar-track {
  display: flex; align-items: flex-end; justify-content: center; padding-top: 20px;
  border-bottom: 1px solid var(--line);
  background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), #eeeee9 calc(25% - 1px) 25%);
}
.time-bar { position: relative; width: 62%; max-width: 44px; height: var(--height); border-radius: 5px 5px 0 0; background: var(--sage); }
.time-chart li:nth-child(even) .time-bar { background: var(--pink-edge); }
.time-bar strong { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); color: var(--ink); font-size: 12px; }
.expiry-content { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 16px 15px 20px; }
.expiry-ring { display: grid; place-items: center; width: clamp(72px, 7.5vw, 112px); aspect-ratio: 1; border-radius: 50%; background: conic-gradient(var(--sage) var(--normal-end), var(--pink-edge) var(--normal-end) var(--soon-end), var(--gray) var(--soon-end)); }
.expiry-ring.empty-ring { background: var(--sage-light); }
.expiry-ring span { display: grid; place-content: center; width: 72%; aspect-ratio: 1; border-radius: 50%; background: var(--paper); text-align: center; font-size: 10px; color: var(--muted); }
.expiry-ring strong { font-size: 20px; line-height: 1.18; color: var(--ink); }
.expiry-legend, .compact-list, .activity-list { margin: 0; padding: 0; list-style: none; }
.expiry-legend li { display: grid; grid-template-columns: 7px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 5px 0; font-size: 11px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); }
.legend-dot.soon { background: var(--pink-edge); }
.legend-dot.expired { background: var(--gray); }
.compact-list { padding: 0 15px 9px; }
.compact-list li + li, .activity-list li + li { border-top: 1px solid var(--line); }
.compact-list a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; text-decoration: none; }
.compact-list a:hover strong { text-decoration: underline; }
.compact-list strong, .activity-list strong { display: block; font-size: 12px; }
.compact-list small, .activity-list small { display: block; color: var(--muted); font-size: 11px; }
.stock-amount { padding: 2px 6px; border-radius: 5px; background: var(--pink-wash); color: var(--rose-ink); font-size: 11px; font-weight: 700; white-space: nowrap; }
.activity-list { padding: 0 15px 10px; }
.activity-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 9px 0; }
.activity-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: #eef1eb; color: #425749; }
.activity-icon .icon { width: 15px; }
.activity-time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
@media (max-width: 1150px) {
  body { grid-template-columns: 172px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .overview-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
  .dashboard-trio { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .expiry-content { grid-template-columns: 1fr; justify-items: center; padding-top: 4px; }
  .expiry-legend { width: 100%; }
}
@media (max-width: 960px) {
  body { display: block; }
  .sidebar { position: static; height: auto; gap: 8px; padding: 12px 15px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar nav a { min-height: 36px; }
  .store-label { display: none; }
}
@media (max-width: 700px) {
  .overview-grid, .dashboard-trio, .alert-list { grid-template-columns: minmax(0, 1fr); }
  .expiry-content { grid-template-columns: auto minmax(0, 1fr); }
  .expiry-ring { width: 90px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .inventory-table .origin { display: none; }
}
@media (max-width: 420px) {
  .sidebar nav a { font-size: 11px; gap: 4px; padding-inline: 5px; }
  .sidebar nav .icon { width: 13px; }
  .warehouse-table { min-width: 310px; }
  .panel-head { padding-inline: 10px; }
  .controls { margin-inline: 10px; }
  .alert-controls { margin-left: 0; }
  th, td { padding-inline: 6px; }
  th:first-child, td:first-child { padding-left: 9px; }
  th:last-child, td:last-child { padding-right: 6px; }
  .table-title { min-height: 38px; }
  .row-toggle { min-height: 40px; }
}
