/* ================================================================
   HR System — Main Stylesheet
   Design: Industrial Precision / Dual Theme (Dark & Light)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Dark Theme (default) ────────────────────────────────────── */
:root,
[data-theme="dark"] {
--bg:       #18202d;
--surface:  #232e42;
--surface2: #2b3952;
--surface3: #334461;
--border:   #3e5070;
--border2:  #506891;

  --accent:   #3b82f6;
  --accent2:  #60a5fa;
  --accent-g: rgba(59,130,246,.14);
  --green:    #10b981;
  --red:      #ef4444;
  --yellow:   #f59e0b;
  --purple:   #8b5cf6;
  --pink:     #ec4899;
  --text:     #e2e8f0;
  --text2:    #94a3b8;
  --text3:    #5a6a84;
  --radius:   8px;
  --shadow:   0 4px 32px rgba(0,0,0,.5);
  --font:     'Sarabun', sans-serif;
  --mono:     'IBM Plex Mono', monospace;

  --theme-icon: '☀';
  --theme-label: 'สว่าง';

  color-scheme: dark;
}

/* ── Light Theme ─────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:       #f0f4f8;
  --surface:  #f7f7f7;
  --surface2: #e7e6e6;
  --surface3: #eef2f7;
  --border:   #b4b4b4;
  --border2:  #c8d3e3;
  --accent:   #2563eb;
  --accent2:  #1d4ed8;
  --accent-g: rgba(37,99,235,.10);
  --green:    #059669;
  --red:      #dc2626;
  --yellow:   #d97706;
  --purple:   #7c3aed;
  --pink:     #db2777;
  --text:     #0f172a;
  --text2:    #334155;
  --text3:    #94a3b8;
  --shadow:   0 4px 24px rgba(15,23,42,.10);

  --theme-icon: '🌙';
  --theme-label: 'มืด';

  color-scheme: light;
}

/* ── Smooth transition when switching themes ─────────────────── */
*, *::before, *::after {
  margin:0; padding:0; box-sizing:border-box;
  transition:
    background-color .25s ease,
    border-color .25s ease,
    color .25s ease,
    box-shadow .25s ease;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--text); }

/* ── Theme Toggle Button ─────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all .2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface3);
}

.theme-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  transition: background .25s;
  flex-shrink: 0;
}

.theme-toggle-track.on {
  background: var(--accent);
  border-color: var(--accent);
}

.theme-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}

.theme-toggle-track.on .theme-toggle-knob {
  transform: translateX(16px);
}

.theme-toggle-icon {
  font-size: 15px;
  line-height: 1;
  transition: transform .3s ease;
}

.theme-toggle:hover .theme-toggle-icon {
  transform: rotate(20deg);
}

/* ── Layout ───────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width .25s ease, transform .25s ease;
  overflow: hidden;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  transition: padding .25s ease;
}

.brand-icon {
  width: 190px; height: 60px;
  background: #f4f4f4;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: width .25s ease, height .25s ease, border-radius .25s ease;
}

.brand-logo-full { transition: opacity .2s; }
.brand-logo-mini { transition: opacity .2s; }

.brand-title { font-size: 14px; font-weight: 700; line-height: 1.3; white-space: nowrap; }
.brand-sub   { font-size: 11px; color: var(--text3); font-family: var(--mono); white-space: nowrap; }

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  transition: padding .25s ease;
}

.sidebar-user-info {
  overflow: hidden;
  transition: opacity .2s ease, width .25s ease;
  white-space: nowrap;
}

.flex-shrink-0 { flex-shrink: 0; }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.user-name  { font-size: 13px; font-weight: 600; color: var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-role  { font-size: 11px; color: var(--text3); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; overflow-x: hidden; }

.nav-section {
  padding: 6px 20px 4px;
  overflow: hidden;
  transition: padding .25s ease;
}

.nav-section-text {
  display: block;
  font-size: 10px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 1px;
  white-space: nowrap;
  transition: opacity .2s ease;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 14px;
  color: var(--text2);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background .15s, color .15s, padding .25s ease;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }

.nav-item.active {
  background: var(--accent-g);
  color: var(--accent2);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-text {
  transition: opacity .2s ease;
  white-space: nowrap;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  font-family: var(--mono);
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
  transition: opacity .2s ease;
}

.sidebar-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  transition: padding .25s ease;
}

.sidebar-footer-btn {
  width: 100%;
  justify-content: flex-start;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}

.sidebar-footer-text {
  transition: opacity .2s ease;
  white-space: nowrap;
}

/* ── Sidebar Collapsed (Desktop) ──────────────────────────── */
.sidebar.collapsed {
  width: 56px;
}

/* Brand: ย่อเหลือ icon เล็ก */
.sidebar.collapsed .sidebar-brand {
  padding: 12px 0;
  justify-content: center;
}

.sidebar.collapsed .brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f4f4f4;
}

.sidebar.collapsed .brand-logo-full {
  display: none !important;
}

.sidebar.collapsed .brand-logo-mini {
  display: block !important;
  width: 28px;
  height: 28px;
}

/* User: ซ่อนชื่อ */
.sidebar.collapsed .sidebar-user {
  padding: 10px 0;
  justify-content: center;
}

.sidebar.collapsed .sidebar-user-info {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Nav section label ซ่อน */
.sidebar.collapsed .nav-section {
  padding: 6px 0 4px;
}

.sidebar.collapsed .nav-section-text {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
  display: block;
  overflow: hidden;
}

/* Nav item: center icon */
.sidebar.collapsed .nav-item {
  padding: 10px 0;
  justify-content: center;
  gap: 0;
}

.sidebar.collapsed .nav-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  display: block;
}

.sidebar.collapsed .nav-icon {
  width: 20px;
}

/* Badge: แสดงเป็น dot มุมขวาบน */
.sidebar.collapsed .nav-badge {
  position: absolute;
  top: 5px;
  right: 6px;
  margin-left: 0;
  min-width: 16px;
  height: 16px;
  font-size: 9px;
  padding: 0 4px;
  opacity: 1;
}

/* Tooltip สำหรับ collapsed */
.sidebar.collapsed .nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface3);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  white-space: nowrap;
  border: 1px solid var(--border2);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 300;
}

.sidebar.collapsed .nav-item:hover::after {
  opacity: 1;
}

/* Footer collapsed */
.sidebar.collapsed .sidebar-footer {
  padding: 10px 0;
  align-items: center;
}

.sidebar.collapsed .sidebar-footer-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 8px;
}

.sidebar.collapsed .sidebar-footer-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Tooltip สำหรับ footer buttons */
.sidebar.collapsed .sidebar-footer-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface3);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  white-space: nowrap;
  border: 1px solid var(--border2);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 300;
}

.sidebar.collapsed .sidebar-footer-btn:hover::after {
  opacity: 1;
}

/* active indicator ใน collapsed */
.sidebar.collapsed .nav-item.active::before {
  left: 0;
  top: 4px;
  bottom: 4px;
}

/* Content area */
.content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left .25s ease;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
}

.main { padding: 24px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

[data-theme="light"] .card {
  box-shadow: 0 1px 4px rgba(15,23,42,.06);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(190px,1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

[data-theme="light"] .stat-card {
  box-shadow: 0 1px 4px rgba(15,23,42,.06);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue   { background: rgba(59,130,246,.15); }
.stat-icon.green  { background: rgba(16,185,129,.15); }
.stat-icon.yellow { background: rgba(245,158,11,.15); }
.stat-icon.red    { background: rgba(239,68,68,.15); }
.stat-icon.purple { background: rgba(139,92,246,.15); }

.stat-label { font-size: 12px; color: var(--text3); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); font-family: var(--mono); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── Toolbar ───────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-box { flex: 1; min-width: 200px; max-width: 300px; position: relative; }

.search-box input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px 8px 36px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

.search-box input:focus { border-color: var(--accent); }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 14px; pointer-events: none; }

select.filter-sel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

select.filter-sel:focus { border-color: var(--accent); }

.spacer { flex: 1; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: #1d4ed8; }
.btn-success  { background: var(--green); color: #fff; }
.btn-success:hover  { background: #047857; }
.btn-danger   { background: rgba(239,68,68,.1); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover   { background: rgba(239,68,68,.2); }
.btn-ghost    { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover    { border-color: var(--border2); color: var(--text); }
.btn-warn     { background: rgba(245,158,11,.1); color: var(--yellow); border: 1px solid rgba(245,158,11,.25); }
.btn-warn:hover     { background: rgba(245,158,11,.2); }
.btn-purple   { background: rgba(139,92,246,.1); color: var(--purple); border: 1px solid rgba(139,92,246,.25); }
.btn-edit     { background: rgba(59,130,246,.08); color: var(--accent2); border: 1px solid rgba(59,130,246,.2); }
.btn-edit:hover     { background: rgba(59,130,246,.16); }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-xs { padding: 3px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Form ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}

.form-label .req { color: var(--red); margin-left: 3px; }

.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-g);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }
.form-row  { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toggle-label { font-size: 14px; color: var(--text2); }

.toggle { position: relative; width: 44px; height: 24px; }
.toggle input { opacity:0; width:0; height:0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border2);
  border-radius: 24px;
  cursor: pointer;
  transition: .2s;
}
.toggle-slider::before {
  content:''; position:absolute;
  height:18px; width:18px;
  left:3px; bottom:3px;
  background:#fff;
  border-radius:50%;
  transition:.2s;
}
.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--surface2);
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th:first-child { padding-left: 20px; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

td {
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text2);
  vertical-align: middle;
}

td:first-child { padding-left: 20px; }

.td-mono   { font-family: var(--mono); font-size: 12px; }
.td-name   { color: var(--text); font-weight: 500; }
.td-code   { font-family: var(--mono); font-size: 13px; color: var(--accent2); font-weight: 500; }
.td-date   { font-family: var(--mono); font-size: 12px; color: var(--text3); }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.cb-wrap { display:flex; align-items:center; justify-content:center; }
input[type="checkbox"] { width:16px; height:16px; accent-color:var(--accent); cursor:pointer; }

.table-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text3);
  flex-wrap: wrap;
  gap: 10px;
}

.page-info { font-family: var(--mono); font-size: 12px; }

.pagination { display:flex; align-items:center; gap:4px; }

.page-btn {
  min-width:32px; height:32px; padding:0 8px;
  border-radius:6px; border:1px solid var(--border);
  background:var(--surface2); color:var(--text2);
  font-family:var(--mono); font-size:12px;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  transition:all .15s;
}

.page-btn:hover     { border-color:var(--accent); color:var(--accent2); }
.page-btn.active    { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:700; }
.page-btn:disabled  { opacity:.35; cursor:not-allowed; }
.page-btn.ellipsis  { border:none; background:none; cursor:default; color:var(--text3); }

.per-page-sel {
  background:var(--surface2); border:1px solid var(--border);
  border-radius:6px; padding:5px 10px;
  color:var(--text2); font-family:var(--mono); font-size:12px;
  cursor:pointer; outline:none;
}

.empty-state { text-align:center; padding:50px 20px; color:var(--text3); }
.empty-icon  { font-size:40px; margin-bottom:12px; }
.empty-state p { font-size:14px; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}

.badge-dot { width:6px; height:6px; border-radius:50%; background:currentColor; }

.badge-pending   { background:rgba(245,158,11,.12); color:var(--yellow); border:1px solid rgba(245,158,11,.25); }
.badge-approved  { background:rgba(16,185,129,.12);  color:var(--green);  border:1px solid rgba(16,185,129,.25); }
.badge-rejected  { background:rgba(239,68,68,.12);   color:var(--red);    border:1px solid rgba(239,68,68,.25); }
.badge-cancelled { background:rgba(100,116,139,.12); color:var(--text3);  border:1px solid rgba(100,116,139,.25); }
.badge-active    { background:rgba(16,185,129,.12);  color:var(--green);  border:1px solid rgba(16,185,129,.25); }
.badge-inactive  { background:rgba(100,116,139,.12); color:var(--text3);  border:1px solid rgba(100,116,139,.25); }
.badge-blue      { background:rgba(59,130,246,.12);  color:var(--accent2);border:1px solid rgba(59,130,246,.25); }
.badge-purple    { background:rgba(139,92,246,.12);  color:var(--purple); border:1px solid rgba(139,92,246,.25); }
.badge-hr        { background:rgba(236,72,153,.12);  color:var(--pink);   border:1px solid rgba(236,72,153,.25); }
.badge-sup       { background:rgba(245,158,11,.12);  color:var(--yellow); border:1px solid rgba(245,158,11,.25); }
.badge-emp       { background:rgba(59,130,246,.12);  color:var(--accent2);border:1px solid rgba(59,130,246,.25); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center; justify-content: center;
}

[data-theme="light"] .modal-backdrop {
  background: rgba(15,23,42,.35);
}

.modal-backdrop.active { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%; max-width: 500px;
  margin: 20px;
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes modalIn { from{opacity:0;transform:translateY(-16px) scale(.97)} to{opacity:1;transform:none} }

.modal-lg { max-width: 700px; }
.modal-sm { max-width: 380px; }

.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-title { font-size: 16px; font-weight: 600; display:flex; align-items:center; gap:8px; }

.modal-close {
  background:none; border:none; color:var(--text3);
  font-size:22px; cursor:pointer; padding:2px 6px;
  border-radius:4px; line-height:1;
  transition:color .15s;
}

.modal-close:hover { color:var(--text); }
.modal-body   { padding: 20px 22px; }
.modal-footer { padding: 14px 22px 18px; border-top: 1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; }

.confirm-icon { width:52px;height:52px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:24px;margin:0 auto 14px; }
.confirm-icon.danger { background:rgba(239,68,68,.15); }
.confirm-icon.warn   { background:rgba(245,158,11,.15); }
.confirm-icon.info   { background:rgba(59,130,246,.15); }
.confirm-text { text-align:center;font-size:14px;color:var(--text2);line-height:1.7; }
.confirm-name { font-weight:600;color:var(--text); }

/* ── Toast ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px; color: var(--text);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .25s ease;
  min-width: 260px; max-width: 380px;
}

@keyframes toastIn { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:none} }
.toast.success { border-left:3px solid var(--green); }
.toast.error   { border-left:3px solid var(--red); }
.toast.info    { border-left:3px solid var(--accent); }
.toast.warn    { border-left:3px solid var(--yellow); }

/* ── Loading ───────────────────────────────────────────────── */
.loading { display:flex; align-items:center; justify-content:center; padding:40px; }
.spinner { width:28px;height:28px;border:3px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }

/* ── Login page ────────────────────────────────────────────── */
.login-wrap {
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--bg);
  position: relative;
}

.login-theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
}

.login-card {
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:16px;
  padding:36px 40px;
  width:100%; max-width:380px;
  box-shadow:var(--shadow);
}

.login-logo { text-align:center; margin-bottom:28px; }
.login-logo-icon {
  width:130px;height:130px;
  background:#f4f4f4;
  border-radius:16px;
  display:inline-flex;align-items:center;justify-content:center;
  font-size:28px; margin-bottom:12px;
}
.login-logo h1 { font-size:20px; font-weight:700; }
.login-logo p  { font-size:13px; color:var(--text3); margin-top:4px; }

.login-err {
  background:rgba(239,68,68,.1);
  border:1px solid rgba(239,68,68,.25);
  border-radius:8px; padding:10px 14px;
  font-size:13px; color:var(--red);
  margin-bottom:16px; display:none;
}

.login-hint { font-size:12px; color:var(--text3); text-align:center; margin-top:16px; padding:12px; background:var(--surface2); border-radius:8px; border:1px solid var(--border); }
.login-hint code { font-family:var(--mono); color:var(--accent2); }

/* ── Shift calendar ────────────────────────────────────────── */
.shift-calendar { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }

.shift-day {
  background:var(--surface2);
  border:1px solid var(--border);
  border-radius:8px;
  padding:8px;
  min-height:80px;
}

.shift-day-header { font-size:11px; color:var(--text3); font-family:var(--mono); text-align:center; margin-bottom:6px; }
.shift-day-num    { font-size:16px; font-weight:600; color:var(--text); text-align:center; margin-bottom:6px; }
.shift-day.today  { border-color:var(--accent); }
.shift-day.today .shift-day-num { color:var(--accent2); }

.shift-chip {
  display:flex; align-items:center; gap:4px;
  padding:3px 8px; border-radius:6px;
  font-size:11px; margin-bottom:3px;
  cursor:pointer; transition:opacity .15s;
}

.shift-chip:hover { opacity:.8; }

/* ── Hamburger Button ──────────────────────────────────────── */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}

.hamburger:hover {
  background: var(--surface3);
  border-color: var(--border2);
}

[data-theme="light"] .hamburger {
  background: #ffffff;
  border-color: var(--border2);
}

[data-theme="light"] .hamburger:hover {
  background: var(--surface2);
  border-color: var(--accent);
}

.hamburger-line {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text2);
  border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease, width .2s ease;
}

/* Mobile X animation */
.hamburger.is-open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger.is-open .hamburger-line:nth-child(2) {
  opacity: 0;
  width: 0;
}
.hamburger.is-open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Sidebar Overlay ───────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  transition: opacity .25s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Desktop hamburger แสดงอยู่แล้ว, mobile ใช้ behavior เดิม */
  .sidebar {
    width: 240px !important; /* override collapsed on mobile */
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, .25);
  }

  /* ซ่อน tooltip บน mobile */
  .sidebar .nav-item::after,
  .sidebar .sidebar-footer-btn::after {
    display: none !important;
  }

  .content { margin-left: 0 !important; }

  .stat-grid { grid-template-columns: 1fr 1fr; }

  .form-row { flex-direction: column; }

  .modal { margin: 12px; }

  .topbar { padding: 0 14px; }

  .main { padding: 14px; }

  .topbar-time { display: none; }
}

/* ── Misc ──────────────────────────────────────────────────── */
.section-gap   { margin-bottom: 24px; }
.text-muted    { color: var(--text3); }
.text-small    { font-size: 12px; }
.text-mono     { font-family: var(--mono); }
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.flex-center   { display:flex; align-items:center; gap:8px; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mb-16         { margin-bottom: 16px; }

.divider       { border:none; border-top:1px solid var(--border); margin:16px 0; }

.info-row      { display:flex; gap:8px; font-size:13px; padding:6px 0; border-bottom:1px solid var(--border); }
.info-row:last-child { border-bottom:none; }
.info-label    { color:var(--text3); min-width:120px; }
.info-value    { color:var(--text); font-weight:500; }

/* Tab */
.tabs          { display:flex; gap:0; border-bottom:1px solid var(--border); margin-bottom:20px; }
.tab-btn {
  padding:10px 20px; font-size:14px; font-weight:500;
  cursor:pointer; border:none; background:none;
  color:var(--text3); border-bottom:2px solid transparent;
  font-family:var(--font); transition:all .15s;
  margin-bottom:-1px;
}
.tab-btn:hover { color:var(--text); }
.tab-btn.active { color:var(--accent2); border-bottom-color:var(--accent); }
.tab-panel { display:none; }
.tab-panel.active { display:block; }