:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-soft: #243247;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.22);
  --blue: #38bdf8;
  --indigo: #6366f1;
  --danger: #fb7185;
  --green: #4ade80;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 32rem),
    linear-gradient(135deg, #020617 0%, var(--bg) 52%, #111827 100%);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0;
}

.logo {
  display: grid;
  flex: 0 0 3.25rem;
  width: 3.25rem;
  height: 3.25rem;
  place-items: center;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  color: white;
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 0 0 34px rgba(56, 189, 248, 0.35);
}

.brand-kicker,
.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--blue);
  font-size: 0.78rem;
  letter-spacing: 0;
}

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: 0; }
h1 { font-size: clamp(1.05rem, 2.4vw, 1.65rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.8rem); }
h3 { font-size: 1.05rem; }

.page-shell {
  width: min(1280px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.main-tabs, .sub-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(30, 41, 59, 0.7);
  overflow-x: auto;
}

.main-tab, .sub-tab, .primary-btn {
  min-height: 2.65rem;
  border: 0;
  border-radius: 0.55rem;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.main-tab, .sub-tab {
  flex: 1;
  padding: 0.7rem 1rem;
  background: transparent;
}

.main-tab.active, .sub-tab.active, .primary-btn {
  background: linear-gradient(135deg, #2563eb, var(--indigo));
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.24);
}

.page-panel, .sub-panel { display: none; }
.page-panel.active, .sub-panel.active { display: block; }

.page-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(30, 41, 59, 0.72);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.section-head, .mail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.primary-btn { padding: 0 1rem; }

.dropzone {
  display: grid;
  min-height: 9.5rem;
  place-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 1.25rem;
  border: 1px dashed rgba(56, 189, 248, 0.75);
  border-radius: 0.8rem;
  background: rgba(15, 23, 42, 0.72);
  text-align: center;
  cursor: pointer;
  transition: 0.2s ease;
}

.dropzone.dragging {
  border-color: white;
  background: rgba(37, 99, 235, 0.18);
}

.dropzone input { display: none; }
.dropzone-title { font-size: 1.05rem; font-weight: 800; }
.dropzone-text { color: var(--muted); font-size: 0.92rem; }

.table-wrap, .chart-box, .mail-panel {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.58);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; min-width: 720px; }

th, td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.92rem;
}

th { color: #bfdbfe; background: rgba(30, 41, 59, 0.88); }
tr:hover td { background: rgba(56, 189, 248, 0.06); }
.empty-cell { color: var(--muted); text-align: center; }

.dashboard-grid { grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr); gap: 1rem; }
.dashboard-grid.active { display: grid; }
.chart-box { min-height: 390px; padding: 1rem; }

.mail-panel { padding: 1rem; }

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.9rem;
  color: var(--text);
  background: var(--panel-soft);
  line-height: 1.7;
}

.danger-text { color: var(--danger); font-weight: 900; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  transform: translateY(150%);
  padding: 0.75rem 1rem;
  border: 1px solid rgba(56, 189, 248, 0.38);
  border-radius: 0.65rem;
  background: #082f49;
  color: white;
  opacity: 0;
  transition: 0.22s ease;
  z-index: 200;
}

.toast.show { transform: translateY(0); opacity: 1; }

/* ================================================================
   模組三 - 便當訂購管理
================================================================ */

.bento-subsidy-badge {
  background: rgba(56,189,248,0.12);
  border: 1px solid rgba(56,189,248,0.35);
  border-radius: 0.5rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
  color: var(--blue);
  margin: 0;
}

.bento-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.bento-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
  position: relative;
}

.bento-card-tag {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--blue);
  text-transform: uppercase;
}

.bento-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.bento-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.bento-input {
  font-family: inherit;
  flex: 1;
  min-width: 80px;
  padding: 0.55rem 0.7rem;
  font-size: 0.84rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--panel-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.bento-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(56,189,248,0.18); }
.bento-input[type=number] { flex: 0 0 auto; width: 120px; }
.bento-input[type=date],
.bento-input[type=month] { flex: 0 0 auto; min-width: 155px; color-scheme: dark; }

.bento-file-input { font-size: 0.78rem; color: var(--muted); }

.bento-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.bento-outline-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(148,163,184,0.4);
  border-radius: 0.45rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.bento-outline-btn:hover {
  background: rgba(56,189,248,0.1);
  border-color: var(--blue);
  color: var(--blue);
}

.bento-chip-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 140px;
  overflow-y: auto;
  margin-top: 6px;
}

.bento-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  font-family: "JetBrains Mono", monospace;
}

.bento-chip-remove {
  background: transparent;
  border: 1px solid rgba(251,113,133,0.5);
  border-radius: 0.3rem;
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  cursor: pointer;
  transition: background 0.15s;
}

.bento-chip-remove:hover { background: var(--danger); color: #fff; }

/* Legend */
.bento-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.bento-legend span { display: flex; align-items: center; gap: 5px; }

.bento-dot {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
}

.bento-dot.meat { background: var(--danger); }
.bento-dot.veg  { background: var(--green); }
.bento-dot.none { background: rgba(148,163,184,0.45); }

/* Toolbar */
.bento-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

/* Bento Table */
.bento-table-wrap {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.58);
  overflow: auto;
  max-height: 60vh;
}

.bento-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 700px;
  font-size: 0.82rem;
}

.bento-table thead th {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.98);
  color: #bfdbfe;
  font-weight: 600;
  letter-spacing: 0.02em;
  z-index: 3;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  text-align: center;
  cursor: default;
}

.bento-table thead th.sortable { cursor: pointer; }
.bento-table thead th.sortable:hover { color: var(--blue); }
.bento-table .sort-arrow { font-size: 0.68rem; margin-left: 3px; color: var(--blue); }

.bento-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
  color: var(--text);
  background: transparent;
}

.bento-table tbody tr:nth-child(even) td { background: rgba(30,41,59,0.35); }
.bento-table tbody tr:hover td { background: rgba(56,189,248,0.07); }

/* Sticky fixed columns */
.bento-table .bc-id,
.bento-table .bc-name,
.bento-table .bc-dept {
  position: sticky;
  background: rgba(15, 23, 42, 0.96);
  z-index: 2;
  text-align: left;
}

.bento-table .bc-id   { left: 0;     min-width: 88px; }
.bento-table .bc-name { left: 88px;  min-width: 88px; font-weight: 700; }
.bento-table .bc-dept { left: 176px; min-width: 88px; color: var(--muted); box-shadow: 2px 0 0 var(--line); }

.bento-table thead th.bc-id,
.bento-table thead th.bc-name,
.bento-table thead th.bc-dept {
  background: rgba(10, 18, 36, 0.99);
  z-index: 4;
}

.bento-table tfoot td {
  position: sticky;
  bottom: 0;
  background: rgba(10, 18, 36, 0.98);
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.6rem 0.8rem;
  border-top: 1px solid var(--line);
}

.bento-table .bento-date-head { display: flex; flex-direction: column; gap: 1px; align-items: center; }
.bento-table .bento-date-d { font-size: 0.8rem; font-family: "JetBrains Mono", monospace; }
.bento-table .bento-date-cost { font-size: 0.66rem; color: var(--muted); }
.bento-table .bento-date-del { color: rgba(251,113,133,0.6); font-size: 0.66rem; cursor: pointer; margin-left: 4px; }
.bento-table .bento-date-del:hover { color: var(--danger); }

/* Status select */
select.bento-status {
  font-family: inherit;
  width: 62px;
  font-size: 0.74rem;
  padding: 4px 2px;
  text-align: center;
  border-radius: 0.35rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  outline: none;
}

select.bento-status[data-v="葷"] {
  background: rgba(251,113,133,0.15);
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 700;
}

select.bento-status[data-v="素"] {
  background: rgba(74,222,128,0.12);
  border-color: var(--green);
  color: var(--green);
  font-weight: 700;
}

.bento-slot-pair { display: flex; gap: 4px; justify-content: center; }

.bento-cost-cell {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  color: var(--blue);
}

.bento-table .bento-empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

/* ── Modals ── */
.b-modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.b-modal-mask.show { display: flex; }

.b-modal-box {
  background: var(--panel);
  border: 1px solid rgba(56,189,248,0.3);
  border-radius: 0.8rem;
  max-width: 780px;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  box-shadow: 0 30px 70px rgba(0,0,0,0.6);
  padding: 20px 22px;
}

.b-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.b-modal-head h3 { font-size: 1.1rem; color: var(--text); }

.b-modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 4px;
}

/* Month grid */
.b-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}

.b-month-grid .b-dow {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  padding-bottom: 2px;
}

.b-day-cell {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 5px 4px 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
}

.b-day-cell.weekend { opacity: 0.55; }
.b-day-cell.exists { border-color: rgba(56,189,248,0.6); background: rgba(56,189,248,0.08); }

.b-day-cell .b-dnum { font-family: "JetBrains Mono", monospace; font-size: 0.76rem; color: var(--muted); }
.b-day-cell .b-dw   { font-size: 0.64rem; color: rgba(148,163,184,0.6); margin-top: -3px; }

.b-day-cell input {
  width: 100%;
  text-align: center;
  padding: 4px 2px;
  font-size: 0.76rem;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.b-day-cell.exists input { color: var(--blue); font-weight: 700; }

/* Confirm box */
.b-confirm-box {
  background: var(--panel);
  border: 1px solid rgba(251,113,133,0.3);
  border-radius: 0.75rem;
  max-width: 340px;
  width: 100%;
  padding: 22px 20px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

.b-confirm-box p { font-size: 0.9rem; line-height: 1.7; margin: 0 0 16px; color: var(--text); }
.b-confirm-actions { display: flex; gap: 10px; justify-content: center; }

.b-danger-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--danger);
  border-radius: 0.45rem;
  background: var(--danger);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.b-danger-btn:hover { background: #e11d48; }

/* Responsive */
@media (max-width: 900px) {
  .bento-panels { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .brand { align-items: flex-start; }

  .section-head, .mail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .main-tabs, .sub-tabs { flex-direction: column; }
  .dashboard-grid.active { display: block; }
  .chart-box { min-height: 320px; }
  table { min-width: 640px; }
}
