@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ==========================================================================
   HistoTime - Design System
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-soft: #eff4ff;
  --accent: #7c3aed;
  --accent-teal: #06b6d4;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --info: #0ea5e9;
  --info-soft: #f0f9ff;

  --bg: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e7eaf3;
  --border-strong: #d8def0;

  --text: #0f172a;
  --text-2: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --sidebar-bg: linear-gradient(180deg, #0d1f3d 0%, #0b1a33 100%);
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --sidebar-text: rgba(255, 255, 255, 0.78);
  --sidebar-text-hover: #ffffff;

  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, 0.14), 0 4px 8px -4px rgba(16, 24, 40, 0.08);

  --header-h: 64px;
  --sidebar-w: 256px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

@keyframes cardRise {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  background-image: radial-gradient(1200px 600px at 90% -10%, rgba(37, 99, 235, 0.08), transparent 60%),
                    radial-gradient(900px 500px at -10% 20%, rgba(124, 58, 237, 0.06), transparent 55%);
  background-attachment: fixed;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection {
  background: rgba(37, 99, 235, 0.18);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #c3cbe0;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #a6b1cf;
  background-clip: content-box;
  border: 2px solid transparent;
}

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

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
}
.skip-link:focus {
  top: 12px;
  color: #fff;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5rem;
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
}

p { margin: 0 0 1rem; }

/* ==========================================================================
   App shell
   ========================================================================== */

.main-content {
  min-height: calc(100vh - var(--header-h));
}

.page-container {
  max-width: 1280px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Top navigation
   ========================================================================== */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  overflow: visible;
  z-index: 40;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
}

.app-header-inner {
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#sidebarToggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#sidebarToggle:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
#sidebarToggle svg { width: 20px; height: 20px; }
@media (min-width: 768px) {
  #sidebarToggle { display: none; }
}

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

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 10px -2px rgba(37, 99, 235, 0.45);
}

.brand-name {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.brand-name em {
  font-style: normal;
  color: var(--primary);
}

.brand-sub {
  display: block;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.header-center {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.header-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 20px;
  padding-right: 20px;
  border-right: 1px solid var(--border);
}

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

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 19px; height: 19px; }

.icon-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--surface);
}

.divider-y {
  width: 1px;
  height: 28px;
  margin: 0 4px;
  background: var(--border);
}

/* User chip + dropdown */
.dropdown { position: relative; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 5px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.user-chip:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
}
.user-name {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.user-role {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}
.user-role.muted { color: var(--text-muted); }

.caret {
  color: var(--text-faint);
  transition: transform 0.15s;
}
.dropdown.open .caret { transform: rotate(180deg); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: menuIn 0.14s ease-out;
  z-index: 60;
}
.dropdown-menu.hidden,
.icon-badge.hidden { display: none; }
.dropdown-menu[data-align="left"] { right: auto; left: 0; }

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.dropdown-item svg { width: 17px; height: 17px; color: var(--text-muted); }
.dropdown-item:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.dropdown-item:hover svg { color: var(--primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); color: var(--danger); }
.dropdown-item.danger:hover svg { color: var(--danger); }

.dropdown-sep {
  height: 1px;
  margin: 6px 8px;
  background: var(--border);
}

.dropdown-header {
  padding: 10px 12px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Notification dropdown */
.notif-panel { min-width: 320px; max-width: 360px; }
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.notif-head h4 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
}
.notif-mark-all {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  border: none;
  background: none;
  cursor: pointer;
  padding: 2px 4px;
}
.notif-mark-all:hover { text-decoration: underline; }

.notif-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}

.notif-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.12s;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--primary-soft); }
.notif-item.unread:hover { background: var(--primary-soft); }

.notif-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--border-strong);
  margin-top: 6px;
}
.notif-item.unread .notif-dot { background: var(--primary); }

.notif-item .notif-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 2px;
  word-break: break-word;
}
.notif-item .notif-time {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.notif-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.8rem;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

#sidebar {
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 40px rgba(11, 26, 51, 0.18);
}

#sidebar.-translate-x-full,
#sidebar:not([class*="md:translate-x-0"]).-translate-x-full {
  transform: translateX(-100%) !important;
}

#sidebar.sidebar-open,
#sidebar:not(.-translate-x-full) {
  transform: translateX(0);
}

@media (min-width: 768px) {
  #sidebar,
  #sidebar.-translate-x-full {
    transform: translateX(0) !important;
  }
}

#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(9, 17, 38, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: none;
}
#sidebarOverlay:not(.hidden) {
  display: block;
  pointer-events: auto;
}
#sidebarOverlay.hidden {
  display: none !important;
  pointer-events: none !important;
}
@media (min-width: 768px) {
  #sidebarOverlay { display: none !important; }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: var(--header-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand .brand-logo { width: 34px; height: 34px; font-size: 13px; box-shadow: 0 3px 8px rgba(37, 99, 235, 0.4); }
.sidebar-brand .brand-name { color: #fff; font-size: 1.02rem; }
.sidebar-brand .brand-name em { color: #7fb4ff; }
.sidebar-brand .brand-sub { color: rgba(255, 255, 255, 0.45); }

.sidebar-brand-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-brand-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.sidebar-brand-close svg { width: 15px; height: 15px; }
@media (min-width: 768px) {
  .sidebar-brand-close { display: none; }
}

#sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 24px;
}

.sidebar-section {
  margin-bottom: 6px;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 12px 6px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
  white-space: nowrap;
}
.sidebar-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 2px 0;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  position: relative;
}
.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.15s;
}
.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-text-hover);
}
.sidebar-link:hover svg { color: #fff; }
.sidebar-link:active { transform: translateX(1px); }

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.9), rgba(37, 99, 235, 0.72));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 14px -6px rgba(37, 99, 235, 0.55);
}
.sidebar-link.active svg { color: #fff; }

.sidebar-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  transition: background 0.15s;
}
.sidebar-link:hover .sidebar-dot { background: rgba(255, 255, 255, 0.7); }
.sidebar-link.active .sidebar-dot { background: #fff; }

.sidebar-link .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}
.sidebar-link.active .count { background: rgba(255, 255, 255, 0.22); }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

/* ==========================================================================
   Cards & panels
   ========================================================================== */

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel-head-from, #fcfdff), var(--panel-head-to, #f8fafc));
}
.panel-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}
.panel-body { padding: 20px; }

/* KPI cards */
.kpi-card {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 14px 14px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.kpi-card > div:last-child {
  min-width: 0;
  flex: 1;
}
.kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 99px;
  background: var(--kpi-accent, var(--primary));
}
.kpi-card[data-tone="blue"] { --kpi-accent: #2563eb; }
.kpi-card[data-tone="green"] { --kpi-accent: var(--success); }
.kpi-card[data-tone="amber"] { --kpi-accent: var(--warning); }
.kpi-card[data-tone="red"] { --kpi-accent: var(--danger); }
.kpi-card[data-tone="indigo"] { --kpi-accent: #6366f1; }
.kpi-card[data-tone="cyan"] { --kpi-accent: var(--info); }
.kpi-card[data-tone="violet"] { --kpi-accent: #8b5cf6; }
.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .kpi-card:hover {
    box-shadow: 0 14px 28px -12px color-mix(in srgb, var(--kpi-accent, var(--primary)) 50%, transparent), var(--shadow-md);
    border-color: color-mix(in srgb, var(--kpi-accent, var(--primary)) 35%, var(--border));
  }
}
.kpi-card.text-center {
  flex-direction: column;
  text-align: center;
  gap: 8px;
}

.kpi-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  font-size: 1.05rem;
}
.kpi-icon svg { width: 21px; height: 21px; }

.tone-blue { background: #eaf2ff; color: #2563eb; }
.tone-green { background: var(--success-soft); color: var(--success); }
.tone-amber { background: var(--warning-soft); color: var(--warning); }
.tone-red { background: var(--danger-soft); color: var(--danger); }
.tone-indigo { background: #eef1ff; color: #6366f1; }
.tone-cyan { background: var(--info-soft); color: var(--info); }
.tone-violet { background: #f3efff; color: #8b5cf6; }
.tone-gray { background: #f1f5f9; color: var(--text-muted); }

.kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.25;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-row-4 {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

/* ==========================================================================
   Tables
   ========================================================================== */

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

.data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}
.data-table th {
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-2);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background 0.12s;
}
.data-table tbody tr:hover {
  background: var(--table-hover, #f7f9fd);
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.8;
}

.badge-present { background: var(--success-soft); color: #047857; }
.badge-late { background: var(--warning-soft); color: #b45309; }
.badge-absent { background: var(--danger-soft); color: #b91c1c; }
.badge-break { background: var(--info-soft); color: #0369a1; }
.badge-clocked-out { background: #f1f5f9; color: #475569; }
.badge-leave { background: #eef1ff; color: #4338ca; }
.badge-holiday { background: #fdf2f8; color: #be185d; }
.badge-exception { background: #fff7ed; color: #c2410c; }
.badge-early { background: #ecfeff; color: #0e7490; }
.badge-info { background: var(--info-soft); color: #0369a1; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
  user-select: none;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(37, 99, 235, 0.5);
}
.btn-primary:hover { background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%); color: #fff; }

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 0.95rem; border-radius: 12px; }
.btn-block { width: 100%; }

/* Clock buttons */
.clock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 14px 28px;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.clock-btn:hover { transform: translateY(-2px) scale(1.01); filter: brightness(1.05); }
.clock-btn:active { transform: translateY(0) scale(0.99); }
.clock-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; filter: none; }

.clock-btn-in { background: linear-gradient(135deg, #059669, #10b981); box-shadow: 0 8px 20px -6px rgba(16, 185, 129, 0.5); }
.clock-btn-out { background: linear-gradient(135deg, #dc2626, #ef4444); box-shadow: 0 8px 20px -6px rgba(239, 68, 68, 0.5); }
.clock-btn-break { background: linear-gradient(135deg, #2563eb, #3b82f6); box-shadow: 0 8px 20px -6px rgba(59, 130, 246, 0.5); }
.clock-btn-wide { min-width: 180px; }

/* ==========================================================================
   Kiosk punch screen
   ========================================================================== */

body.kiosk {
  min-height: 100vh;
  margin: 0;
  color: #e2e8f0;
  background-color: #0f172a;
  background-image: linear-gradient(160deg, #0f172a 0%, #1e3a5f 55%, #17456b 100%);
  background-attachment: fixed;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

.kiosk-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.kiosk-clock {
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #f8fafc;
}

.kiosk-date {
  font-size: 1.05rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  margin-top: 10px;
}

.kiosk-panel {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid transparent;
  border-radius: 24px;
  padding: 44px 40px;
  width: min(480px, 92vw);
  box-shadow: 0 30px 60px rgba(2, 8, 23, 0.55);
  text-align: center;
  margin-top: 34px;
}

.kiosk-ready {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.kiosk-scanline {
  font-size: 0.95rem;
  color: #475569;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kiosk-hint {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.45;
}

.kiosk-badge-input {
  width: 100%;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 18px 14px;
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
  color: #0f172a;
  margin: 18px 0 8px;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.kiosk-badge-input:focus {
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.kiosk-badge-input::placeholder { color: #94a3b8; }

.badge-scan-input {
  width: 100%;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 14px 16px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-1);
  outline: none;
  font-variant-numeric: tabular-nums;
}

.badge-scan-input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.badge-scan-input::placeholder {
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: normal;
}

.kiosk-avatar {
  width: 104px;
  height: 104px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  margin: 0 auto 16px;
}

.kiosk-name {
  font-size: 1.7rem;
  font-weight: 800;
  color: #0f172a;
}

.kiosk-empid {
  font-size: 0.9rem;
  color: #64748b;
  margin-top: 4px;
}

.kiosk-action-pill {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 18px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.kiosk-action-pill.clock-in { background: #dcfce7; color: #15803d; }
.kiosk-action-pill.clock-out { background: #fef3c7; color: #b45309; }

.kiosk-btn {
  display: block;
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 22px;
  box-shadow: none;
}
.kiosk-btn:hover { transform: none; filter: brightness(1.06); }
.kiosk-btn-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; }
.kiosk-btn-secondary { background: #f1f5f9; color: #334155; }
.kiosk-btn:disabled { opacity: 0.65; cursor: not-allowed; filter: none; }

.kiosk-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 18px;
}

.kiosk-success-icon {
  width: 96px;
  height: 96px;
  border-radius: 9999px;
  background: #dcfce7;
  color: #16a34a;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.kiosk-success-msg {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
}

.kiosk-foot {
  margin-top: 30px;
  font-size: 0.8rem;
  color: #94a3b8;
  text-align: center;
}
.kiosk-foot a { color: #93c5fd; text-decoration: none; }
.kiosk-foot a:hover { color: #bfdbfe; }
body.kiosk [hidden] { display: none !important; }

html[data-theme="dark"] body.kiosk {
  background-color: #020617;
  background-image: radial-gradient(900px 500px at 90% -10%, rgba(37, 99, 235, 0.22), transparent 55%),
                    linear-gradient(160deg, #020617 0%, #0b1220 45%, #111827 100%);
}

html[data-theme="dark"] .kiosk-panel {
  background: #111827;
  color: #f1f5f9;
  border-color: #243044;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .kiosk-ready,
html[data-theme="dark"] .kiosk-name,
html[data-theme="dark"] .kiosk-success-msg { color: #f1f5f9; }

html[data-theme="dark"] .kiosk-scanline { color: #94a3b8; }
html[data-theme="dark"] .kiosk-hint,
html[data-theme="dark"] .kiosk-empid { color: #94a3b8; }

html[data-theme="dark"] .kiosk-badge-input {
  background: #1a2333;
  color: #f1f5f9;
  border-color: #334155;
}
html[data-theme="dark"] .kiosk-badge-input:focus {
  border-color: #60a5fa;
  background: #1e293b;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
}
html[data-theme="dark"] .kiosk-badge-input::placeholder { color: #64748b; }

html[data-theme="dark"] .kiosk-btn-secondary {
  background: #1e293b;
  color: #e2e8f0;
}

html[data-theme="dark"] .kiosk-action-pill.clock-in {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}
html[data-theme="dark"] .kiosk-action-pill.clock-out {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

html[data-theme="dark"] .kiosk-error {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.4);
}

html[data-theme="dark"] .kiosk-success-icon {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
}

.form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.88rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
.form-control::placeholder { color: var(--text-faint); }
select.form-control { cursor: pointer; }

.form-hint { font-size: 0.74rem; color: var(--text-faint); margin-top: 5px; }

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 17, 38, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal-backdrop.hidden,
.hidden.modal-backdrop {
  display: none !important;
  pointer-events: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  animation: modalIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 440px;
  width: 100%;
  animation: modalIn 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title { margin: 0; font-size: 1.02rem; font-weight: 700; }
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-close svg { width: 17px; height: 17px; }
.modal-body { padding: 22px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Toasts / notifications
   ========================================================================== */

#toastContainer {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  right: 16px;
  z-index: 90;
  width: 100%;
  max-width: 360px;
  pointer-events: none;
}

.toast-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
}
.toast-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.toast-item p {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  line-height: 1.4;
}
.toast-item.translate-x-full { transform: translateX(110%); opacity: 0; }

.toast-success .toast-icon { color: var(--success); }
.toast-item.toast-error { background: #fff7f7; border-color: #fecaca; }
.toast-error .toast-icon { color: var(--danger); }
.toast-item.toast-warning { background: #fffdf5; border-color: #fde68a; }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-item.toast-success svg,
.toast-item.toast-info svg { color: var(--success); }
.toast-item.toast-error svg { color: var(--danger); }
.toast-item.toast-warning svg { color: var(--warning); }

/* legacy .toast classes */
.toast { position: fixed; bottom: 16px; right: 16px; z-index: 90; max-width: 380px; width: 100%; }
.toast.toast-success { background: #10b981; color: #fff; }
.toast.toast-error { background: #ef4444; color: #fff; }
.toast.toast-warning { background: #f59e0b; color: #0f172a; }
.toast.toast-info { background: #3b82f6; color: #fff; }

/* ==========================================================================
   Digital clock (hero)
   ========================================================================== */

.digital-clock {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.digital-clock .clock-greeting {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
}

.digital-clock .clock-time {
  font-weight: 400;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.digital-clock .clock-date {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  text-transform: capitalize;
}

.header-clock .clock-time {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  line-height: 1.1;
}
.header-clock .clock-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: capitalize;
}

/* ==========================================================================
   Calendar
   ========================================================================== */

.calendar-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
}
.calendar-day:hover { transform: scale(1.06); }

.calendar-day.present { background: var(--success-soft); color: #047857; }
.calendar-day.late { background: var(--warning-soft); color: #b45309; }
.calendar-day.absent { background: var(--danger-soft); color: #b91c1c; }
.calendar-day.leave { background: #eef1ff; color: #4338ca; }
.calendar-day.holiday { background: #fdf2f8; color: #be185d; }
.calendar-day.rest { background: #f1f5f9; color: #64748b; }
.calendar-day.current { box-shadow: 0 0 0 2px var(--primary); }

/* ==========================================================================
   Login page
   ========================================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  background-image: radial-gradient(1000px 600px at 15% -5%, rgba(37, 99, 235, 0.16), transparent 55%),
                    radial-gradient(800px 500px at 110% 110%, rgba(124, 58, 237, 0.12), transparent 55%);
}

.login-page-main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.login-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1 1 50%;
  padding: 64px;
  color: #fff;
  background: linear-gradient(150deg, #0c1f42 0%, #132c60 55%, #1e40af 100%);
  position: relative;
  overflow: hidden;
}
.login-brand-panel::before {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  right: -180px;
  bottom: -180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.45), transparent 65%);
}
.login-brand-panel::after {
  content: "";
  position: absolute;
  width: 380px;
  height: 380px;
  left: -140px;
  top: -120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.25), transparent 65%);
}

.login-brand-inner { position: relative; z-index: 1; max-width: 460px; }

.login-brand-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 40px;
}
.login-brand-logo .brand-logo { width: 46px; height: 46px; font-size: 18px; box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.5); }
.login-brand-logo .brand-name { color: #fff; font-size: 1.35rem; }
.login-brand-logo .brand-name em { color: #a5c8ff; }
.login-brand-logo .brand-sub { color: rgba(255, 255, 255, 0.55); }

.login-brand-title {
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 14px;
}
.login-brand-sub {
  color: rgba(255, 255, 255, 0.65);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 40px;
}

.login-features { display: grid; gap: 14px; }
.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
}
.login-feature .feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #8fc1ff;
  flex-shrink: 0;
}
.login-feature .feature-icon svg { width: 18px; height: 18px; }

.login-form-panel {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.login-form-card {
  width: 100%;
  max-width: 420px;
}
.login-form-card .brand-name { font-size: 1.15rem; }
.login-form-card .brand-sub { margin-bottom: 26px; }

.login-card-title { font-size: 1.45rem; font-weight: 800; margin-bottom: 4px; }
.login-card-sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 26px; }

@media (max-width: 900px) {
  .login-brand-panel { display: none; }
}

.login-page-footer {
  flex-shrink: 0;
  width: 100%;
  padding: 14px 20px 18px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1199px) {
  .header-center { display: none; }
  .header-actions { gap: 8px; }
}

@media (max-width: 767px) {
  .app-header-inner { padding: 0 14px; }

  .header-clock .clock-date { display: none; }
  .header-clock { border-right: none; padding-right: 0; margin-right: 0; }
  .header-clock .clock-time { font-size: 1rem; }

  .user-meta { display: none; }
  .brand-sub { display: none; }

  .kpi-value { font-size: 1.4rem; }
  .clock-btn { padding: 14px 24px; }
  .clock-btn-wide { min-width: 150px; }
  .modal { max-width: 100%; }
  .notif-panel { min-width: calc(100vw - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .kpi-card, .live-card, .punch-card, .ai-board, .ai-item, .coverage-card, .surface-card, .coverage-bar > span {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ==========================================================================
   Empty states, alerts, punch card, live cards
   ========================================================================== */

.app-main {
  min-width: 0;
  max-width: 100%;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 6px;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--text-faint);
}
.empty-state-icon svg { width: 26px; height: 26px; }
.empty-state strong {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
}
.empty-state span { font-size: 0.82rem; }

.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
}
.alert-banner svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.alert-banner.error { background: var(--danger-soft); border-color: #fecaca; color: #b91c1c; }
.alert-banner.success { background: var(--success-soft); border-color: #a7f3d0; color: #047857; }
.alert-banner.warning { background: var(--warning-soft); border-color: #fde68a; color: #b45309; }
.alert-banner.info { background: var(--info-soft); border-color: #bae6fd; color: #0369a1; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.status-pill .pulse {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: statusPulse 1.8s ease-out infinite;
}
@keyframes statusPulse {
  0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  70% { box-shadow: 0 0 0 8px transparent; opacity: 0.6; }
  100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}
.status-clocked-in { background: var(--success-soft); color: #047857; }
.status-on-break { background: var(--info-soft); color: #0369a1; }
.status-clocked-out { background: #f1f5f9; color: #475569; }
.status-not-in { background: #fff7ed; color: #c2410c; }

.punch-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 28px 24px;
  margin-bottom: 20px;
  border-radius: 20px;
  color: #fff;
  background:
    radial-gradient(500px 240px at 100% 0%, rgba(124, 58, 237, 0.35), transparent 60%),
    linear-gradient(135deg, #0c1f42 0%, #1d4ed8 70%, #2563eb 100%);
  box-shadow: var(--shadow-md);
}
.punch-hero .clock-greeting {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
.punch-hero .punch-name {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}
.punch-hero .clock-date {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
  text-transform: none;
}
.punch-hero .clock-time {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 300;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.shift-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.shift-bar-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.shift-bar-value {
  font-weight: 700;
  color: var(--text);
}

.punch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.punch-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  max-width: 720px;
  margin: 0 auto 24px;
}
.punch-metric {
  padding: 14px 10px;
  border-radius: 12px;
  background: var(--surface-2);
}
.punch-metric .label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.punch-metric .value {
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.punch-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 44px; }
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}
.password-toggle:hover { color: var(--text); background: var(--surface-2); }
.password-toggle svg { width: 18px; height: 18px; }

.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-bottom: 22px;
}
.login-row a {
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.login-check {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  width: auto;
}
.login-check input { width: 15px; height: 15px; accent-color: var(--primary); }

.btn.is-busy {
  pointer-events: none;
  opacity: 0.8;
}
.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.live-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--success);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.live-card:nth-child(odd),
.live-card:nth-child(even) { animation-delay: 0s; }
.live-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 16px 30px -14px rgba(16, 185, 129, 0.45), var(--shadow-md);
}
.live-card.is-break {
  border-color: #bae6fd;
  border-top-color: var(--info);
  background: linear-gradient(180deg, #f0f9ff, var(--surface));
}
.live-card.is-break:hover {
  box-shadow: 0 16px 30px -14px rgba(14, 165, 233, 0.4), var(--shadow-md);
}

.filter-bar {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
@media (min-width: 768px) {
  .filter-bar { grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: end; }
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin: 8px 10px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}
.sidebar-user .avatar { width: 32px; height: 32px; font-size: 0.75rem; }
.sidebar-user .user-name { color: #fff; font-size: 0.8rem; }
.sidebar-user .user-role { color: rgba(255, 255, 255, 0.5); font-size: 0.68rem; }

.panel.chart-panel { padding: 16px 18px 12px; }
.panel.chart-panel h3 {
  margin: 0 0 12px;
  font-size: 0.92rem;
}

@media (max-width: 767px) {
  .punch-hero { padding: 22px 18px; }
  .punch-hero .punch-name { font-size: 1.35rem; }
  .punch-actions { position: sticky; bottom: 12px; z-index: 10; }
  .clock-btn { width: 100%; }
}

/* ==========================================================================
   Motion, coverage cards, AI insights
   ========================================================================== */

.surface-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px 12px;
  min-width: 0;
}
.chart-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.chart-row > * { min-width: 0; }
.chart-wrap {
  position: relative;
  height: 180px;
  width: 100%;
}
.chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.coverage-card {
  text-align: center;
  padding: 14px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.coverage-card .coverage-name {
  font-weight: 700;
  color: var(--text);
  font-size: 0.88rem;
}
.coverage-card .coverage-count {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary);
  margin: 4px 0 2px;
}
.coverage-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
  margin-top: 8px;
}
.coverage-bar > span {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--primary), var(--accent-teal));
  animation: barFill 0.7s ease-out;
}
@keyframes barFill {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.ai-board {
  margin-bottom: 24px;
  padding: 20px 20px 8px;
  border-radius: 20px;
  background:
    radial-gradient(700px 180px at 100% 0%, rgba(124, 58, 237, 0.12), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.ai-board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.ai-board-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.ai-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.ai-risk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ai-risk.low { background: var(--success-soft); color: #047857; }
.ai-risk.medium { background: var(--warning-soft); color: #b45309; }
.ai-risk.high { background: var(--danger-soft); color: #b91c1c; }
.ai-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.ai-chip {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.ai-chip .val {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ai-chip .lbl {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}
.ai-col { min-width: 0; }
.ai-col h3 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ai-item {
  padding: 14px 14px 12px;
  margin-bottom: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-left: 4px solid var(--primary);
}
.ai-item h4 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}
.ai-item p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.ai-item.ai-success { border-left-color: var(--success); background: linear-gradient(90deg, var(--success-soft), var(--surface) 40%); }
.ai-item.ai-warning { border-left-color: var(--warning); background: linear-gradient(90deg, var(--warning-soft), var(--surface) 40%); }
.ai-item.ai-danger { border-left-color: var(--danger); background: linear-gradient(90deg, var(--danger-soft), var(--surface) 40%); }
.ai-item.ai-info { border-left-color: var(--info); background: linear-gradient(90deg, var(--info-soft), var(--surface) 40%); }
.ai-item.ai-neutral { border-left-color: var(--text-faint); }
.ai-action {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 700;
}
.ai-empty { color: var(--text-muted); font-size: 0.85rem; padding: 8px 0 16px; }

.theme-toggle .icon-sun,
.theme-toggle .icon-moon { width: 18px; height: 18px; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon,
html:not([data-theme]) .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
.login-theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
}

@media (max-width: 1024px) {
  .ai-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Dark theme
   ========================================================================== */

html[data-theme="dark"] {
  color-scheme: dark;
  --primary: #60a5fa;
  --primary-dark: #93c5fd;
  --primary-soft: #1e3a5f;
  --accent: #a78bfa;
  --accent-teal: #22d3ee;
  --success: #34d399;
  --success-soft: rgba(16, 185, 129, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(14, 165, 233, 0.14);

  --bg: #0b1220;
  --surface: #111827;
  --surface-2: #1a2333;
  --border: #243044;
  --border-strong: #334155;

  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 16px -6px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 32px -10px rgba(0, 0, 0, 0.55);

  --panel-head-from: #151c2c;
  --panel-head-to: #111827;
  --table-hover: rgba(148, 163, 184, 0.08);
}

html[data-theme="dark"] body:not(.kiosk) {
  background-image: radial-gradient(1200px 600px at 90% -10%, rgba(37, 99, 235, 0.16), transparent 60%),
                    radial-gradient(900px 500px at -10% 20%, rgba(124, 58, 237, 0.12), transparent 55%);
}
html[data-theme="dark"] .app-header {
  background: rgba(17, 24, 39, 0.86);
}
html[data-theme="dark"] .modal-backdrop {
  background: rgba(2, 6, 23, 0.72);
}
html[data-theme="dark"] .panel-header,
html[data-theme="dark"] .panel-head {
  background: linear-gradient(180deg, var(--panel-head-from), var(--panel-head-to));
}
html[data-theme="dark"] .tone-blue { background: #1e3a5f; color: #93c5fd; }
html[data-theme="dark"] .tone-green { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; }
html[data-theme="dark"] .tone-amber { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
html[data-theme="dark"] .tone-red { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
html[data-theme="dark"] .tone-indigo { background: #1e1b4b; color: #a5b4fc; }
html[data-theme="dark"] .tone-cyan { background: rgba(14, 165, 233, 0.16); color: #7dd3fc; }
html[data-theme="dark"] .tone-violet { background: #2e1065; color: #c4b5fd; }
html[data-theme="dark"] .tone-gray { background: #1e293b; color: #94a3b8; }
html[data-theme="dark"] .status-clocked-in { color: #6ee7b7; }
html[data-theme="dark"] .status-on-break { color: #7dd3fc; }
html[data-theme="dark"] .status-clocked-out { background: #1e293b; color: #94a3b8; }
html[data-theme="dark"] .status-not-in { background: rgba(234, 88, 12, 0.18); color: #fdba74; }
html[data-theme="dark"] .ai-risk.low { color: #6ee7b7; }
html[data-theme="dark"] .ai-risk.medium { color: #fcd34d; }
html[data-theme="dark"] .ai-risk.high { color: #fca5a5; }
html[data-theme="dark"] .live-card.is-break {
  border-color: #1e3a5f;
  background: linear-gradient(180deg, #0c1a2e, var(--surface));
}

/* Tailwind utility remaps — prebuilt CSS has no dark: variants */
html[data-theme="dark"] .bg-white { background-color: var(--surface) !important; }
html[data-theme="dark"] .bg-gray-50 { background-color: var(--bg) !important; }
html[data-theme="dark"] .bg-gray-100 { background-color: var(--surface-2) !important; }
html[data-theme="dark"] .bg-gray-200 { background-color: #334155 !important; color: #e2e8f0 !important; }
html[data-theme="dark"] .hover\:bg-gray-50:hover,
html[data-theme="dark"] .hover\:bg-gray-100:hover { background-color: var(--surface-2) !important; }
html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-gray-800,
html[data-theme="dark"] .text-gray-700 { color: var(--text) !important; }
html[data-theme="dark"] .text-gray-600,
html[data-theme="dark"] .text-gray-500,
html[data-theme="dark"] .text-gray-400 { color: var(--text-muted) !important; }
html[data-theme="dark"] .border-gray-200,
html[data-theme="dark"] .border-gray-100,
html[data-theme="dark"] .border-gray-300,
html[data-theme="dark"] .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: var(--border) !important; }
html[data-theme="dark"] .bg-amber-50 { background: rgba(245, 158, 11, 0.12) !important; }
html[data-theme="dark"] .bg-red-50 { background: rgba(239, 68, 68, 0.12) !important; }
html[data-theme="dark"] .bg-green-50 { background: rgba(16, 185, 129, 0.12) !important; }
html[data-theme="dark"] .bg-blue-50 { background: rgba(37, 99, 235, 0.12) !important; }
html[data-theme="dark"] .bg-yellow-50 { background: rgba(234, 179, 8, 0.12) !important; }
html[data-theme="dark"] .bg-green-100 { background: rgba(16, 185, 129, 0.18) !important; color: #6ee7b7 !important; }
html[data-theme="dark"] .bg-blue-100 { background: rgba(59, 130, 246, 0.18) !important; color: #93c5fd !important; }
html[data-theme="dark"] .bg-red-100 { background: rgba(239, 68, 68, 0.18) !important; color: #fca5a5 !important; }
html[data-theme="dark"] .bg-amber-100 { background: rgba(245, 158, 11, 0.18) !important; color: #fcd34d !important; }
html[data-theme="dark"] .text-green-800,
html[data-theme="dark"] .text-green-700,
html[data-theme="dark"] .text-green-600 { color: #6ee7b7 !important; }
html[data-theme="dark"] .text-blue-800,
html[data-theme="dark"] .text-blue-700,
html[data-theme="dark"] .text-blue-600 { color: #93c5fd !important; }
html[data-theme="dark"] .hover\:text-blue-800:hover { color: #bfdbfe !important; }
html[data-theme="dark"] .text-amber-800,
html[data-theme="dark"] .text-amber-700,
html[data-theme="dark"] .text-amber-600 { color: #fcd34d !important; }
html[data-theme="dark"] .hover\:text-amber-800:hover { color: #fde68a !important; }
html[data-theme="dark"] .text-red-800,
html[data-theme="dark"] .text-red-700,
html[data-theme="dark"] .text-red-600 { color: #fca5a5 !important; }
html[data-theme="dark"] .hover\:text-red-800:hover,
html[data-theme="dark"] .hover\:text-green-800:hover { color: #fecaca !important; }
html[data-theme="dark"] .hover\:text-green-800:hover { color: #a7f3d0 !important; }
html[data-theme="dark"] .border-green-200 { border-color: rgba(16, 185, 129, 0.35) !important; }
html[data-theme="dark"] .border-blue-200 { border-color: rgba(59, 130, 246, 0.35) !important; }
html[data-theme="dark"] .border-red-200 { border-color: rgba(239, 68, 68, 0.35) !important; }
html[data-theme="dark"] .border-amber-200 { border-color: rgba(245, 158, 11, 0.35) !important; }

html[data-theme="dark"] body:not(.kiosk) input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="range"]):not([type="color"]),
html[data-theme="dark"] body:not(.kiosk) select,
html[data-theme="dark"] body:not(.kiosk) textarea {
  background-color: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
html[data-theme="dark"] body:not(.kiosk) input::placeholder,
html[data-theme="dark"] body:not(.kiosk) textarea::placeholder {
  color: var(--text-faint);
}
html[data-theme="dark"] option {
  background-color: var(--surface);
  color: var(--text);
}

html[data-theme="dark"] .toast-item.toast-error {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(248, 113, 113, 0.4);
}
html[data-theme="dark"] .toast-item.toast-warning {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(251, 191, 36, 0.4);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #334155;
  background-clip: content-box;
  border: 2px solid transparent;
}
html[data-theme="dark"] .login-form-card .brand-name { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .kpi-card, .live-card, .punch-card, .ai-board, .ai-item, .coverage-card, .surface-card, .coverage-bar > span {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .kpi-card:hover, .live-card:hover {
    transform: none;
  }
}