:root {
  color-scheme: light;
  --bg: #f8f3f7;
  --surface: #ffffff;
  --surface-soft: #f5edf5;
  --border: #e4d6e5;
  --text: #2b2230;
  --muted: #786a7d;
  --brand: #8f5fa8;
  --brand-strong: #673f7a;
  --brand-soft: #f0e2f2;
  --accent: #c98556;
  --warning: #b56b36;
  --danger: #b44d55;
  --danger-bg: #fff0f2;
  --ok-bg: #edf8f1;
  --warn-bg: #fff5e9;
  --watch-bg: #fff9e8;
  --shadow: 0 18px 45px rgba(82, 49, 94, 0.12);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #fff9f5 0%, var(--bg) 58%, #f8f3f7 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.page-heading,
.demo-panel,
.highlight-panel,
.form-panel,
.records-panel,
.dashboard-panel,
.publish-footer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.page-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: center;
  padding: 30px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.32rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.lead {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.7;
}

.notice {
  padding: 16px;
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbf4ff 0%, var(--surface-soft) 100%);
  color: var(--brand-strong);
  font-weight: 700;
  line-height: 1.55;
}

.hero-side {
  display: grid;
  gap: 12px;
  align-self: stretch;
  align-content: center;
}

.contact-card {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid #b7e8c7;
  border-radius: 8px;
  background: #f3fff7;
}

.contact-card span,
.contact-lines span,
.contact-lines a {
  color: var(--muted);
  font-weight: 800;
}

.contact-card strong {
  display: block;
  margin-top: 6px;
  color: #0b7c37;
  font-size: 1.04rem;
  line-height: 1.35;
}

.contact-card strong a {
  color: inherit;
  text-decoration: none;
}

.hero-proof {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.hero-proof span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.hero-proof strong {
  display: block;
  color: var(--text);
  line-height: 1.5;
}

.hero-copy {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.7;
}

.demo-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 22px;
  margin-bottom: 18px;
}

.highlight-panel {
  padding: 22px;
  margin-bottom: 18px;
}

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

.highlight-card {
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff 0%, #fbf6fb 100%);
}

.highlight-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--brand-strong);
  font-size: 1.05rem;
}

.highlight-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.demo-panel p:not(.eyebrow),
.section-header p,
.dashboard-panel p {
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 0;
}

.demo-actions,
.export-actions,
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.primary-button {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(143, 95, 168, 0.24);
}

.primary-button:hover {
  background: var(--brand-strong);
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.accent-button {
  background: var(--accent);
  color: #fff;
}

.danger-ghost-button {
  border: 1px solid #f0b6ae;
  background: var(--danger-bg);
  color: var(--danger);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 15px;
  background: #fff;
  color: var(--brand-strong);
  font-weight: 800;
  text-decoration: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-grid.expanded {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat-card {
  min-height: 128px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--brand-strong);
  font-size: 2.18rem;
  line-height: 1;
}

.alert-card strong {
  color: var(--warning);
}

.danger-card strong {
  color: var(--danger);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.dashboard-panel,
.form-panel,
.records-panel {
  padding: 22px;
  margin-bottom: 18px;
}

.section-header {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-header.compact {
  margin-bottom: 12px;
}

.summary-list,
.stack-list,
.alert-list {
  display: grid;
  gap: 10px;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) repeat(3, auto);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.summary-row strong {
  color: var(--text);
}

.low-text {
  color: var(--warning);
  font-weight: 800;
}

.out-text {
  color: var(--danger);
  font-weight: 800;
}

.alert-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid #efc66f;
  border-radius: 8px;
  background: var(--warn-bg);
}

.alert-item.out {
  border-color: #f0b6ae;
  background: var(--danger-bg);
}

.alert-item strong {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

.alert-item strong span {
  color: var(--danger);
}

.alert-item p,
.alert-item small {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.inspection-form {
  display: grid;
  gap: 16px;
}

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

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: #34423d;
  font-size: 0.9rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

input:disabled {
  background: #f2f5f3;
  color: var(--muted);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 107, 87, 0.13);
}

.full-field {
  grid-column: 1 / -1;
}

.filter-panel {
  display: grid;
  grid-template-columns: 140px 170px 150px minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  margin-bottom: 16px;
}

.filter-panel.restock-filter {
  grid-template-columns: minmax(150px, 1fr) minmax(170px, 1fr) 140px auto;
}

.compact-input {
  width: min(180px, 100%);
  min-height: 40px;
}

.wide-filter {
  min-width: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  background: #fff;
}

.compact-table table {
  min-width: 860px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--brand-soft);
  color: #4b3557;
  font-size: 0.9rem;
  white-space: nowrap;
}

td {
  color: #26352f;
  line-height: 1.5;
}

tr.low-row {
  background: #fffaf0;
}

tr.watch-row {
  background: #fffdf5;
}

.stock-number {
  font-weight: 900;
}

.table-subtext {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 68px;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-normal {
  background: var(--ok-bg);
  color: #116149;
}

.status-low {
  background: var(--warn-bg);
  color: var(--warning);
}

.status-watch {
  background: var(--watch-bg);
  color: #8a6122;
}

.status-out,
.status-replenish {
  background: #ffe8e5;
  color: #9f1f17;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.row-actions button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.86rem;
}

.empty-state {
  display: none;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.stack-item {
  display: grid;
  gap: 5px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.stack-item.purchase {
  border-color: #b8d8c9;
  background: #f4fbf7;
}

.stack-item.variance {
  border-color: #efc66f;
  background: #fffaf0;
}

.stack-item.defect {
  border-color: #b8cef8;
  background: #f4f7ff;
}

.stack-item strong {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  line-height: 1.4;
}

.stack-item small,
.stack-item span {
  color: var(--muted);
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #17211d;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.toast.error {
  background: var(--danger);
}

.publish-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 22px;
}

.publish-footer h2 {
  margin-bottom: 8px;
}

.publish-footer h2 a {
  color: var(--brand-strong);
  text-decoration: none;
}

.publish-footer p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.contact-lines {
  display: flex;
  gap: 10px 18px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

.contact-lines a {
  color: var(--brand-strong);
  text-decoration: none;
}

.footer-contact-side {
  display: flex;
  justify-content: flex-end;
}

.publish-footer-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.batch-list {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.batch-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.batch-heading {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
}

.batch-heading h3 {
  margin-bottom: 4px;
}

.batch-heading p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.actual-stock-input,
.difference-reason-input {
  min-width: 120px;
}

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

  .stats-grid.expanded {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field-grid,
  .filter-panel,
  .highlight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .page-heading,
  .demo-panel,
  .dashboard-grid,
  .highlight-grid,
  .alert-item,
  .publish-footer {
    grid-template-columns: 1fr;
  }

  .hero-side {
    align-content: stretch;
  }

  .publish-footer-actions {
    justify-content: flex-start;
  }

  .batch-heading {
    display: grid;
  }

  .alert-item button {
    width: fit-content;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 12px;
  }

  .page-heading,
  .demo-panel,
  .highlight-panel,
  .form-panel,
  .records-panel,
  .dashboard-panel,
  .publish-footer {
    padding: 16px;
  }

  .stats-grid,
  .highlight-grid,
  .field-grid,
  .filter-panel,
  .filter-panel.restock-filter,
  .summary-row {
    grid-template-columns: 1fr;
  }

  .section-header,
  .demo-actions,
  .export-actions,
  .form-actions,
  .footer-contact-side,
  .publish-footer-actions {
    display: grid;
    justify-content: stretch;
  }

  button,
  .link-button {
    width: 100%;
  }
}
