:root {
  --ink: #0B2E52;        /* 深藍色 - 標題/導覽 */
  --ink-soft: #163F6C;
  --paper: #F3F1EC;      /* 底色 */
  --card: #FFFFFF;
  --line: #DAD6CC;
  --amber: #E8A33D;      /* 安全警示琥珀色 - 主要行動色 */
  --amber-deep: #C77F1F;
  --ok: #2F7D5A;
  --warn: #B5482A;
  --text: #23262B;
  --text-mute: #6B7078;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(11,46,82,0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.topbar {
  background: var(--ink);
  color: #fff;
  padding: 16px 20px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: var(--shadow);
}
.topbar .brand {
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--amber);
  font-weight: 700;
}
.topbar h1 {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 700;
}
.topbar nav {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}
.topbar nav a {
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.topbar nav a.active, .topbar nav a:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

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

h2.section-title {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  margin: 0 0 14px;
  font-weight: 700;
}

label.field {
  display: block;
  margin-bottom: 16px;
}
label.field > span.label-text {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-soft);
}
label.field > span.req { color: var(--warn); }

input[type=text], input[type=date], input[type=number], input[type=password],
select, textarea {
  width: 100%;
  padding: 12px 12px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(232,163,61,0.25);
}
textarea { resize: vertical; min-height: 70px; }

.radio-row, .check-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  background: #fff;
  user-select: none;
}
.pill input { accent-color: var(--amber-deep); }
.pill.checked {
  border-color: var(--amber-deep);
  background: rgba(232,163,61,0.14);
  font-weight: 600;
}
.check-grid { flex-direction: column; }
.check-grid .pill { border-radius: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: filter .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--amber-deep); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-danger { background: var(--warn); color: #fff; }
.btn-sm { width: auto; padding: 8px 12px; font-size: 13px; }

.msg {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}
.msg.ok { background: rgba(47,125,90,0.12); color: var(--ok); }
.msg.err { background: rgba(181,72,42,0.12); color: var(--warn); }

table.stat {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.stat th, table.stat td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
table.stat th {
  color: var(--text-mute);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.stat tr:last-child td { border-bottom: none; }
table.stat td.num { text-align: right; font-variant-numeric: tabular-nums; }

.bar-track {
  background: var(--line);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-top: 4px;
}
.bar-fill { height: 100%; background: var(--amber-deep); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-head {
  font-size: 11px;
  text-align: center;
  color: var(--text-mute);
  padding: 4px 0;
  font-weight: 700;
}
.cal-cell {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px;
  font-size: 11px;
  background: #fff;
  cursor: pointer;
  position: relative;
}
.cal-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell .daynum { font-weight: 700; font-size: 12px; color: var(--text-mute); }
.cal-cell.today .daynum { color: var(--amber-deep); }
.cal-cell .tag {
  display: block;
  background: rgba(232,163,61,0.22);
  color: var(--amber-deep);
  border-radius: 4px;
  padding: 1px 4px;
  margin-top: 2px;
  font-size: 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.month-nav .cur { font-weight: 700; font-size: 16px; }
.month-nav button {
  background: none; border: 1.5px solid var(--line); border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer; font-size: 16px;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(27,36,48,0.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; width: 100%; max-width: 640px; border-radius: 16px 16px 0 0;
  padding: 20px; max-height: 80vh; overflow-y: auto;
}
@media (min-width: 700px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 16px; }
}

.footer-note {
  text-align: center; color: var(--text-mute); font-size: 12px; margin-top: 20px;
}

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--ink); color: #fff; font-size: 12px;
  padding: 4px 10px; border-radius: 999px;
  display: flex; align-items: center; gap: 6px;
}
.chip button { background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer; font-size: 12px; }

.order-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  background: #F5F5F3; margin-bottom: 6px;
}
.order-arrows { display: flex; gap: 4px; }
.order-arrows button {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid #DDD;
  background: #fff; cursor: pointer; font-size: 13px; line-height: 1;
}
.order-arrows button:disabled { opacity: 0.3; cursor: not-allowed; }
.order-name { flex: 1; font-size: 14px; }
.order-remove {
  border: none; background: none; color: #C0392B; font-size: 12px; cursor: pointer; padding: 4px 6px;
}

.status-badge {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; white-space: nowrap; font-weight: 600;
}
.status-pending { background: #FDF0DC; color: #B4690E; }
.status-approved { background: #E1F3E6; color: #1E7A3E; }
.status-rejected { background: #FBE4E4; color: #B33A3A; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px; overflow-y: auto; z-index: 100;
}
.modal-box {
  background: #fff; border-radius: 16px; padding: 24px;
  width: 100%; max-width: 520px; margin-top: 20px;
}
.record-row {
  border-bottom: 1px solid #EEE; padding: 10px 0; font-size: 14px;
}
.record-row .record-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.record-row .record-actions { display: flex; gap: 6px; }
.record-row .record-actions button {
  border: 1px solid #DDD; background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.record-row .record-note { color: #6B7078; font-size: 13px; margin-top: 4px; }
