/* ============================================
   DESIGN SYSTEM — Warm Industrial + Gold Accent
   ============================================ */
:root {
  --bg-base: #0F1117;
  --bg-raised: #181B24;
  --bg-surface: #1E2230;
  --bg-hover: #262A38;
  --border: #2A2E3D;
  --border-light: #353A4D;
  --text-primary: #E8E9ED;
  --text-secondary: #9499A8;
  --text-muted: #5F6478;
  --accent: #E8C872;
  --accent-dim: #C4A44E;
  --accent-glow: rgba(232, 200, 114, 0.12);
  --accent-glow-strong: rgba(232, 200, 114, 0.25);
  --success: #6ECB8B;
  --danger: #E87272;
  --info: #72A8E8;
  --purple: #A78BFA;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Noto Sans SC', sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(232,200,114,0.04), transparent),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(114,168,232,0.03), transparent);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

/* ===== HEADER ===== */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0; border-bottom: 1px solid var(--border); gap: 16px; flex-wrap: wrap;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo-mark { display: flex; align-items: center; animation: logoSpin 8s linear infinite; }
@keyframes logoSpin { 0%,100%{transform:rotate(0deg)} 25%{transform:rotate(2deg)} 75%{transform:rotate(-2deg)} }
.header-title h1 { font-family:var(--font-display); font-size:1.5rem; font-weight:700; letter-spacing:-0.02em; color:var(--text-primary); line-height:1.2; }
.header-subtitle { font-family:var(--font-display); font-size:0.75rem; font-weight:400; color:var(--text-muted); letter-spacing:0.08em; text-transform:uppercase; }
.header-right { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }

/* Month Selector */
.month-selector { display:flex; align-items:center; background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-md); overflow:hidden; }
.month-nav { background:none; border:none; color:var(--text-secondary); padding:8px 12px; cursor:pointer; font-size:0.75rem; transition:var(--transition); }
.month-nav:hover { background:var(--bg-hover); color:var(--accent); }
.month-display { font-family:var(--font-display); font-weight:600; font-size:0.9rem; color:var(--text-primary); padding:8px; min-width:120px; text-align:center; border-left:1px solid var(--border); border-right:1px solid var(--border); }

/* Buttons */
.btn-upload,.btn-download-tpl { display:flex; align-items:center; gap:6px; padding:8px 16px; border:1px solid var(--accent-dim); background:var(--accent-glow); color:var(--accent); border-radius:var(--radius-md); cursor:pointer; font-family:var(--font-body); font-size:0.85rem; font-weight:500; transition:var(--transition); }
.btn-upload:hover,.btn-download-tpl:hover { background:var(--accent-glow-strong); box-shadow:0 0 20px rgba(232,200,114,0.15); transform:translateY(-1px); }
.btn-download-tpl { border-color:var(--border-light); background:var(--bg-surface); color:var(--text-secondary); }
.btn-download-tpl:hover { border-color:var(--text-muted); color:var(--text-primary); background:var(--bg-hover); box-shadow:none; }

/* ===== STAFF BAR ===== */
.staff-bar { margin-top:16px; padding:12px 16px; background:var(--bg-raised); border:1px solid var(--border); border-radius:var(--radius-md); min-height:48px; }
.staff-bar-empty { display:flex; align-items:center; gap:8px; color:var(--text-muted); font-size:0.85rem; }
.staff-bar-stats { display:flex; align-items:center; gap:20px; flex-wrap:wrap; }
.stat-item { display:flex; align-items:center; gap:6px; font-size:0.82rem; color:var(--text-secondary); }
.stat-dot { width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.stat-dot.total { background:var(--accent); }
.stat-dot.male { background:var(--info); }
.stat-dot.female { background:#E872B8; }
.stat-dot.groups { background:var(--purple); }
.stat-value { font-family:var(--font-display); font-weight:600; color:var(--text-primary); }

/* ===== TABS ===== */
.tab-bar { display:flex; gap:4px; margin-top:20px; border-bottom:1px solid var(--border); padding-bottom:0; }
.tab { display:flex; align-items:center; gap:6px; padding:12px 20px; background:none; border:none; color:var(--text-muted); font-family:var(--font-body); font-size:0.9rem; font-weight:500; cursor:pointer; border-bottom:2px solid transparent; transition:var(--transition); margin-bottom:-1px; }
.tab:hover { color:var(--text-secondary); }
.tab.active { color:var(--accent); border-bottom-color:var(--accent); }
.tab-icon { font-size:1.05rem; }

/* ===== ACTION BAR ===== */
.action-bar { display:flex; align-items:center; justify-content:space-between; padding:16px 0; gap:12px; flex-wrap:wrap; }
.action-left,.action-right { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.btn-action { display:flex; align-items:center; gap:6px; padding:9px 18px; border:1px solid var(--border); background:var(--bg-surface); color:var(--text-secondary); border-radius:var(--radius-md); cursor:pointer; font-family:var(--font-body); font-size:0.85rem; font-weight:500; transition:var(--transition); }
.btn-action:hover:not(:disabled) { background:var(--bg-hover); border-color:var(--border-light); color:var(--text-primary); transform:translateY(-1px); }
.btn-action:disabled { opacity:0.35; cursor:not-allowed; }
.btn-generate { background:var(--accent); border-color:var(--accent); color:#0F1117; font-weight:600; }
.btn-generate:hover:not(:disabled) { background:#F0D58A; border-color:#F0D58A; color:#0F1117; box-shadow:0 0 24px rgba(232,200,114,0.3); }
.btn-undo { border-color:var(--danger); color:var(--danger); background:rgba(232,114,114,0.06); }
.btn-undo:hover:not(:disabled) { background:rgba(232,114,114,0.14); }
.btn-clear { border-color:var(--text-muted); color:var(--text-muted); background:rgba(95,100,120,0.06); }
.btn-clear:hover:not(:disabled) { background:rgba(95,100,120,0.14); color:var(--text-secondary); border-color:var(--text-secondary); }
.btn-delete-tab { border-color:var(--danger); color:var(--danger); background:rgba(232,114,114,0.06); }
.btn-delete-tab:hover:not(:disabled) { background:rgba(232,114,114,0.14); }
.btn-export { border-color:var(--success); color:var(--success); background:rgba(110,203,139,0.06); }
.btn-export:hover:not(:disabled) { background:rgba(110,203,139,0.14); }

/* ===== PANELS ===== */
.content { margin-top:4px; }
.panel { display:none; }
.panel.active { display:block; animation:panelIn 0.3s ease; }
@keyframes panelIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.panel-info { display:flex; align-items:center; gap:10px; padding:12px 16px; background:var(--bg-raised); border:1px solid var(--border); border-radius:var(--radius-md); font-size:0.82rem; color:var(--text-muted); margin-bottom:16px; flex-wrap:wrap; }
.info-badge { padding:3px 10px; background:var(--accent-glow); border:1px solid rgba(232,200,114,0.2); border-radius:20px; color:var(--accent); font-size:0.72rem; font-weight:600; white-space:nowrap; }

/* ===== RULE PANEL ===== */
.btn-toggle-rules {
  margin-left: auto;
  padding: 5px 14px;
  border: 1px solid var(--purple);
  background: rgba(167,139,250,0.08);
  color: var(--purple);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-toggle-rules:hover {
  background: rgba(167,139,250,0.18);
  transform: translateY(-1px);
}

.rule-summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-panel {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  overflow: hidden;
  animation: panelIn 0.3s ease;
}

.rule-panel-inner {
  padding: 20px;
}

.rule-section {
  margin-bottom: 20px;
}

.rule-section:last-of-type {
  margin-bottom: 16px;
}

.rule-section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.rule-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.rule-col {
  flex: 1;
  min-width: 180px;
}

.rule-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.checkbox-item:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.checkbox-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.checkbox-item input[type="checkbox"]:checked + span {
  color: var(--accent);
}

.no-options {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.rule-row-params {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.rule-param {
  flex: 1;
  min-width: 160px;
}

.param-input-group {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: fit-content;
}

.param-btn {
  width: 36px;
  height: 36px;
  background: var(--bg-hover);
  border: none;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.param-btn:hover {
  background: var(--accent-glow-strong);
  color: var(--accent);
}

.param-value {
  width: 40px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 6px 0;
}

.param-toggle-group {
  display: flex;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: fit-content;
}

.param-toggle {
  padding: 7px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border-right: 1px solid var(--border);
}

.param-toggle:last-child {
  border-right: none;
}

.param-toggle.active {
  background: var(--accent);
  color: #0F1117;
  font-weight: 600;
}

.param-toggle:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.param-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

.rule-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ===== SCHEDULE GRID ===== */
.schedule-grid { overflow-x:auto; border:1px solid var(--border); border-radius:var(--radius-lg); background:var(--bg-raised); }
.schedule-grid::-webkit-scrollbar { height:6px; }
.schedule-grid::-webkit-scrollbar-track { background:var(--bg-raised); }
.schedule-grid::-webkit-scrollbar-thumb { background:var(--border-light); border-radius:3px; }
.schedule-table { width:100%; border-collapse:collapse; font-size:0.82rem; }
.schedule-table th { position:sticky; top:0; background:var(--bg-surface); color:var(--text-muted); font-weight:500; padding:10px 8px; text-align:center; border-bottom:1px solid var(--border); font-size:0.75rem; letter-spacing:0.03em; white-space:nowrap; }
.schedule-table td { padding:8px 6px; text-align:center; border-bottom:1px solid rgba(42,46,61,0.5); vertical-align:middle; transition:background var(--transition); }
.schedule-table tr:hover td { background:rgba(232,200,114,0.03); }
.schedule-table tr:last-child td { border-bottom:none; }
.day-num { font-family:var(--font-display); font-weight:600; font-size:0.9rem; color:var(--text-primary); min-width:32px; display:inline-block; }
.day-week { font-size:0.72rem; color:var(--text-muted); margin-left:4px; }
.rest-badge { display:inline-block; padding:2px 8px; background:rgba(232,114,114,0.1); border:1px solid rgba(232,114,114,0.2); border-radius:12px; color:var(--danger); font-size:0.72rem; font-weight:500; }
.staff-name { display:inline-block; padding:3px 10px; background:var(--bg-surface); border:1px solid var(--border); border-radius:6px; color:var(--text-primary); font-size:0.78rem; font-weight:500; transition:var(--transition); border-left:4px solid transparent; }
.staff-name.male { border-color:rgba(114,168,232,0.3); background:rgba(114,168,232,0.08); color:var(--info); }
.staff-name.female { border-color:rgba(232,114,184,0.3); background:rgba(232,114,184,0.08); color:#E872B8; }
.staff-name.group-a { border-left:3px solid var(--accent); }
.staff-name.group-b { border-left:3px solid var(--info); }
.staff-name.group-c { border-left:3px solid var(--success); }
.staff-name.group-d { border-left:3px solid var(--purple); }
.empty-grid { padding:60px 20px; text-align:center; color:var(--text-muted); font-size:0.9rem; }
.empty-grid svg { display:block; margin:0 auto 16px; opacity:0.3; }

/* Night sub-tabs */
.night-sub-tabs { display:flex; gap:4px; margin-bottom:12px; border-bottom:1px solid var(--border); padding-bottom:0; }
.night-sub-tab { display:flex; align-items:center; gap:6px; padding:10px 20px; background:none; border:none; color:var(--text-muted); font-family:var(--font-body); font-size:0.85rem; font-weight:500; cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; transition:var(--transition); }
.night-sub-tab:hover { color:var(--text-secondary); }
.night-sub-tab.active[data-nighttab="male"] { color:var(--info); border-bottom-color:var(--info); }
.night-sub-tab.active[data-nighttab="female"] { color:#E872B8; border-bottom-color:#E872B8; }

/* ===== CONFIRM / HISTORY BUTTONS ===== */
.btn-confirm { border-color:#E8C872; color:#E8C872; background:rgba(232,200,114,0.08); }
.btn-confirm:hover:not(:disabled) { background:rgba(232,200,114,0.18); box-shadow:0 0 16px rgba(232,200,114,0.2); }

/* ===== HISTORY ===== */
.history-list { display:flex; flex-direction:column; gap:8px; }
.history-empty { padding:60px 20px; text-align:center; color:var(--text-muted); font-size:0.9rem; }
.history-card { display:flex; align-items:center; justify-content:space-between; padding:14px 18px; background:var(--bg-raised); border:1px solid var(--border); border-radius:var(--radius-md); cursor:pointer; transition:var(--transition); gap:12px; flex-wrap:wrap; }
.history-card:hover { border-color:var(--border-light); background:var(--bg-surface); }
.history-card-left { display:flex; align-items:center; gap:14px; flex:1; min-width:0; }
.history-month { font-family:var(--font-display); font-weight:700; font-size:1rem; color:var(--text-primary); white-space:nowrap; }
.history-meta { display:flex; gap:10px; flex-wrap:wrap; }
.history-tag { padding:2px 10px; border-radius:12px; font-size:0.72rem; font-weight:500; border:1px solid; }
.history-tag.drink { color:var(--accent); border-color:rgba(232,200,114,0.3); background:rgba(232,200,114,0.08); }
.history-tag.night { color:var(--info); border-color:rgba(114,168,232,0.3); background:rgba(114,168,232,0.08); }
.history-tag.taste { color:var(--success); border-color:rgba(110,203,139,0.3); background:rgba(110,203,139,0.08); }
.history-card-right { display:flex; align-items:center; gap:8px; flex-shrink:0; }
.history-date { font-size:0.75rem; color:var(--text-muted); }
.history-locked-badge { display:inline-flex; align-items:center; gap:4px; padding:3px 10px; background:rgba(232,200,114,0.1); border:1px solid rgba(232,200,114,0.25); border-radius:12px; color:var(--accent); font-size:0.72rem; font-weight:600; }
.history-version-badge { display:inline-flex; align-items:center; gap:4px; padding:3px 10px; background:rgba(167,139,250,0.1); border:1px solid rgba(167,139,250,0.25); border-radius:12px; color:var(--purple); font-size:0.72rem; font-weight:600; }
.history-detail { animation:panelIn 0.3s ease; }
.history-detail-header { display:flex; align-items:center; justify-content:space-between; padding:14px 0; gap:12px; flex-wrap:wrap; }
.history-detail-title { font-family:var(--font-display); font-weight:700; font-size:1.1rem; color:var(--text-primary); }
.history-detail-actions { display:flex; gap:8px; flex-wrap:wrap; }
.btn-back { border-color:var(--border-light); color:var(--text-secondary); }
.btn-back:hover:not(:disabled) { color:var(--text-primary); }
.btn-delete-history { border-color:var(--danger); color:var(--danger); background:rgba(232,114,114,0.06); }
.btn-delete-history:hover:not(:disabled) { background:rgba(232,114,114,0.14); }

/* Sub-tab for history detail */
.history-sub-tabs { display:flex; gap:4px; margin-bottom:12px; border-bottom:1px solid var(--border); padding-bottom:0; }
.history-sub-tab { padding:8px 16px; background:none; border:none; color:var(--text-muted); font-family:var(--font-body); font-size:0.82rem; font-weight:500; cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; transition:var(--transition); }
.history-sub-tab:hover { color:var(--text-secondary); }
.history-sub-tab.active { color:var(--accent); border-bottom-color:var(--accent); }

/* ===== MODAL ===== */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.6); display:flex; align-items:center; justify-content:center; z-index:9998; animation:fadeIn 0.2s ease; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.modal-box { background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:28px; max-width:420px; width:90%; box-shadow:var(--shadow-lg); animation:panelIn 0.3s ease; }
.modal-title { font-family:var(--font-display); font-weight:700; font-size:1.1rem; color:var(--text-primary); margin-bottom:12px; }
.modal-text { font-size:0.85rem; color:var(--text-secondary); line-height:1.6; margin-bottom:20px; }
.modal-actions { display:flex; gap:10px; justify-content:flex-end; }
.modal-actions .btn-action { min-width:80px; justify-content:center; }

/* ===== TOAST ===== */
.toast-container { position:fixed; top:20px; right:20px; z-index:9999; display:flex; flex-direction:column; gap:8px; }
.toast { padding:12px 20px; background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-md); color:var(--text-primary); font-size:0.85rem; box-shadow:var(--shadow-lg); animation:toastIn 0.3s ease; max-width:360px; }
.toast.success { border-left:3px solid var(--success); }
.toast.error { border-left:3px solid var(--danger); }
.toast.info { border-left:3px solid var(--info); }
@keyframes toastIn { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }

/* ===== STAFF MANAGEMENT ===== */
.staff-mgmt-actions { display:flex; align-items:center; gap:10px; margin-bottom:16px; flex-wrap:wrap; }
.staff-mgmt-btns { display:flex; gap:8px; margin-left:auto; }
.staff-search-bar { display:flex; align-items:center; gap:8px; padding:7px 14px; background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-md); color:var(--text-muted); min-width:180px; transition:var(--transition); }
.staff-search-bar:focus-within { border-color:var(--accent); box-shadow:0 0 0 2px var(--accent-glow); }
.staff-search-input { background:none; border:none; outline:none; color:var(--text-primary); font-family:var(--font-body); font-size:0.85rem; width:100%; }
.staff-search-input::placeholder { color:var(--text-muted); }
.staff-filter-select { padding:8px 12px; background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-md); color:var(--text-secondary); font-family:var(--font-body); font-size:0.82rem; cursor:pointer; outline:none; transition:var(--transition); -webkit-appearance:none; appearance:none; background-image:url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239499A8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 10px center; padding-right:28px; }
.staff-filter-select:focus { border-color:var(--accent); }
.staff-count-bar { padding:8px 16px; text-align:right; font-size:0.75rem; color:var(--text-muted); }
.staff-mgmt-grid { overflow-x:auto; border:1px solid var(--border); border-radius:var(--radius-lg); background:var(--bg-raised); }
.staff-table th:last-child,.staff-table td:last-child { min-width:100px; }
.staff-table th,.staff-table td { white-space:nowrap; }
.action-cell { display:flex; gap:6px; justify-content:center; }
.btn-sm { padding:4px 10px; border:1px solid var(--border); background:var(--bg-surface); color:var(--text-secondary); border-radius:var(--radius-sm); cursor:pointer; font-family:var(--font-body); font-size:0.72rem; font-weight:500; transition:var(--transition); }
.btn-sm:hover { background:var(--bg-hover); color:var(--text-primary); }
.btn-sm.btn-edit { border-color:rgba(114,168,232,0.4); color:var(--info); }
.btn-sm.btn-edit:hover { background:rgba(114,168,232,0.12); }
.btn-sm.btn-del { border-color:rgba(232,114,114,0.4); color:var(--danger); }
.btn-sm.btn-del:hover { background:rgba(232,114,114,0.12); }
.gender-badge { display:inline-block; padding:2px 8px; border-radius:12px; font-size:0.72rem; font-weight:500; }
.gender-badge.male { background:rgba(114,168,232,0.1); border:1px solid rgba(114,168,232,0.25); color:var(--info); }
.gender-badge.female { background:rgba(232,114,184,0.1); border:1px solid rgba(232,114,184,0.25); color:#E872B8; }
.btn-staff-mgmt { margin-left:auto; padding:5px 14px; border:1px solid var(--accent-dim); background:var(--accent-glow); color:var(--accent); border-radius:var(--radius-sm); cursor:pointer; font-family:var(--font-body); font-size:0.78rem; font-weight:500; transition:var(--transition); }
.btn-staff-mgmt:hover { background:var(--accent-glow-strong); transform:translateY(-1px); }

/* Modal Form Styles */
.modal-form { max-width:480px; }
.modal-form-body { display:flex; flex-direction:column; gap:12px; margin-bottom:20px; }
.form-label { display:flex; flex-direction:column; gap:4px; font-size:0.82rem; color:var(--text-secondary); font-weight:500; }
.form-input { padding:8px 12px; background:var(--bg-raised); border:1px solid var(--border); border-radius:var(--radius-sm); color:var(--text-primary); font-family:var(--font-body); font-size:0.85rem; outline:none; transition:var(--transition); }
.form-input:focus { border-color:var(--accent); box-shadow:0 0 0 2px rgba(232,200,114,0.1); }
.form-input::placeholder { color:var(--text-muted); }

/* Cycle highlight styles */
.cycle-highlight td { background:rgba(167,139,250,0.12)!important; border-left:2px solid var(--purple); }
.cycle-highlight td:first-child { border-left:3px solid var(--purple); }
.cycle-name-highlight { outline:2px solid var(--purple); outline-offset:1px; background:rgba(167,139,250,0.18)!important; box-shadow:0 0 8px rgba(167,139,250,0.25); }
.cycle-legend { display:flex; align-items:center; gap:8px; padding:8px 16px; margin-bottom:8px; font-size:0.78rem; color:var(--purple); background:rgba(167,139,250,0.06); border:1px solid rgba(167,139,250,0.2); border-radius:var(--radius-md); }
.cycle-legend-dot { width:10px; height:10px; border-radius:50%; background:var(--purple); flex-shrink:0; }
.btn-cycle { border-color:var(--purple); color:var(--purple); background:rgba(167,139,250,0.06); }
.btn-cycle:hover:not(:disabled) { background:rgba(167,139,250,0.16); }
.btn-cycle.active { background:var(--purple); color:#0F1117; border-color:var(--purple); }

/* Share image button */
.btn-share-img { border-color:#E872B8; color:#E872B8; background:rgba(232,114,184,0.06); }
.btn-share-img:hover:not(:disabled) { background:rgba(232,114,184,0.14); box-shadow:0 0 16px rgba(232,114,184,0.15); }

/* Image generation overlay */
.img-gen-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.7); display:flex; align-items:center; justify-content:center; z-index:9998; animation:fadeIn 0.2s ease; }
.img-gen-box { background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:24px; max-width:90vw; max-height:90vh; overflow:auto; box-shadow:var(--shadow-lg); }
.img-gen-box img { max-width:100%; border-radius:var(--radius-md); border:1px solid var(--border); }
.img-gen-actions { display:flex; gap:10px; justify-content:flex-end; margin-top:16px; }

/* ===== DYNAMIC FILTERS ===== */
.staff-dynamic-filters { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }

/* ===== DASHBOARD EXPAND/COLLAPSE ===== */
.cat-expand-header { user-select:none; }
.cat-expand-header:hover { opacity:0.85; }
.cat-expand-header:hover .cat-expand-arrow { color:var(--accent) !important; }
.cat-detail-panel { animation:panelIn 0.2s ease; }

/* ===== BATCH DELETE ===== */
.staff-table .batch-cb { accent-color:var(--accent); width:16px; height:16px; cursor:pointer; }
.batch-select-all { accent-color:var(--accent); width:16px; height:16px; cursor:pointer; }

/* ===== DASHBOARD ===== */
.dashboard-stats-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(200px, 1fr)); gap:14px; margin-bottom:24px; }
.dash-stat-card { background:var(--bg-raised); border:1px solid var(--border); border-radius:var(--radius-lg); padding:18px 20px; transition:var(--transition); }
.dash-stat-card:hover { border-color:var(--border-light); background:var(--bg-surface); transform:translateY(-2px); box-shadow:var(--shadow-md); }
.dash-stat-card .stat-label { font-size:0.78rem; color:var(--text-muted); margin-bottom:8px; font-weight:500; }
.dash-stat-card .stat-number { font-family:var(--font-display); font-size:1.8rem; font-weight:700; color:var(--accent); line-height:1; }
.dash-stat-card .stat-sub { font-size:0.72rem; color:var(--text-secondary); margin-top:6px; }

.dash-section { margin-bottom:28px; }
.dash-section-title { font-family:var(--font-display); font-weight:700; font-size:1.05rem; color:var(--text-primary); margin-bottom:14px; padding-bottom:8px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:8px; }
.dash-section-title .title-icon { font-size:1.1rem; }

.dash-category-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(280px, 1fr)); gap:14px; }
.dash-category-card { background:var(--bg-raised); border:1px solid var(--border); border-radius:var(--radius-lg); padding:16px; }
.dash-category-card .cat-title { font-weight:600; font-size:0.88rem; color:var(--text-primary); margin-bottom:10px; display:flex; align-items:center; justify-content:space-between; }
.dash-category-card .cat-count { font-family:var(--font-display); font-weight:700; color:var(--accent); font-size:1rem; }
.dash-category-card .cat-bar { height:6px; background:var(--bg-surface); border-radius:3px; margin-bottom:8px; overflow:hidden; }
.dash-category-card .cat-bar-fill { height:100%; border-radius:3px; transition:width 0.5s ease; }
.dash-category-card .cat-names { font-size:0.75rem; color:var(--text-secondary); line-height:1.6; }
.dash-category-card .cat-name-tag { display:inline-block; padding:2px 8px; background:var(--bg-surface); border:1px solid var(--border); border-radius:4px; margin:2px; font-size:0.72rem; color:var(--text-secondary); }

/* Custom analytics */
.dash-custom-area { background:var(--bg-raised); border:1px solid var(--border); border-radius:var(--radius-lg); padding:20px; }
.dash-custom-header { display:flex; align-items:center; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.dash-custom-header label { font-size:0.85rem; color:var(--text-secondary); font-weight:500; }
.dash-custom-select { padding:8px 14px; background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius-md); color:var(--text-primary); font-family:var(--font-body); font-size:0.85rem; cursor:pointer; outline:none; transition:var(--transition); min-width:140px; }
.dash-custom-select:focus { border-color:var(--accent); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-shell { padding:0 12px 24px; }
  .app-header { padding:14px 0; }
  .header-title h1 { font-size:1.2rem; }
  .header-right { width:100%; justify-content:flex-start; }
  .tab { padding:10px 14px; font-size:0.82rem; }
  .action-bar { flex-direction:column; align-items:stretch; }
  .action-left,.action-right { justify-content:center; }
  .btn-action { flex:1; justify-content:center; min-width:0; }
  .schedule-table { font-size:0.75rem; }
  .staff-name { padding:2px 6px; font-size:0.72rem; }
  .staff-mgmt-actions { flex-direction:column; align-items:stretch; }
  .staff-mgmt-btns { margin-left:0; justify-content:center; }
  .staff-search-bar { min-width:0; }
  .staff-filter-select { flex:1; }
  .rule-row { flex-direction:column; }
  .rule-row-params { flex-direction:column; }
  .dashboard-stats-grid { grid-template-columns:repeat(auto-fill, minmax(140px, 1fr)); }
  .dash-category-grid { grid-template-columns:1fr; }
}

/* Custom tab add button */
.tab-add { color:var(--text-muted); font-size:1.1rem; padding:12px 14px; min-width:auto; }
.tab-add:hover { color:var(--accent); }

/* Tab arrow buttons — always visible, compact pill controls */
.tab-controls { display:inline-flex; align-items:center; gap:3px; margin-left:8px; vertical-align:middle; }
.tab-ctrl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 4px;
  background: var(--bg-surface); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.6rem; cursor: pointer;
  transition: var(--transition); line-height: 1; padding: 0;
  flex-shrink: 0; user-select: none;
}
.tab-ctrl-btn:hover:not(.disabled) { color: var(--accent); background: var(--accent-glow); border-color: rgba(232,200,114,0.3); }
.tab-ctrl-btn.disabled { opacity: 0.25; cursor: default; pointer-events: none; }
.tab-ctrl-btn.tab-close-btn { color: var(--text-muted); font-size: 0.75rem; font-weight: 600; }
.tab-ctrl-btn.tab-close-btn:hover { color: var(--danger); background: rgba(232,114,114,0.12); border-color: rgba(232,114,114,0.3); }

/* Legacy class removal */
.tab-arrow-group { display:none !important; }

/* Continue next month button */
.btn-continue-month { display:flex; align-items:center; justify-content:center; gap:8px; width:100%; padding:14px; margin-top:12px; background:var(--bg-raised); border:1px dashed var(--accent-dim); border-radius:var(--radius-md); color:var(--accent); font-family:var(--font-body); font-size:0.88rem; font-weight:500; cursor:pointer; transition:var(--transition); }
.btn-continue-month:hover { background:var(--accent-glow); border-style:solid; transform:translateY(-1px); box-shadow:0 0 16px rgba(232,200,114,0.15); }
.month-separator { background:var(--accent-glow)!important; }
.month-separator td { padding:10px!important; text-align:center!important; font-weight:600; color:var(--accent)!important; font-size:0.88rem; border-bottom:2px solid var(--accent-dim)!important; }

@media (max-width: 480px) {
  .tab-icon { display:none; }
  .month-display { min-width:90px; font-size:0.8rem; }
  .btn-upload span,.btn-download-tpl span { display:none; }
}

/* ===== DRAG & DROP ===== */
.staff-name[draggable="true"] { cursor: grab; }
.staff-name[draggable="true"]:active { cursor: grabbing; }
td.drag-over { background: var(--accent-glow-strong) !important; outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 4px; }

/* ===== TAB DRAG & DROP ===== */
.tab[draggable="true"] { cursor: grab; }
.tab[draggable="true"]:active { cursor: grabbing; }
.tab.dragging { opacity: 0.4; }
.tab.tab-drag-over { border-bottom-color: var(--accent); background: var(--accent-glow); }

/* ===== SUB-TAB BAR ===== */
.sub-tab-bar { display:flex; gap:4px; margin-bottom:12px; border-bottom:1px solid var(--border); padding-bottom:0; align-items:center; flex-wrap:wrap; }

/* ===== GROUP ORDER DRAG LIST ===== */
.group-order-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 8px;
}
.group-order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: var(--transition);
  user-select: none;
}
.group-order-item:active { cursor: grabbing; }
.group-order-item.dragging { opacity: 0.4; border-color: var(--accent); }
.group-order-item.drag-over-group { border-color: var(--accent); background: var(--accent-glow); }
.group-order-handle {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
}
.group-order-name {
  flex: 1;
  color: var(--text-primary);
  font-size: 0.9rem;
}
.group-order-pos {
  color: var(--text-secondary);
  font-size: 0.8rem;
  min-width: 28px;
  text-align: right;
}

/* ===== SKIP FIRST CYCLE STAFF ===== */
.skip-first-cycle-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.skip-staff-checkbox {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: var(--transition);
}
.skip-staff-checkbox:hover { border-color: var(--accent-dim); background: var(--bg-hover); }
.skip-staff-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

/* Shift Type Sections */
.shift-type-section {
  margin-top: 12px;
  margin-bottom: 12px;
  background: rgba(232, 200, 114, 0.03);
  border-radius: var(--radius-sm);
  padding: 12px;
}

/* ===== SCHEDULE STATISTICS — Redesigned ===== */
.schedule-stats {
  margin-top: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.schedule-stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
  gap: 12px;
}
.schedule-stats-header:hover { background: var(--bg-hover); }
.schedule-stats-header-left {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.schedule-stats-title {
  font-family: var(--font-display);
  font-weight: 700; font-size: 0.95rem; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.schedule-stats-title::before {
  content: ''; display: inline-block; width: 4px; height: 16px;
  background: var(--accent); border-radius: 2px;
}
.stats-collapse-arrow {
  font-size: 0.7rem; color: var(--text-muted);
  transition: transform 0.3s ease; display: inline-block;
}
.stats-collapse-arrow.collapsed { transform: rotate(-90deg); }
.schedule-stats-header-right {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.stats-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; background: var(--accent-glow);
  border: 1px solid rgba(232,200,114,0.2); border-radius: 20px;
  color: var(--accent); font-size: 0.72rem; font-weight: 600;
  font-family: var(--font-display);
}
.btn-export-stats {
  padding: 4px 12px; border: 1px solid var(--success);
  background: rgba(110,203,139,0.06); color: var(--success);
  border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font-body); font-size: 0.72rem; font-weight: 500;
  transition: var(--transition); display: flex; align-items: center; gap: 4px;
}
.btn-export-stats:hover { background: rgba(110,203,139,0.14); transform: translateY(-1px); }
.schedule-stats-body {
  overflow: hidden; transition: max-height 0.35s ease, opacity 0.25s ease;
}
.schedule-stats-body.collapsed { max-height: 0 !important; opacity: 0; }
.schedule-stats-summary {
  font-size: 0.78rem; color: var(--text-muted); padding: 12px 20px 0;
}
.schedule-stats-summary strong {
  color: var(--accent); font-family: var(--font-display);
}

/* Stats Table */
.schedule-stats-table-wrap { padding: 12px 16px 16px; overflow-x: auto; }
.schedule-stats-table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.82rem;
}
.schedule-stats-table thead th {
  position: sticky; top: 0; background: var(--bg-surface);
  color: var(--text-muted); font-weight: 600; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 12px; text-align: center; white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
.schedule-stats-table thead th:first-child,
.schedule-stats-table thead th:nth-child(2) { text-align: left; }
.schedule-stats-table tbody tr { transition: background var(--transition); }
.schedule-stats-table tbody tr:hover { background: rgba(232,200,114,0.03); }
.schedule-stats-table tbody td {
  padding: 9px 12px; text-align: center;
  border-bottom: 1px solid rgba(42,46,61,0.5); vertical-align: middle;
}
.schedule-stats-table tbody tr:last-child td { border-bottom: none; }
.stats-idx {
  font-family: var(--font-display); font-weight: 500; font-size: 0.75rem;
  color: var(--text-muted); text-align: left !important; width: 40px;
}
.stats-name-cell {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.8rem; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; transition: var(--transition);
}
.schedule-stats-table tbody tr:hover .stats-name-cell {
  border-color: var(--border-light); background: var(--bg-hover);
}
.stats-num {
  font-family: var(--font-display); font-weight: 600; font-size: 0.85rem;
  color: var(--text-secondary);
}
.stats-num.stats-total {
  color: var(--accent); font-weight: 700; font-size: 0.9rem;
}
.stats-footer td {
  border-top: 2px solid var(--border) !important;
  border-bottom: none !important;
  font-weight: 600; color: var(--text-primary);
  background: rgba(232,200,114,0.03); padding: 10px 12px;
}
.stats-footer td:nth-child(2) {
  text-align: left; color: var(--accent);
  font-family: var(--font-display); font-weight: 700;
}
.stats-footer .stats-num { color: var(--accent); }
.stats-footer .stats-total { font-size: 1rem; font-weight: 800; }

/* Rank indicators */
.stats-rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-family: var(--font-display); font-weight: 700; font-size: 0.68rem; flex-shrink: 0;
}
.stats-rank.rank-1 { background: linear-gradient(135deg, #FFD700, #FFA500); color: #1a1a1a; }
.stats-rank.rank-2 { background: linear-gradient(135deg, #C0C0C0, #A0A0A0); color: #1a1a1a; }
.stats-rank.rank-3 { background: linear-gradient(135deg, #CD7F32, #A0522D); color: #fff; }
.stats-rank.rank-other { background: var(--bg-hover); color: var(--text-muted); }

.stats-num-cell {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; padding: 3px 8px; border-radius: 4px;
  font-family: var(--font-display); font-weight: 600; font-size: 0.82rem;
  color: var(--text-muted);
}
.stats-num-cell.has-value { background: rgba(232,200,114,0.06); color: var(--text-primary); }
.stats-num-cell.total-cell {
  background: rgba(232,200,114,0.12); color: var(--accent);
  font-weight: 700; font-size: 0.88rem;
  border: 1px solid rgba(232,200,114,0.15); border-radius: 6px;
}

@media (max-width: 768px) {
  .schedule-stats-header { padding: 12px 14px; flex-wrap: wrap; }
  .schedule-stats-table-wrap { padding: 8px 10px 12px; }
  .schedule-stats-table { font-size: 0.75rem; }
  .stats-name-cell { padding: 3px 8px; font-size: 0.72rem; }
  .stats-rank { width: 18px; height: 18px; font-size: 0.6rem; }
  .schedule-stats-summary { padding: 10px 14px 0; }
}
