:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #164e63;
  --primary-2: #0f766e;
  --accent: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select { font: inherit; }

#app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 290px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 18px;
  color: white;
  background: linear-gradient(160deg, #0f172a, #164e63 55%, #115e59);
  overflow-y: auto;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,.16);
}
.brand-block strong { display: block; font-size: 17px; }
.brand-block span { color: rgba(255,255,255,.7); font-size: 12px; }
.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #0f172a;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  box-shadow: 0 10px 26px rgba(245, 158, 11, .28);
}

.nav-list { display: grid; gap: 5px; }
.nav-item {
  width: 100%;
  min-height: 43px;
  border: 0;
  border-radius: 12px;
  color: rgba(255,255,255,.82);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  text-align: left;
  cursor: pointer;
  transition: .18s ease;
}
.nav-item i { width: 20px; text-align: center; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.14); color: #fff; }
.nav-item.disabled { opacity: .35; cursor: not-allowed; }

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.11);
  color: rgba(255,255,255,.85);
  font-size: 13px;
  line-height: 1.5;
}

.content-area {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--primary-2);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .05em;
}
#page-title { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.input, .input-select {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  color: var(--text);
  outline: none;
}
.input:focus, .input-select:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }

.btn {
  min-height: 40px;
  border: 0;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: white;
  background: var(--primary);
  cursor: pointer;
  transition: .18s ease;
  margin-left: 8px;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(22,78,99,.18); }
.btn.ghost { margin-left: 0; color: var(--primary); background: #e6f6f3; }
.btn.disabled, .btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.link-btn {
  border: 0;
  color: var(--primary-2);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.view-root { display: grid; gap: 18px; }
.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-header h2 { margin: 0; font-size: 20px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 16px;
}
.metric-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: var(--shadow);
}
.metric-card > i {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
}
.metric-card.blue > i { background: #164e63; }
.metric-card.green > i { background: #0f766e; }
.metric-card.orange > i { background: #f59e0b; }
.metric-card.red > i { background: #dc2626; }
.metric-card span { display: block; color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin-top: 3px; font-size: 23px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.status-list p { margin: 12px 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #475569; background: #f8fafc; font-size: 13px; white-space: nowrap; }
td { font-size: 14px; }
tr:last-child td { border-bottom: 0; }
small { color: var(--muted); }
code { padding: 3px 6px; border-radius: 7px; background: #f1f5f9; color: #334155; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.ok { color: #047857; background: #d1fae5; }
.badge.pending { color: #b45309; background: #fef3c7; }
.badge.locked { color: #4338ca; background: #e0e7ff; }
.badge.draft { color: #475569; background: #e2e8f0; }
.badge.warn { color: #b91c1c; background: #fee2e2; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}
.detail-grid label {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}
.detail-grid span { color: var(--text); font-weight: 700; line-height: 1.5; }
.masked { display: inline-flex; align-items: center; gap: 6px; }
.hint { color: var(--muted) !important; font-weight: 500 !important; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar .input { min-width: 260px; }

.calendar-demo {
  display: grid;
  grid-template-columns: repeat(7, minmax(105px, 1fr));
  gap: 9px;
}
.day-cell {
  min-height: 105px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdff;
}
.day-cell strong { display: block; margin-bottom: 7px; }
.day-cell span {
  display: block;
  margin: 5px 0;
  padding: 5px 7px;
  border-radius: 8px;
  color: #075985;
  background: #e0f2fe;
  font-size: 12px;
}

.report-cards, .permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(200px, 1fr));
  gap: 16px;
}
.report-cards article, .permission-grid article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fafc;
}
.report-cards i { color: var(--primary-2); font-size: 26px; }
.report-cards h3, .permission-grid h3 { margin: 10px 0 8px; }
.report-cards p, .permission-grid p { color: var(--muted); line-height: 1.6; }
.permission-grid span { color: var(--primary); font-weight: 800; }

.settings-list { display: grid; gap: 12px; }
.settings-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px;
  border-radius: 14px;
  background: #f8fafc;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 30px;
  border: 1px dashed #cbd5e1;
  border-radius: 22px;
  background: white;
}
.empty-state i { font-size: 54px; color: var(--primary-2); }
.empty-state p { max-width: 520px; color: var(--muted); line-height: 1.7; }
.text-red { color: var(--danger); }

#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 14px;
  color: white;
  background: #0f766e;
  box-shadow: 0 16px 42px rgba(15, 23, 42, .22);
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: .2s ease;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.warning { background: #b45309; }
#toast.error { background: #b91c1c; }

@media (max-width: 1180px) {
  #app-shell { grid-template-columns: 230px 1fr; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .detail-grid, .report-cards, .permission-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  #app-shell { display: block; }
  .sidebar { position: relative; height: auto; border-radius: 0 0 24px 24px; }
  .nav-list { grid-template-columns: repeat(2, 1fr); }
  .content-area { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .calendar-demo { grid-template-columns: repeat(2, 1fr); }
  #page-title { font-size: 24px; }
}
