:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --ink: #17211c;
  --muted: #68736d;
  --line: #dce5df;
  --primary: #216e55;
  --primary-strong: #15513f;
  --accent: #e7b84d;
  --danger: #b42318;
  --danger-bg: #fff0ed;
  --info-bg: #edf6f2;
  --shadow: 0 14px 34px rgba(22, 39, 31, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar,
.section-heading,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding: 16px 0 22px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

h1 {
  font-size: clamp(1.55rem, 4vw, 2.4rem);
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.05rem;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.7fr);
  gap: 16px;
  align-items: start;
}

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

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

.login-panel {
  min-height: 320px;
}

.compact {
  box-shadow: none;
}

.form-stack,
.grid-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.grid-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(33, 110, 85, 0.14);
}

.primary,
.ghost,
.icon-btn,
.segmented button,
.tabs button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

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

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

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 999px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 4px 14px rgba(20, 40, 30, 0.08);
}

.wide {
  width: 100%;
  min-height: 56px;
  font-size: 1.05rem;
}

.segmented,
.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: #e8eee9;
  border-radius: 8px;
  margin-top: 18px;
  overflow-x: auto;
}

.segmented button,
.tabs button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.segmented button.active,
.tabs button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(20, 40, 30, 0.08);
}

.section-heading {
  margin: 6px 0 16px;
}

.metric-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  padding: 16px;
}

.metric span,
.muted,
.record-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1.65rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--primary);
  font-weight: 800;
}

.work-list,
.record-list,
.table-list {
  display: grid;
  gap: 10px;
}

.table-list {
  padding: 10px;
  margin-bottom: 14px;
}

.row,
.work-item,
.record-item {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.work-item.completed {
  background: #f0f6f3;
}

.work-item.completed strong,
.work-item.completed .task-check span span:not(.warning-text) {
  color: var(--muted);
  text-decoration: line-through;
}

.task-check {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
}

.task-check input {
  width: 20px;
  min-height: 20px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.task-check > span {
  display: grid;
  gap: 7px;
}

.row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

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

.small-btn {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  font-weight: 800;
}

.danger {
  color: var(--danger);
  border-color: #f2b8b5;
  background: var(--danger-bg);
}

.warning-text {
  color: var(--danger);
  font-weight: 900;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  .login-layout,
  .grid-form {
    grid-template-columns: 1fr;
  }

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

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions button {
    flex: 1;
  }
}
