:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-strong: #eef3f8;
  --text: #17202a;
  --muted: #627083;
  --line: #d9e1ea;
  --blue: #1f6fbf;
  --green: #16835d;
  --amber: #b46a00;
  --red: #b42318;
  --ink-soft: #334155;
  --shadow: 0 16px 40px rgba(31, 45, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
}

button,
input {
  font: inherit;
}

.dashboard-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow,
.section-kicker,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.35;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.date-control {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.date-control input {
  min-width: 160px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink-soft);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button,
#refreshButton {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.segmented button.active {
  background: var(--blue);
  color: #ffffff;
}

.morning-brief {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.morning-brief p:last-child {
  margin-bottom: 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.brief-status {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.brief-status > div {
  display: grid;
  align-content: center;
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.brief-status strong {
  margin-top: 4px;
  font-size: 20px;
}

.metric-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric-band article {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-band span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-band strong {
  display: block;
  margin-top: 10px;
  font-size: 19px;
  line-height: 1.2;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.table-panel,
.action-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-panel {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
}

#refreshButton {
  min-width: 94px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink-soft);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  min-height: 54px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  color: var(--ink-soft);
  font-size: 14px;
}

.store-name {
  color: var(--text);
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-pending {
  background: #e7edf4;
  color: #425466;
}

.status-green {
  background: #dff5ed;
  color: var(--green);
}

.status-yellow {
  background: #fff1d6;
  color: var(--amber);
}

.status-red {
  background: #fde4e1;
  color: var(--red);
}

.action-panel {
  padding: 18px;
}

.action-panel ol {
  margin: 16px 0 20px;
  padding-left: 22px;
  color: var(--ink-soft);
  line-height: 1.65;
}

.message-draft {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.message-draft p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.line-overview-panel {
  margin-top: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.line-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px 18px;
}

.line-overview-card {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 150px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.line-overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.line-overview-head h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.line-overview-summary,
.line-overview-special {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}

.line-overview-summary {
  color: var(--text);
  font-weight: 800;
}

.line-overview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0;
}

.line-overview-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.line-detail-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.line-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 18px 18px;
}

.line-detail-card {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.line-card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.line-card-head h3 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.35;
}

.line-card-head p,
.line-special-block p,
.line-case-list p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
  white-space: normal;
  word-break: break-word;
}

.line-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.line-stat-grid div {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.line-stat-grid .wide {
  grid-column: span 2;
}

.line-stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.line-stat-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.25;
}

.category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.line-special-block {
  padding-top: 2px;
}

details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 800;
}

.line-case-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding-left: 20px;
}

.line-case-list li {
  color: var(--ink-soft);
}

.case-meta {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.empty-case {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .metric-band {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content-grid,
  .line-overview-grid,
  .line-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .dashboard-shell {
    padding: 14px;
  }

  .topbar,
  .morning-brief {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  .segmented {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }

  .metric-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .line-card-head,
  .line-stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .line-stat-grid .wide {
    grid-column: span 2;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 24px;
  }

  .metric-band {
    grid-template-columns: 1fr;
  }
}
