:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --bg-card: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --primary: #2563eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --work: #1e3a5f;
  --weekend: #334155;
  --holiday: #7c2d12;
  --makeup: #166534;
  --radius: 12px;
  --shadow: 0 6px 20px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f1f5f9;
    --bg-soft: #ffffff;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-dim: #64748b;
    --work: #dbeafe;
    --weekend: #e2e8f0;
    --holiday: #fed7aa;
    --makeup: #bbf7d0;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-header {
  padding: 16px 20px; background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 40px; height: 40px; border-radius: 10px; }
.app-header h1 { font-size: 20px; margin: 0; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.header-tools { margin-top: 12px; }
.btn-group { display: flex; gap: 8px; }

button.btn {
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; transition: filter .15s;
}
button.btn:hover { filter: brightness(1.1); }
button.btn.btn-danger { background: var(--danger); }

select, input[type="number"], input[type="text"], input[type="date"] {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 14px;
}
input[type="color"] { width: 42px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); cursor: pointer; }

.tabs {
  display: flex; gap: 4px; padding: 10px 16px 0; overflow-x: auto;
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
  position: sticky; top: 73px; z-index: 9;
}
.tab {
  background: none; border: none; color: var(--text-dim);
  padding: 10px 16px; font-size: 14px; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }

main { padding: 18px 16px 60px; max-width: 960px; margin: 0 auto; }
.panel { display: none; animation: fade .2s; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.panel-head h2 { font-size: 17px; margin: 0 0 4px; }
.hint { font-size: 12px; color: var(--text-dim); margin: 0 0 14px; }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-top: 16px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; margin: 0 0 12px; }

.setting-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.setting-row label { font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 6px; }

.fleet-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.fleet-label { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
.fleet-info { font-size: 12px; color: var(--primary); font-weight: 600; }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-nav strong { font-size: 16px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px; color: var(--text-dim); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg::before { content: ""; width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.lg-work::before { background: #16a34a; }
.lg-weekend::before { background: var(--weekend); }
.lg-holiday::before { background: var(--holiday); }
.lg-makeup::before { background: #15803d; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 4px; min-height: 54px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 12px; user-select: none; transition: transform .08s;
}
.cal-cell:active { transform: scale(.96); }
.cal-cell .dnum { font-weight: 600; font-size: 13px; }
.cal-cell .dlabel { font-size: 10px; }
.cal-cell.t-work { background: transparent; }
.cal-cell.t-makeup { background: transparent; }
.cal-cell.t-weekend { background: var(--weekend); }
.cal-cell.t-holiday { background: var(--holiday); }
.cal-cell.editable { cursor: pointer; outline: 1px solid var(--warn); }
.cal-cell.editable:active { transform: scale(.96); }
.edit-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0; padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.edit-tip { font-size: 12px; color: var(--text-dim); }
button.btn.btn-warn { background: var(--warn); }

.schedule-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.sch-cell {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 4px; min-height: 52px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between; gap: 2px;
  font-size: 12px; user-select: none;
}
.sch-cell .dnum { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.shift-tag { font-size: 11px; font-weight: 600; padding: 2px 4px; border-radius: 5px; color: #fff; text-align: center; }
.shift-tag.rest { background: var(--weekend); color: var(--text-dim); }
.shift-tag.over { outline: 2px solid var(--warn); }
.dnote { font-size: 9px; color: var(--text-dim); align-self: flex-end; }

.month-std {
  margin-top: 14px; padding: 12px 14px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; display: flex; gap: 24px; flex-wrap: wrap;
}
.month-std b { color: var(--primary); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: center; }
th { color: var(--text-dim); font-weight: 600; background: var(--bg-soft); position: sticky; }
td.num { font-variant-numeric: tabular-nums; }
.cell-pos { color: var(--ok); font-weight: 600; }
.cell-neg { color: var(--danger); font-weight: 600; }

.compare-hint {
  background: var(--bg-card); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 16px;
  font-size: 13px; color: var(--warn);
}
.chart-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; overflow-x: auto; }
.chart-wrap svg { width: 100%; height: auto; display: block; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; padding: 10px 20px;
  border-radius: 24px; font-size: 14px; box-shadow: var(--shadow); z-index: 50;
}
