:root {
  color-scheme: dark;
  --bg: #1a1a1a;
  --bg-deep: #111;
  --panel: #252525;
  --panel-strong: #2a2a2a;
  --panel-soft: #222;
  --panel-hover: #333;
  --text: #eee;
  --text-soft: #ccc;
  --muted: #888;
  --line: #333;
  --line-strong: #444;
  --blue: #5865f2;
  --blue-strong: #4752c4;
  --cyan: #5865f2;
  --green: #3ba55c;
  --red: #ed4245;
  --yellow: #faa61a;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 150ms ease;
}

:root.light-mode {
  color-scheme: light;
  --bg: #f5f5f5;
  --bg-deep: #e8e8e8;
  --panel: #fff;
  --panel-strong: #fff;
  --panel-soft: #f0f0f0;
  --panel-hover: #e5e5e5;
  --text: #333;
  --text-soft: #555;
  --muted: #777;
  --line: #ddd;
  --line-strong: #ccc;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg-deep); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
img { display: block; max-width: 100%; }

::selection { color: #fff; background: var(--blue-strong); }

.hidden { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 3000;
  top: 1rem;
  left: 1rem;
  padding: 0.7rem 1rem;
  color: #fff;
  text-decoration: none;
  background: var(--blue-strong);
  border-radius: 10px;
  transform: translateY(-180%);
  transition: transform var(--transition);
}

.skip-link:focus { transform: translateY(0); }

:focus-visible {
  outline: 3px solid rgba(81, 213, 255, 0.7);
  outline-offset: 3px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.6rem 1rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.btn-primary {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}
.btn-primary:hover:not(:disabled) { background: var(--blue-strong); }
.btn-danger { color: #fff; background: var(--red); border-color: var(--red); }
.btn-danger:hover:not(:disabled) { background: #c0392b; }
.btn-ghost { color: var(--text-soft); background: var(--panel-soft); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--panel-hover); }
.btn-sm { min-height: 36px; padding: 0.5rem 0.75rem; font-size: 0.82rem; }
.btn-block { width: 100%; min-height: 52px; }

/* Login */
.auth-screen {
  position: relative;
  display: grid;
  min-height: 100vh;
  padding: 2rem;
  overflow: hidden;
  place-items: center;
  background: var(--bg);
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(610px, 100%);
  padding: clamp(1.5rem, 4vw, 2.6rem);
  overflow: hidden;
}


.brand-block { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 1.25rem; align-items: center; margin-bottom: 1.7rem; }
.brand-logo { width: 78px; aspect-ratio: 1; object-fit: cover; border: 1px solid rgba(207, 214, 255, 0.35); border-radius: 20px; box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3); }
.eyebrow { display: inline-flex; align-items: center; gap: 0.45rem; margin-bottom: 0.65rem; color: var(--cyan); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.brand-block h1 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.1rem); letter-spacing: -0.045em; }
.brand-block p { max-width: 410px; margin: 0.45rem 0 0; }
.auth-features { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 1.7rem; }
.auth-features span { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.52rem 0.65rem; color: var(--text-soft); font-size: 0.78rem; font-weight: 600; background: rgba(148, 163, 184, 0.1); border: 1px solid var(--line); border-radius: 8px; }
.auth-features i { color: var(--cyan); }
.auth-help { display: grid; gap: 0.55rem; margin-top: 1.2rem; }
.auth-help p { margin: 0; font-size: 0.86rem; }
.auth-status { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--green); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.auth-status i { font-size: 0.5rem; animation: blink 1.8s ease-in-out infinite; }

/* Shell */
.app-shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; padding: 1.2rem 1rem 1rem; overflow-y: auto; background: var(--bg-deep); border-right: 1px solid var(--line); flex-direction: column; gap: 1.2rem; }
.light-mode .sidebar { background: #fff; }
.sidebar-top { padding: 0 0.5rem; }
.brand-mini { display: inline-flex; align-items: center; gap: 0.75rem; min-width: 0; }
.brand-mini img { width: 39px; height: 39px; object-fit: cover; border: 1px solid var(--line-strong); border-radius: 12px; }
.brand-mini span { overflow: hidden; color: var(--text); font-size: 0.98rem; font-weight: 800; letter-spacing: -0.02em; text-overflow: ellipsis; white-space: nowrap; }
.nav-menu { display: grid; gap: 0.25rem; }
.nav-section-label { display: block; padding: 0.9rem 0.75rem 0.35rem; color: var(--muted); font-size: 0.65rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.nav-link { position: relative; display: flex; align-items: center; gap: 0.75rem; min-height: 43px; padding: 0.68rem 0.75rem; overflow: hidden; color: var(--muted); font-size: 0.88rem; font-weight: 600; text-decoration: none; border: 1px solid transparent; border-radius: 10px; transition: color var(--transition), background var(--transition), border-color var(--transition), transform var(--transition); }
.nav-link i { width: 1rem; text-align: center; color: currentColor; }
.nav-link:hover { color: var(--text); background: rgba(148, 163, 184, 0.08); }
.nav-link.active { color: #fff; background: var(--blue); border-color: var(--blue); }
.light-mode .nav-link.active { color: #fff; }
.sidebar-footer { display: grid; gap: 0.8rem; margin-top: auto; padding: 0.6rem 0.5rem 0; }
.sidebar-footer .btn { width: 100%; justify-content: flex-start; }
.sidebar-connection { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.72rem; font-weight: 600; }
.sidebar-connection span { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 4px rgba(67, 214, 154, 0.1); }

.main-panel { display: flex; min-width: 0; min-height: 100vh; flex-direction: column; }
.topbar { position: sticky; z-index: 15; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding: 1rem 1.5rem; gap: 1rem; background: var(--bg-deep); border-bottom: 1px solid var(--line); }
.light-mode .topbar { background: #fff; }
.breadcrumbs { display: inline-flex; align-items: center; gap: 0.7rem; min-width: max-content; color: var(--muted); font-size: 0.78rem; }
.breadcrumbs i { color: var(--line-strong); font-size: 0.6rem; }
.breadcrumbs strong { color: var(--text); font-size: 0.95rem; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; min-width: 0; }
.status-chip { display: inline-flex; align-items: center; gap: 0.42rem; padding: 0.46rem 0.65rem; color: var(--green); font-size: 0.76rem; font-weight: 700; white-space: nowrap; background: rgba(67, 214, 154, 0.1); border: 1px solid rgba(67, 214, 154, 0.2); border-radius: 999px; }
.status-chip span { width: 6px; height: 6px; background: currentColor; border-radius: 50%; box-shadow: 0 0 0 3px rgba(67, 214, 154, 0.12); }
.user-widget { display: inline-flex; align-items: center; gap: 0.65rem; min-width: 0; padding-right: 0.25rem; }
.user-widget > div { display: grid; gap: 0.1rem; min-width: 0; }
.user-widget strong { overflow: hidden; max-width: 135px; color: var(--text); font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; }
.user-widget span { overflow: hidden; color: var(--muted); font-size: 0.7rem; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 37px; height: 37px; flex: 0 0 auto; object-fit: cover; background: var(--panel-soft); border: 2px solid var(--line-strong); border-radius: 50%; }
.topbar-clock { padding-left: 0.75rem; color: var(--text-soft); font-variant-numeric: tabular-nums; font-size: 0.82rem; font-weight: 700; border-left: 1px solid var(--line); }
.mobile-menu-btn { display: none; padding: 0.45rem; color: var(--text); font-size: 1.15rem; background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.sidebar-overlay { display: none; }

/* Shared content */
.content-area { width: min(1520px, 100%); margin: 0 auto; padding: clamp(1rem, 2.8vw, 2.35rem); }
.content-area > * + * { margin-top: 1.25rem; }
.dashboard-welcome { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: 0.15rem 0 0.4rem; }
.dashboard-welcome .eyebrow { margin-bottom: 0.45rem; }
.dashboard-welcome h2 { margin-bottom: 0.22rem; }
.dashboard-welcome p { margin: 0; font-size: 0.9rem; }
.shift-mode { display: inline-flex; align-items: center; gap: 0.5rem; width: max-content; padding: 0.55rem 0.75rem; font-size: 0.78rem; font-weight: 800; white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; }
.shift-mode.inactive { color: var(--muted); background: var(--panel-soft); }
.shift-mode.active { color: var(--green); background: rgba(67, 214, 154, 0.1); border-color: rgba(67, 214, 154, 0.24); }
.shift-mode.active i { font-size: 0.5rem; animation: blink 1.8s ease-in-out infinite; }
.shift-mode.break { color: var(--yellow); background: rgba(248, 189, 88, 0.1); border-color: rgba(248, 189, 88, 0.24); }
.glass-card, .stats-card { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.glass-card { padding: 1.5rem; border-radius: var(--radius-lg); }
.hero-card { max-width: 720px; }
.placeholder-panel { display: grid; min-height: calc(100vh - 150px); place-items: center; }
.placeholder-panel .hero-card { text-align: center; }
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.stats-card { position: relative; min-height: 132px; padding: 1.15rem; overflow: hidden; border-radius: var(--radius); transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition); }
.stats-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
.stats-card h3 { margin: 0 0 1.05rem; color: var(--muted); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.025em; text-transform: uppercase; }
.stats-card strong { color: var(--text); font-size: clamp(1.25rem, 2vw, 1.7rem); font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.prominent-card { position: relative; overflow: hidden; background: var(--panel); border-color: var(--line); }
.card-banner { position: relative; z-index: 1; display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; }
.card-banner img { width: 62px; height: 62px; object-fit: cover; border: 2px solid rgba(255, 255, 255, 0.32); border-radius: 18px; }
.card-banner h2 { margin-bottom: 0.3rem; }
.card-banner p { margin: 0; }
.card-footer { position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem; margin-top: 1.45rem; }
.card-footer .btn:last-child { margin-left: auto; }

.shift-timer-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--panel-soft);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.timer-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.shift-timer {
  font-family: 'Courier New', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 10px rgba(67, 214, 154, 0.3);
  min-width: 80px;
  text-align: center;
}

h1, h2, h3 { color: var(--text); line-height: 1.22; }
h1 { font-size: 2rem; }
h2 { margin: 0 0 0.45rem; font-size: clamp(1.25rem, 2vw, 1.55rem); letter-spacing: -0.035em; }
h3 { margin: 0 0 0.7rem; font-size: 1rem; }
p { color: var(--muted); line-height: 1.65; }
small { color: var(--muted); }

.table-card { margin-top: 1rem; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; }
.glass-card.table-card { padding: 0; }
.glass-card > .table-card { padding: 0; }
.table-card table { width: 100%; min-width: 580px; border-spacing: 0; border-collapse: separate; color: var(--text-soft); font-size: 0.84rem; }
.table-card th, .table-card td { padding: 0.9rem 1rem; text-align: left; border-bottom: 1px solid var(--line); }
.table-card th { position: sticky; top: 0; z-index: 1; color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.065em; text-transform: uppercase; background: var(--panel-strong); }
.table-card tbody tr { transition: background var(--transition); }
.table-card tbody tr:hover { background: rgba(148, 163, 184, 0.07); }
.table-card tbody tr:last-child td { border-bottom: 0; }
.table-card .avatar { width: 32px; height: 32px; }

.status-pill { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.6rem; font-size: 0.72rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; border-radius: 999px; }
.status-pill.online { color: var(--green); background: rgba(67, 214, 154, 0.1); border-color: rgba(67, 214, 154, 0.2); }
.status-pill.break { color: var(--yellow); background: rgba(248, 189, 88, 0.1); border-color: rgba(248, 189, 88, 0.2); }
.status-pill.offline { color: var(--red); background: rgba(255, 102, 122, 0.1); border-color: rgba(255, 102, 122, 0.2); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid-1 { grid-template-columns: 1fr; }
.input-group { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.input-group label { color: var(--text-soft); font-size: 0.82rem; font-weight: 700; }
.input-group input, .input-group select, .input-group textarea { width: 100%; padding: 0.75rem 0.85rem; color: var(--text); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; transition: border-color var(--transition), box-shadow var(--transition), background var(--transition); }
.input-group input::placeholder, .input-group textarea::placeholder { color: var(--muted); }
.input-group input:focus, .input-group select:focus, .input-group textarea:focus { outline: none; background: var(--panel-strong); border-color: var(--blue); box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.15); }
.input-group input:disabled { cursor: not-allowed; opacity: 0.63; }
textarea { min-height: 140px; resize: vertical; }
.input-group input.error, .input-group select.error, .input-group textarea.error { border-color: var(--red); }
.input-group input.success, .input-group select.success, .input-group textarea.success { border-color: var(--green); }
.form-feedback { display: none; margin-top: 0.05rem; font-size: 0.78rem; }
.form-feedback.error { display: block; color: var(--red); }
.form-feedback.success { display: block; color: var(--green); }

.notification-area { position: fixed; z-index: 2000; top: 1rem; right: 1rem; display: grid; gap: 0.75rem; max-width: min(390px, calc(100vw - 2rem)); }
.notification-toast { min-width: min(340px, calc(100vw - 2rem)); padding: 0.9rem 1rem; background: var(--panel-strong); border: 1px solid var(--line-strong); border-radius: 13px; box-shadow: var(--shadow-lg); animation: slide-in 280ms ease both; }
.notification-toast strong { display: block; color: var(--text); font-size: 0.88rem; }
.notification-toast p { margin: 0.15rem 0 0; font-size: 0.79rem; }
.notification-toast.fade-out { animation: fade-out 240ms ease both; }

.loading-skeleton { position: relative; overflow: hidden; background: rgba(148, 163, 184, 0.11); border-radius: 8px; }
.loading-skeleton::after { position: absolute; inset: 0; content: ""; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent); transform: translateX(-100%); animation: shimmer 1.5s infinite; }
.loading-spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 700ms linear infinite; }
.btn.loading { pointer-events: none; opacity: 0.72; }
.status-indicator { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); }
.status-indicator span { width: 9px; height: 9px; background: var(--green); border-radius: 50%; }

@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fade-out { to { opacity: 0; transform: translateX(18px); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0.35; } }

@media (max-width: 1150px) {
  .app-shell { grid-template-columns: 236px minmax(0, 1fr); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-clock { display: none; }
}

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 1000; top: 0; bottom: 0; left: 0; width: min(290px, 82vw); height: 100dvh; transform: translateX(-105%); transition: transform 240ms ease; box-shadow: var(--shadow-lg); }
  .sidebar.active { transform: translateX(0); }
  .sidebar-overlay { position: fixed; z-index: 900; inset: 0; background: rgba(3, 7, 18, 0.66); opacity: 0; pointer-events: none; transition: opacity 240ms ease; }
  .sidebar-overlay.active { display: block; opacity: 1; pointer-events: auto; }
  .mobile-menu-btn { display: inline-flex; }
  .topbar { min-height: 68px; }
  .main-panel { min-height: 100dvh; }
}

@media (max-width: 680px) {
  .auth-screen { padding: 1rem; }
  .brand-block { grid-template-columns: 1fr; gap: 1rem; }
  .brand-logo { width: 64px; }
  .auth-features { display: grid; grid-template-columns: 1fr; }
  .topbar { align-items: center; padding: 0.8rem 1rem; }
  .topbar-actions { gap: 0.55rem; }
  .status-chip, .user-widget > div, .btn-danger span { display: none; }
  .btn-danger { min-width: 38px; min-height: 38px; padding: 0.55rem; }
  .breadcrumbs span, .breadcrumbs i { display: none; }
  .content-area { padding: 1rem; }
  .dashboard-welcome { align-items: flex-start; flex-direction: column; }
  .card-grid, .form-grid, .form-grid-1 { grid-template-columns: 1fr; }
  .stats-card { min-height: 112px; }
  .card-banner { grid-template-columns: 1fr; }
  .card-footer { align-items: stretch; }
  .card-footer .btn { width: 100%; }
  .card-footer .btn:last-child { margin-left: 0; }
  .table-card { margin-right: -0.1rem; }
  .notification-area { top: auto; right: 1rem; bottom: 1rem; left: 1rem; }
  .notification-toast { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
