:root {
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-alt: #f4f8fb;
  --border: #d7e3ec;
  --text: #2c3e4a;
  --text-muted: #6b8296;
  --primary: #6f97b3;
  --primary-dark: #4f7791;
  --primary-light: #dce9f1;
  --success: #7fb69e;
  --danger: #c9807f;
  --warning: #d9ab6e;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(79, 119, 145, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary-dark); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  transition: background 0.15s;
}
button:hover { background: var(--primary-dark); }
button.secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--primary-light); }
button.danger { background: var(--danger); }
button.danger:hover { background: #b56a69; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
}
.sidebar .brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--surface-alt); color: var(--text); }
.sidebar nav a.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-left-color: var(--primary);
  font-weight: 600;
}
.sidebar .user-info {
  margin-top: 20px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.main-content { flex: 1; padding: 24px 32px; max-width: 1100px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; background: var(--surface-alt); }
tr:hover td { background: var(--surface-alt); }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary-dark);
}
.badge.warning { background: #f6e6d0; color: #96702e; }
.badge.danger { background: #f5dcdb; color: #96413f; }
.badge.muted { background: var(--surface-alt); color: var(--text-muted); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid.full { grid-template-columns: 1fr; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field label { font-size: 13px; color: var(--text-muted); }
.form-field textarea { resize: vertical; min-height: 60px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(44, 62, 74, 0.35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(44, 62, 74, 0.2);
}
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef3f7, #dbe8f0);
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(79, 119, 145, 0.15);
  padding: 40px;
  width: 380px;
}
.login-card h1 { font-size: 20px; color: var(--primary-dark); margin-bottom: 4px; }
.login-card p.subtitle { color: var(--text-muted); font-size: 13px; margin-top: 0; margin-bottom: 24px; }
.login-card .form-field { margin-bottom: 14px; }
.login-card input { width: 100%; }
.login-card button[type="submit"] { width: 100%; padding: 10px; margin-top: 8px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 8px; }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: #fff;
  padding: 12px 18px; border-radius: 8px;
  font-size: 14px; box-shadow: var(--shadow);
  z-index: 100;
}
.toast.error { background: var(--danger); }

.empty-state { text-align: center; color: var(--text-muted); padding: 40px 0; }
.text-muted { color: var(--text-muted); }
.pagination { display: flex; gap: 8px; align-items: center; margin-top: 16px; justify-content: flex-end; }
