:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-soft: #64748b;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.1);

  --success: #10b981;
  --success-hover: #059669;
  --success-soft: rgba(16, 185, 129, 0.14);

  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);

  --holiday: #8b5cf6;
  --holiday-soft: rgba(139, 92, 246, 0.14);

  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.16);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131c31;
  --surface-2: #1a2540;
  --border: #253352;
  --border-strong: #33466e;
  --text: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-soft: #94a3b8;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.18);

  --success: #10b981;
  --success-hover: #34d399;
  --success-soft: rgba(16, 185, 129, 0.18);

  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.16);

  --holiday: #a78bfa;
  --holiday-soft: rgba(167, 139, 250, 0.18);

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Noto Sans Thai', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

button, .tab-btn, .bottom-nav-btn, .cal-day {
  user-select: none;
  -webkit-user-select: none;
}

button, input, select {
  font-family: inherit;
  font-size: 0.94rem;
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* ==================== TOPBAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.28);
}

.brand-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-sub {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-top: 2px;
}

/* 2-Page Tabs */
.page-tabs {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 9px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--primary-soft);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.26);
}

/* ==================== SETTINGS DROPDOWN ==================== */
.settings-dropdown-wrap {
  position: relative;
}

.btn-settings {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-settings:hover,
.btn-settings[aria-expanded="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-settings .chevron {
  transition: transform 0.2s ease;
}

.btn-settings[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.settings-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 410px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 60;
  animation: dropFade 0.18s ease;
}

.settings-dropdown.open {
  display: flex;
}

@keyframes dropFade {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.dropdown-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.dropdown-header p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.icon-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-soft);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.icon-close:hover {
  background: var(--border);
  color: var(--text);
}

.dropdown-body {
  padding: 14px 18px;
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.setting-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.setting-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.seg-option {
  cursor: pointer;
  margin: 0;
}

.seg-option input {
  display: none;
}

.seg-option span {
  display: block;
  text-align: center;
  padding: 7px 10px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.seg-option input:checked + span {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.wage-subpanel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-2);
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.hint-text {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-row input:focus,
.form-row select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.toggle-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
}

.toggle-desc {
  display: block;
  font-size: 0.76rem;
  color: var(--text-soft);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.dropdown-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.save-hint {
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* ==================== MAIN CONTAINER & CARDS ==================== */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

.page-section {
  display: none;
  animation: fadeIn 0.22s ease;
}

.page-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

/* ==================== BUTTONS ==================== */
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
  color: #fff;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-danger-outline {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--danger);
}

.btn-danger-outline:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 7px;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ==================== PAGE 1: CHECK-IN ==================== */
.checkin-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 22px;
  align-items: start;
}

.checkin-hero-card {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 26px;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pill-badge {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
}

.live-status-pill {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  background: var(--warning-soft);
  color: #b45309;
}

html[data-theme="dark"] .live-status-pill {
  color: var(--warning);
}

.live-status-pill.checked {
  background: var(--success-soft);
  color: #047857;
}

html[data-theme="dark"] .live-status-pill.checked {
  color: #34d399;
}

.clock-block {
  text-align: center;
  padding: 14px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.live-time {
  font-size: clamp(2.5rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.live-date {
  margin-top: 6px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
}

.clock-note {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.quick-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.option-group > label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.worktype-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.type-pill {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.type-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.type-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.24);
}

.quick-inputs-row {
  display: flex;
  gap: 12px;
}

.quick-inputs-row .compact {
  width: 128px;
}

.quick-inputs-row .flex-grow {
  flex: 1;
}

/* Big Check-in Button */
.checkin-action-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 4px;
}

.btn-checkin {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 20px 24px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 12px 26px rgba(79, 70, 229, 0.34);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-checkin:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(79, 70, 229, 0.42);
}

.btn-checkin:active {
  transform: translateY(1px);
}

.btn-checkin.checked {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 12px 26px rgba(16, 185, 129, 0.32);
}

.btn-checkin.checked:hover {
  box-shadow: 0 16px 32px rgba(16, 185, 129, 0.4);
}

.btn-checkin-text {
  font-size: 1.2rem;
  font-weight: 800;
}

.btn-checkin-sub {
  font-size: 0.84rem;
  opacity: 0.92;
}

.today-checked-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Side Column */
.checkin-side-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card-header-row h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.mini-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mini-kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.mini-kpi-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.mini-kpi-val {
  display: block;
  margin-top: 4px;
  font-size: 1.32rem;
  font-weight: 800;
}

.mini-kpi-val.accent {
  color: var(--success);
}

/* Mini Calendar */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-day {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: all 0.14s ease;
}

.cal-day:hover {
  border-color: var(--primary);
}

.cal-day.empty {
  background: transparent;
  cursor: default;
  pointer-events: none;
}

.cal-day.is-today {
  border: 2px solid var(--primary);
  color: var(--primary);
}

.cal-day.status-full {
  background: var(--success-soft);
  color: #047857;
}

html[data-theme="dark"] .cal-day.status-full {
  color: #34d399;
}

.cal-day.status-half {
  background: var(--warning-soft);
  color: #b45309;
}

html[data-theme="dark"] .cal-day.status-half {
  color: var(--warning);
}

.cal-day.status-holiday {
  background: var(--holiday-soft);
  color: var(--holiday);
}

.cal-day .cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-top: 2px;
  background: currentColor;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot.full { background: var(--success); }
.dot.half { background: var(--warning); }
.dot.holiday { background: var(--holiday); }
.dot.today-ring {
  background: transparent;
  border: 2px solid var(--primary);
}

/* ==================== PAGE 2: RECORDS & WAGE ==================== */
.toolbar-card {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.month-picker-wrap {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
}

.icon-btn {
  border: none;
  background: transparent;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.month-input {
  border: none;
  background: transparent;
  padding: 7px 6px;
  font-weight: 600;
  outline: none;
}

.select-input,
.search-input {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  outline: none;
}

.select-input:focus,
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-input {
  min-width: 200px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-soft);
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 0.79rem;
  color: var(--text-soft);
}

.kpi-highlight {
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  border-color: transparent;
  color: #fff;
}

.kpi-highlight .kpi-label,
.kpi-highlight .kpi-sub {
  color: rgba(255, 255, 255, 0.85);
}

/* Breakdown Card */
.breakdown-card {
  margin-bottom: 20px;
  padding: 18px 22px;
}

.breakdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.breakdown-header h3 {
  margin: 0;
  font-size: 0.98rem;
}

.breakdown-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.breakdown-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
}

.breakdown-item .b-label {
  color: var(--text-muted);
}

.breakdown-item .b-val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.breakdown-item .b-val.plus { color: var(--success); }
.breakdown-item .b-val.minus { color: var(--danger); }

/* Work Table */
.table-card {
  padding: 20px 22px;
}

.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.table-header-row h3 {
  margin: 0;
  font-size: 1.05rem;
  display: inline-block;
  margin-right: 10px;
}

.table-count {
  font-size: 0.82rem;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
}

.table-responsive {
  overflow-x: auto;
}

.work-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.work-table th,
.work-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.work-table th {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--surface-2);
  white-space: nowrap;
}

.work-table th:first-child { border-radius: 8px 0 0 8px; }
.work-table th:last-child { border-radius: 0 8px 8px 0; }

.work-table tbody tr:hover {
  background: var(--surface-2);
}

.work-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.work-table .actions-col {
  text-align: right;
  white-space: nowrap;
}

.date-cell-main {
  font-weight: 600;
}

.date-cell-sub {
  display: block;
  font-size: 0.77rem;
  color: var(--text-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-full {
  background: var(--success-soft);
  color: #047857;
}

html[data-theme="dark"] .badge-full {
  color: #34d399;
}

.badge-half {
  background: var(--warning-soft);
  color: #b45309;
}

html[data-theme="dark"] .badge-half {
  color: var(--warning);
}

.badge-holiday {
  background: var(--holiday-soft);
  color: var(--holiday);
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.action-icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.action-icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.action-icon-btn.del:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  text-align: center;
  padding: 46px 16px;
  color: var(--text-soft);
}

.empty-state h4 {
  margin: 12px 0 4px;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  font-size: 0.88rem;
}

/* ==================== MODAL ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-dialog {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: dropFade 0.18s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--primary);
  animation: dropFade 0.2s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger { border-left-color: var(--danger); }

/* ==================== MOBILE BOTTOM NAVIGATION ==================== */
.mobile-bottom-nav {
  display: none;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 960px) {
  .checkin-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .topbar-inner {
    padding: 10px 14px;
    flex-wrap: nowrap;
  }

  .page-tabs {
    display: none;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08);
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
    gap: 8px;
  }

  .bottom-nav-btn {
    border: none;
    background: transparent;
    color: var(--text-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 7px 6px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.16s ease;
  }

  .bottom-nav-btn.active {
    color: var(--primary);
    background: var(--primary-soft);
  }

  .bottom-nav-btn:active {
    transform: scale(0.96);
  }

  .container {
    padding: 14px 12px calc(92px + env(safe-area-inset-bottom));
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  .checkin-hero-card {
    padding: 18px 16px;
    gap: 16px;
  }

  .btn-checkin {
    max-width: 100%;
    padding: 18px 20px;
  }

  .quick-inputs-row {
    flex-direction: column;
  }

  .quick-inputs-row .compact {
    width: 100%;
  }

  .toolbar-card {
    padding: 14px;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .search-input {
    width: 100%;
    min-width: 0;
  }

  .toolbar-right > button {
    flex: 1;
  }

  .settings-dropdown {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    width: auto;
    max-height: calc(100vh - 88px - env(safe-area-inset-top));
  }

  .dropdown-body {
    max-height: calc(100vh - 220px - env(safe-area-inset-top));
  }

  .toast-container {
    left: 14px;
    right: 14px;
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .brand-title {
    font-size: 0.98rem;
  }
  .brand-sub {
    font-size: 0.72rem;
  }
  .btn-settings span {
    display: none;
  }
  .btn-settings {
    padding: 9px 11px;
  }
  .work-table th,
  .work-table td {
    padding: 10px 8px;
    font-size: 0.84rem;
  }
}
