:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --ink: #1a1a1a;
  --ink-2: #4a4a4a;
  --ink-3: #888;
  --border: #e6e6e3;
  --border-strong: #d0d0cc;
  --accent: #0d6efd;
  --accent-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --muted: #f0f0ec;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

html { font-size: 16px; }
@media (max-width: 640px) { html { font-size: 17px; } }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans TC', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 700; margin: 0; }

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

input[type="text"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 16px;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  transition: all 0.12s;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: #0b5ed7; border-color: #0b5ed7; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--muted); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.muted { color: var(--ink-3); }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.spacer { flex: 1; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--muted);
  color: var(--ink-2);
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-active { background: #dbeafe; color: #1e40af; }

.tab {
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-2);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-3);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }
