:root {
  --bg: #f5f7fb;
  --bg-accent: #eef4ff;
  --admin-bg: #fff9f0;
  --admin-header: #fff0d6;
  --panel: #ffffff;
  --line: #dbe4f3;
  --text: #1b2430;
  --muted: #5b6b7f;
  --brand: #0d5bcd;
  --brand-2: #0a3f8c;
  --danger: #c91f37;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans TC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 90% -10%, #d8e7ff 0%, transparent 55%),
    radial-gradient(900px 460px at -10% 0%, #e4f5ff 0%, transparent 52%),
    var(--bg);
}

.hero {
  padding: 24px 28px 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: 0.3px;
}

.build-tag {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 0 28px 28px;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
}

.view-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.view-tab {
  background: transparent;
  color: var(--brand-2);
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 16px 12px 14px;
  font-size: 14px;
  font-weight: 700;
}

.view-tab.active {
  background: transparent;
  color: #ef5f74;
  border-bottom-color: #ef5f74;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.view-panel {
  width: 100%;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 24px #0d5bcd10;
  padding: 20px;
}

h2 {
  margin: 0 0 16px;
  font-size: 16px;
}

/* ── Form ── */
.form-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--brand);
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-panel {
  max-width: 920px;
  margin: 0 auto;
}

.dashboard-panel {
  padding: 24px;
  margin: 0 auto;
  width: 100%;
  max-width: 1180px;
}

.table-panel {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 18px;
}

.dashboard-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 30px;
  line-height: 1;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
}

.mini-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: #fff;
}

.mini-panel-head {
  margin-bottom: 12px;
}

.mini-panel h3 {
  margin: 0;
  font-size: 15px;
}

.summary-list,
.recent-list {
  display: grid;
  gap: 10px;
}

.summary-row,
.recent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fbff;
}

.summary-name,
.recent-main {
  font-size: 13px;
  font-weight: 700;
}

.summary-count,
.recent-meta {
  font-size: 12px;
  color: var(--muted);
}

.recent-copy {
  display: grid;
  gap: 3px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

input, select, textarea, button { font: inherit; }

input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
}

textarea {
  resize: vertical;
  margin-top: 4px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

button {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}

button:hover { opacity: 0.88; }

button.ghost {
  background: #fff;
  color: var(--brand-2);
  border: 1px solid var(--line);
}

button.danger {
  background: var(--danger);
  padding: 5px 10px;
  font-size: 12px;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.toolbar-actions { display: flex; gap: 8px; }

/* ── Sync banner ── */
.sync-banner {
  margin: 0 0 10px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}
.sync-banner.ok  { border-color: #b7e3c8; background: #effcf4; color: #186a3b; }
.sync-banner.warn{ border-color: #f0d9a7; background: #fff8e9; color: #8a5a00; }
.sync-banner.err { border-color: #f4b5bf; background: #fff1f4; color: #9f1239; }

/* ── Table ── */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: calc(100vh - 220px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: var(--bg-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  z-index: 1;
}

td { background: #fff; }

tr:hover td { background: #f8faff; }

th.admin-col { background: var(--admin-header); }
td.admin-col { background: #fffdf7; }
tr:hover td.admin-col { background: #fff8e8; }

.status-select {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.status-pending { background: #e8eeff; color: #3a5cc7; }
.status-in-progress { background: #e0f7ea; color: #1a6e3c; }
.status-completed { background: #d4edda; color: #155724; }

/* Assignee select */
.assignee-select {
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  min-width: 80px;
}

/* Appointment date */
.appt-input {
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  min-width: 120px;
}

.comments-cell {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-columns { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .layout { padding: 0 16px 20px; }
  .hero { padding: 20px 16px 12px; }
  .view-switch { overflow: auto; }
}
