* { box-sizing: border-box; }

:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #16213a;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #4ade80;
  --morning: #fbbf24;
  --afternoon: #38bdf8;
  --night: #818cf8;
  --off: #475569;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.3rem; margin: 0; }
.save-indicator { font-size: 0.8rem; color: var(--muted); }

.layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px;
  overflow-y: auto;
}
.sidebar h2 { font-size: 0.95rem; color: var(--accent); margin: 14px 0 8px; }
.sidebar hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.add-nurse-row { display: flex; gap: 6px; margin-bottom: 10px; }
.add-nurse-row input { flex: 1; min-width: 0; }

input[type="text"], input[type="number"], select {
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.nurse-list { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow-y: auto; }
.nurse-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
}
.nurse-list li:nth-child(odd) { background: rgba(255,255,255,0.03); }
.nurse-list li button {
  background: none;
  border: none;
  color: #f87171;
  cursor: pointer;
  font-size: 0.9rem;
}

.hint { font-size: 0.78rem; color: var(--muted); margin: 6px 0; }
.hint.small { font-size: 0.72rem; }

.shift-config label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.shift-config input { width: 60px; text-align: center; }

.month-config { display: flex; gap: 8px; margin-bottom: 12px; }
.month-config select { flex: 1.4; }
.month-config input { flex: 1; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 6px;
}
.btn-primary { background: #4ade80; color: #0f172a; }
.btn-success { background: #22c55e; color: #08240f; }
.btn-danger { background: #f87171; color: #2a0a0a; }
.btn-secondary { background: #334155; color: var(--text); }
.full-width { width: 100%; }

.main {
  flex: 1;
  padding: 18px 24px;
  overflow: auto;
}

.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.tag {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #0f172a;
}
.shift-เช้า { background: var(--morning); }
.shift-บ่าย { background: var(--afternoon); }
.shift-ดึก { background: var(--night); color: #fff; }
.shift-off { background: var(--off); color: #fff; }
.legend-note { font-size: 0.78rem; color: var(--muted); margin-left: 8px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.82rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  text-align: center;
  white-space: nowrap;
}
thead th {
  background: var(--panel-2);
  position: sticky;
  top: 0;
}
tbody th {
  background: var(--panel);
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
}
.weekend-col { background: rgba(248,113,113,0.08); }

select.cell-select {
  width: 64px;
  padding: 2px;
  font-size: 0.78rem;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  text-align: center;
  font-weight: 600;
}
select.cell-select.เช้า { background: var(--morning); color: #0f172a; }
select.cell-select.บ่าย { background: var(--afternoon); color: #0f172a; }
select.cell-select.ดึก { background: var(--night); color: #fff; }
select.cell-select.off { background: var(--off); color: #fff; }

.summary-wrap { margin-top: 22px; }
.summary-wrap h3 { font-size: 0.95rem; color: var(--accent); margin-bottom: 8px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--border); }
}
