/* YECO 深色版面（參考稿重繪：純 CSS，零外部依賴） */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: #070d18;
  background-image:
    radial-gradient(rgba(6, 182, 212, 0.08) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 24px 24px, 48px 48px, 48px 48px;
  color: #e2e8f0;
  min-height: 100vh;
  padding-bottom: 48px;
}
[hidden] { display: none !important; }

/* ---------- 頂部 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11, 21, 40, 0.96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(6, 182, 212, 0.22);
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 14px; max-width: 1280px; margin: 0 auto; }
.logo {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(45deg, #0891b2, #2563eb, #4338ca);
  border: 1px solid rgba(165, 243, 252, 0.4);
  box-shadow: 0 0 18px rgba(6, 182, 212, 0.35);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge {
  font-size: 10px; letter-spacing: 0.1em; padding: 2px 8px; border-radius: 4px;
  font-weight: 600; font-family: ui-monospace, monospace;
}
.badge-cyan { background: rgba(8, 51, 68, 0.85); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.4); }
.badge-mode { background: #1e293b; color: #94a3b8; border: 1px solid #334155; }
body.logged-in .badge-mode { background: rgba(120, 53, 15, 0.9); color: #fbbf24; border-color: rgba(245, 158, 11, 0.5); }
.badge-date { background: rgba(2, 6, 23, 0.8); color: #67e8f9; border: 1px solid rgba(6, 182, 212, 0.3); font-weight: 400; }
.brand h1 {
  margin: 4px 0 1px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  background: linear-gradient(90deg, #fff, #cffafe, #22d3ee);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle { margin: 0; font-size: 11.5px; color: #94a3b8; }
.top-actions {
  max-width: 1280px; margin: 8px auto 0; display: flex; gap: 8px;
  justify-content: flex-end; align-items: center; flex-wrap: wrap;
}
@media (min-width: 900px) {
  .brand { padding-right: 420px; }
  .top-actions { position: absolute; right: 16px; top: 12px; margin: 0; max-width: none; }
  .topbar { position: sticky; }
}
.admin-tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 按鈕 ---------- */
.btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid #334155;
  background: #1e293b; color: #e2e8f0; font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; min-height: 38px; font-family: inherit;
}
.btn:hover { background: #334155; border-color: #475569; }
.btn-primary {
  background: linear-gradient(90deg, #06b6d4, #2563eb); border: none; color: #020617;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.35);
}
.btn-primary:hover { filter: brightness(1.12); background: linear-gradient(90deg, #06b6d4, #2563eb); }
.btn-danger { background: rgba(190, 18, 60, 0.8); border-color: #be123c; color: #fff; }
.btn-danger:hover { background: #be123c; }
.btn-ghost { background: transparent; border-color: #1e293b; color: #94a3b8; min-height: 32px; padding: 5px 10px; font-size: 12px; }
.btn-ghost:hover { color: #22d3ee; border-color: #164e63; background: rgba(6, 182, 212, 0.06); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 主區 ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 16px; }

.panel {
  background: rgba(11, 21, 40, 0.92);
  border: 1px solid rgba(6, 182, 212, 0.22);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(6, 182, 212, 0.1);
  padding: 14px;
  margin-bottom: 16px;
}

/* KPI 卡 */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: rgba(11, 21, 40, 0.92); border: 1px solid rgba(6, 182, 212, 0.22);
  border-radius: 14px; padding: 14px 16px; display: flex; justify-content: space-between;
  align-items: center; box-shadow: inset 0 0 0 1px rgba(6, 182, 212, 0.12);
}
.kpi-label { margin: 0; font-size: 11px; color: #94a3b8; letter-spacing: 0.08em; text-transform: uppercase; }
.kpi-label.kpi-cyan { color: #22d3ee; }
.kpi-label.kpi-rose { color: #fb7185; }
.kpi-label.kpi-emerald { color: #34d399; }
.kpi h3 { margin: 4px 0 0; font-size: 26px; font-weight: 800; font-family: ui-monospace, monospace; }
.t-cyan { color: #22d3ee; } .t-rose { color: #fb7185; } .t-emerald { color: #34d399; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 19px;
}
.kpi-icon-blue { background: rgba(59, 130, 246, 0.12); border: 1px solid rgba(59, 130, 246, 0.3); }
.kpi-icon-cyan { background: rgba(6, 182, 212, 0.12); border: 1px solid rgba(6, 182, 212, 0.3); }
.kpi-icon-rose { background: rgba(244, 63, 94, 0.12); border: 1px solid rgba(244, 63, 94, 0.3); }
.kpi-icon-emerald { background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.3); }

/* tabs + filters */
.controls { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 1000px) { .controls { flex-direction: row; justify-content: space-between; align-items: center; } }
.tabs { display: flex; background: rgba(2, 6, 23, 0.8); border: 1px solid #1e293b; border-radius: 10px; padding: 4px; gap: 2px; }
.tab {
  flex: 1; padding: 8px 16px; border: none; background: transparent; color: #94a3b8;
  font-size: 12.5px; font-weight: 700; border-radius: 8px; cursor: pointer; font-family: inherit;
}
.tab:hover { color: #67e8f9; }
.tab.active { background: #06b6d4; color: #020617; box-shadow: 0 0 12px rgba(6, 182, 212, 0.4); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.searchbox { position: relative; display: flex; align-items: center; }
.searchbox span { position: absolute; left: 10px; font-size: 12px; opacity: 0.6; }
.searchbox input { padding-left: 32px; }
input, select, textarea {
  background: rgba(2, 6, 23, 0.85); border: 1px solid #1e293b; color: #e2e8f0;
  border-radius: 8px; padding: 9px 12px; font-size: 13px; font-family: inherit; outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: #06b6d4; }
input::placeholder, textarea::placeholder { color: #475569; }
select { cursor: pointer; }
textarea { resize: vertical; }
input[readonly], input:disabled, input:disabled + * { opacity: 0.75; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.task-table { width: 100%; border-collapse: collapse; min-width: 1080px; font-size: 12.5px; }
.task-table thead tr {
  background: rgba(2, 6, 23, 0.9); color: #94a3b8;
  font-family: ui-monospace, monospace; font-size: 11px; letter-spacing: 0.05em;
}
.task-table th, .task-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid rgba(30, 41, 59, 0.7); }
.task-table tbody tr:hover { background: rgba(6, 182, 212, 0.05); }
.task-table .col-check { width: 36px; }
.task-table .col-title { min-width: 220px; }
.task-table .col-ops { width: 150px; text-align: center; }
.task-code { color: #22d3ee; font-family: ui-monospace, monospace; font-weight: 700; white-space: nowrap; }
.task-title { color: #f1f5f9; font-weight: 600; }
.task-notes { display: block; color: #64748b; font-size: 11px; margin-top: 2px; }
.due-over { color: #fb7185; font-weight: 700; }
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px;
  font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.chip-cat { background: #1e293b; color: #cbd5e1; border-color: #334155; }
.prio-critical { background: rgba(127, 29, 29, 0.6); color: #fecaca; border-color: #b91c1c; }
.prio-high { background: rgba(120, 53, 15, 0.6); color: #fde68a; border-color: #b45309; }
.prio-medium { background: rgba(30, 58, 138, 0.6); color: #bfdbfe; border-color: #1d4ed8; }
.prio-low { background: #1e293b; color: #cbd5e1; border-color: #475569; }
.st-notstarted { background: #1e293b; color: #cbd5e1; border-color: #475569; }
.st-inprogress { background: rgba(8, 51, 68, 0.9); color: #67e8f9; border-color: #0e7490; }
.st-review { background: rgba(120, 53, 15, 0.75); color: #fcd34d; border-color: #b45309; }
.st-done { background: rgba(6, 78, 59, 0.8); color: #6ee7b7; border-color: #059669; }
.mono { font-family: ui-monospace, monospace; font-size: 11.5px; color: #94a3b8; white-space: nowrap; }

/* 進度條 */
.progress { min-width: 90px; }
.progress-track { background: #1e293b; border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #06b6d4, #3b82f6); transition: width 0.3s; }
.progress-fill.done { background: linear-gradient(90deg, #10b981, #059669); }
.progress-num { font-family: ui-monospace, monospace; font-size: 10.5px; color: #94a3b8; margin-top: 2px; display: block; }

/* 行內操作 */
.ops { display: flex; gap: 5px; justify-content: center; }
.op-btn {
  min-height: 30px; padding: 4px 9px; font-size: 11.5px; border-radius: 7px;
  border: 1px solid #334155; background: #1e293b; color: #cbd5e1; cursor: pointer; font-family: inherit;
}
.op-btn:hover { border-color: #06b6d4; color: #67e8f9; }
.op-btn.op-del:hover { border-color: #be123c; color: #fda4af; background: rgba(190, 18, 60, 0.15); }

/* 批量列 */
.batch-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: rgba(8, 51, 68, 0.6); border: 1px solid rgba(6, 182, 212, 0.35);
  border-radius: 10px; padding: 8px 14px; margin-bottom: 10px; font-size: 12.5px; color: #a5f3fc;
}

.empty { padding: 40px; text-align: center; color: #64748b; font-size: 13.5px; }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 14px; font-size: 13px; color: #94a3b8; }
.pager .btn { min-height: 32px; padding: 5px 12px; }

/* 骨架視圖 */
.skeleton {
  padding: 46px 20px; text-align: center; color: #64748b;
  border: 1px dashed #1e293b; border-radius: 10px;
}
.skeleton-title { font-size: 17px; font-weight: 700; color: #94a3b8; margin: 0 0 6px; }

/* ---------- 右側滑出選單 ---------- */
.side-menu {
  position: fixed; top: 0; right: 0; z-index: 55; width: 232px; height: 100vh;
  background: #0b1528; border-left: 1px solid rgba(6, 182, 212, 0.35);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.55);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  transform: translateX(100%); transition: transform 0.25s ease;
}
.side-menu.open { transform: translateX(0); }
.side-head {
  display: flex; justify-content: space-between; align-items: center;
  color: #67e8f9; font-weight: 700; font-size: 13px; letter-spacing: 0.06em;
  padding-bottom: 10px; border-bottom: 1px solid #1e293b;
}
.side-close { background: none; border: none; color: #64748b; font-size: 15px; cursor: pointer; min-height: 32px; }
.side-close:hover { color: #fff; }
.side-item {
  text-align: left; padding: 11px 13px; border-radius: 9px; border: 1px solid #1e293b;
  background: rgba(2, 6, 23, 0.6); color: #cbd5e1; font-size: 13px; cursor: pointer; font-family: inherit;
}
.side-item:hover { border-color: #06b6d4; color: #67e8f9; background: rgba(6, 182, 212, 0.08); }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 14px; overflow-y: auto;
}
.modal-card {
  background: #0b1528; border: 1px solid rgba(6, 182, 212, 0.4); border-radius: 16px;
  width: 100%; max-width: 430px; padding: 22px; margin-bottom: 4vh;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}
.modal-lg { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-card h3 { margin: 0; font-size: 16px; color: #fff; }
.modal-x { background: none; border: none; color: #64748b; font-size: 17px; cursor: pointer; min-height: 34px; }
.modal-x:hover { color: #fff; }
.muted { color: #64748b; font-size: 12px; margin: 4px 0 12px; }
.modal-card label { display: block; font-size: 12px; color: #94a3b8; margin: 10px 0 4px; }
.modal-card label em { color: #fb7185; font-style: normal; }
.modal-card .hint { color: #475569; font-size: 11px; margin-left: 6px; }
.modal-card input, .modal-card select, .modal-card textarea { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid #1e293b; }
.alert {
  background: rgba(127, 29, 29, 0.35); border: 1px solid #b91c1c; color: #fecaca;
  padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-top: 10px;
}
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
.grid-3 .full { grid-column: 1 / -1; }
.grid-3 .align-end { display: flex; align-items: flex-end; }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr; } }
.progress-head { display: flex; justify-content: space-between; align-items: center; }
.progress-head b { color: #22d3ee; font-family: ui-monospace, monospace; }
input[type="range"] { padding: 0; accent-color: #06b6d4; height: 26px; }
.user-create { margin-bottom: 12px; }
.user-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 0; }
.user-table th, .user-table td { padding: 8px 10px; border-bottom: 1px solid #1e293b; text-align: left; }
.user-table th { color: #64748b; font-size: 11px; font-family: ui-monospace, monospace; }

/* toast */
#toastBox {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  background: #0f172a; color: #e2e8f0; border: 1px solid rgba(6, 182, 212, 0.5);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55); max-width: 88vw;
}
.toast.err { border-color: rgba(244, 63, 94, 0.6); color: #fecdd3; }

/* 認證狀態顯隱（JS toggle hidden；CSS 兜底） */
body:not(.logged-in) .auth-only { display: none !important; }