/* ═══════════════════════════════════════════════════════════
   VARIABLES & RESET
═══════════════════════════════════════════════════════════ */
:root {
  --primary:       #6366F1;
  --primary-dark:  #4F46E5;
  --primary-light: #EEF2FF;
  --primary-glow:  rgba(99,102,241,0.18);

  --sidebar-bg:    #0F172A;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-text:  #94A3B8;
  --sidebar-head:  #F8FAFC;

  --bg:            #F1F5F9;
  --card:          #FFFFFF;
  --border:        #E2E8F0;
  --text:          #0F172A;
  --text-2:        #334155;
  --text-muted:    #64748B;

  --green:         #10B981;
  --green-bg:      #ECFDF5;
  --amber:         #F59E0B;
  --amber-bg:      #FFFBEB;
  --red:           #EF4444;
  --red-bg:        #FEF2F2;
  --blue:          #3B82F6;
  --blue-bg:       #EFF6FF;
  --purple:        #8B5CF6;
  --purple-bg:     #F5F3FF;

  --radius:        14px;
  --radius-sm:     8px;
  --radius-lg:     20px;
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.05);
  --shadow:        0 1px 4px rgba(15,23,42,0.06), 0 4px 20px rgba(15,23,42,0.04);
  --shadow-md:     0 4px 16px rgba(15,23,42,0.08), 0 16px 48px rgba(15,23,42,0.06);
  --shadow-lg:     0 20px 60px rgba(15,23,42,0.14);

  --sidebar-w:     264px;
  --header-h:      60px;
  --bottom-nav-h:  64px;
  --t:             0.18s ease;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

input, select, textarea, button { font-family: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }


/* ═══════════════════════════════════════════════════════════
   UTILITIES
═══════════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.screen { width: 100%; min-height: 100vh; }
.screen.active { display: flex; }
.screen.hidden { display: none; }

.required { color: var(--red); }


/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  transition: all var(--t);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 16px var(--primary-glow); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); border-color: #CBD5E1; }

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

.btn-full { width: 100%; justify-content: center; }
.btn-sm  { height: 34px; padding: 0 12px; font-size: .8125rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }
.btn-icon svg { width: 17px; height: 17px; }


/* ═══════════════════════════════════════════════════════════
   SPINNER
═══════════════════════════════════════════════════════════ */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ═══════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-2);
}
.field input,
.field select {
  height: 42px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--text);
  background: #fff;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}
.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.field input::placeholder { color: var(--text-muted); }

.field--inline { flex-direction: row; align-items: center; gap: 10px; }
.field--inline label { white-space: nowrap; font-size: .85rem; }
.field--inline select { flex: 1; }

.input-group { position: relative; }
.input-group input { width: 100%; padding-right: 44px; }
.input-toggle {
  position: absolute; right: 0; top: 0;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: color var(--t);
}
.input-toggle:hover { color: var(--text); }
.input-toggle svg { width: 18px; height: 18px; }

.fields-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 480px) { .fields-2col { grid-template-columns: 1fr; } }


/* ═══════════════════════════════════════════════════════════
   ALERTS
═══════════════════════════════════════════════════════════ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
}
.alert-error {
  background: var(--red-bg);
  color: #B91C1C;
  border: 1px solid #FCA5A5;
}
.alert-success {
  background: var(--green-bg);
  color: #065F46;
  border: 1px solid #6EE7B7;
}


/* ═══════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(226,232,240,0.8);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}
.card-title {
  font-size: .9375rem;
  font-weight: 700;
  color: var(--text);
}
.card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}


/* ═══════════════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════════════ */
.table-scroll { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #FAFAFA;
}
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--t); }
.data-table tbody tr:hover { background: var(--bg); }

.td-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px !important;
  font-size: .9rem;
}
.th-actions { width: 100px; }

.worker-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.worker-cell .w-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
  flex-shrink: 0;
}
.worker-cell .w-info .w-name { font-weight: 600; font-size: .875rem; }
.worker-cell .w-info .w-phone { font-size: .75rem; color: var(--text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .74rem;
  font-weight: 600;
}
.badge--active { background: var(--green-bg); color: #065F46; }
.badge--inactive { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

.badge-count {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg);
  border-radius: 20px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}


/* ═══════════════════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════════════════ */
.login-bg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.08) 0%, transparent 50%),
    linear-gradient(135deg, #F8FAFC 0%, #EEF2FF 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(226,232,240,0.8);
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fadeUp .4s ease;
}

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

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}
.login-logo-badge {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
  border-radius: 14px;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.login-logo-name { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.login-logo-sub  { font-size: .78rem; color: var(--text-muted); }

.login-title { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.login-sub   { font-size: .9rem; color: var(--text-muted); margin-top: -14px; }

.login-card form { display: flex; flex-direction: column; gap: 16px; }


/* ═══════════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════════ */
#app-shell {
  flex: 1;
  position: relative;
}


/* ═══════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--t);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.brand-badge {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: 12px;
  color: #fff;
  font-size: .875rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.brand-name { font-size: .925rem; font-weight: 700; color: var(--sidebar-head); display: block; }
.brand-role { font-size: .72rem; color: var(--sidebar-text); display: block; margin-top: 1px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 20px;
  margin: 10px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
}
.s-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.s-name  { font-size: .8rem; font-weight: 600; color: var(--sidebar-head); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.s-email { font-size: .7rem; color: var(--sidebar-text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

.sidebar-section-label {
  padding: 14px 20px 6px;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: rgba(148,163,184,0.5);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 12px;
  list-style: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--t);
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active {
  background: var(--primary-glow);
  color: #fff;
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--primary); }

.nav-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.nav-icon svg { width: 18px; height: 18px; }

.nav-badge {
  margin-left: auto;
  background: var(--green);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px;
}

.sidebar-bottom {
  padding: 16px 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conn-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  font-size: .78rem;
  color: var(--sidebar-text);
}
.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background .5s;
}
.conn-dot.on  { background: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.conn-dot.off { background: #475569; }

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--t);
}
.sidebar-logout svg { width: 18px; height: 18px; }
.sidebar-logout:hover { background: rgba(239,68,68,0.12); color: #FC8181; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}


/* ═══════════════════════════════════════════════════════════
   MAIN WRAPPER
═══════════════════════════════════════════════════════════ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin var(--t);
}

.top-header {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

.hamburger {
  display: none;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background var(--t);
  flex-shrink: 0;
}
.hamburger:hover { background: var(--bg); }
.hamburger svg { width: 20px; height: 20px; }

.header-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.header-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.content {
  flex: 1;
  padding: 28px 28px 40px;
}


/* ═══════════════════════════════════════════════════════════
   PAGE HEADER
═══════════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--text);
}
.page-sub {
  font-size: .875rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.view { animation: fadeView .25s ease; }
@keyframes fadeView {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ═══════════════════════════════════════════════════════════
   STATS GRID
═══════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(226,232,240,0.8);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--t), box-shadow var(--t);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon-wrap {
  width: 50px; height: 50px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon-wrap svg { width: 22px; height: 22px; }
.stat--blue   { background: var(--blue-bg);   color: var(--blue); }
.stat--green  { background: var(--green-bg);  color: var(--green); }
.stat--amber  { background: var(--amber-bg);  color: var(--amber); }
.stat--purple { background: var(--purple-bg); color: var(--purple); }

.stat-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
}


/* ═══════════════════════════════════════════════════════════
   SECTION TITLE
═══════════════════════════════════════════════════════════ */
.section-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--red-bg);
  color: var(--red);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 20px;
}
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse-dot 1.5s infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .6; transform: scale(1.4); }
}


/* ═══════════════════════════════════════════════════════════
   WORKERS GRID (Dashboard real-time)
═══════════════════════════════════════════════════════════ */
.workers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.worker-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform var(--t), box-shadow var(--t);
  position: relative;
  overflow: hidden;
}
.worker-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--border);
  transition: background .4s;
}
.worker-card.wc--active::before  { background: var(--green); }
.worker-card.wc--paused::before  { background: var(--amber); }
.worker-card.wc--idle::before    { background: #CBD5E1; }

.worker-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.wc-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wc-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; font-weight: 700;
  flex-shrink: 0;
}
.wc-avatar.av--active { background: var(--green-bg); color: var(--green); }
.wc-avatar.av--paused { background: var(--amber-bg); color: var(--amber); }
.wc-avatar.av--idle   { background: var(--bg); color: var(--text-muted); }

.wc-info { flex: 1; min-width: 0; }
.wc-name { font-size: .95rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-email{ font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wc-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.wcs--active { background: var(--green-bg); color: var(--green); }
.wcs--paused { background: var(--amber-bg); color: var(--amber); }
.wcs--idle   { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

.wc-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg);
  border-radius: 10px;
  padding: 12px;
}
.wc-timer-val {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-feature-settings: 'tnum';
}
.wc-timer-val.tv--active { color: var(--green); }
.wc-timer-val.tv--paused { color: var(--amber); }

.wc-meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.wc-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: .78rem;
  color: var(--text-muted);
}
.wc-meta-row svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: 1px; }
.wc-meta-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Skeleton loading */
.loading-placeholder { display: contents; }
.skeleton {
  height: 180px;
  background: linear-gradient(90deg, var(--border) 25%, #F8FAFC 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { to { background-position: -200% 0; } }

.empty-workers {
  grid-column: 1/-1;
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: .95rem;
}
.empty-workers svg { width: 40px; height: 40px; margin-bottom: 12px; color: var(--border); display: block; margin-inline: auto; }


/* ═══════════════════════════════════════════════════════════
   SEARCH & FILTER
═══════════════════════════════════════════════════════════ */
.search-box {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-box svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pill {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1.5px solid var(--border);
  transition: all var(--t);
}
.pill:hover { border-color: var(--primary); color: var(--primary); }
.pill.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }


/* ═══════════════════════════════════════════════════════════
   REPORTS
═══════════════════════════════════════════════════════════ */
.report-filter-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
  overflow: visible;
}
.period-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
  border: 1px solid var(--border);
}
.period-tab {
  padding: 7px 16px;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--t);
}
.period-tab:hover { color: var(--text); }
.period-tab.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }

.filters-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.filters-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.report-empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.report-empty-icon {
  width: 64px; height: 64px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  color: var(--border);
}
.report-empty-icon svg { width: 30px; height: 30px; }
.report-empty p { font-size: .95rem; }

.report-kpi-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px 22px;
  box-shadow: var(--shadow);
  flex: 1;
  min-width: 150px;
}
.kpi-value { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.kpi-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.kpi-card.kpi--primary .kpi-value { color: var(--primary); }
.kpi-card.kpi--green   .kpi-value { color: var(--green); }
.kpi-card.kpi--purple  .kpi-value { color: var(--purple); }

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.report-grid .card { padding: 0 0 20px; }
.report-grid .card-head { padding: 18px 20px 12px; }

.chart-card .card-head { padding: 18px 20px 10px; }
.chart-wrap { padding: 16px 20px; }
#report-chart { max-height: 280px; }

#detail-card { padding: 0 0 8px; }
#detail-card .card-head { padding: 18px 20px 12px; }


/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideModal .22s ease;
}
@keyframes slideModal {
  from { opacity: 0; transform: scale(.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--card);
  z-index: 1;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all var(--t);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close svg { width: 18px; height: 18px; }

.modal-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--border);
}


/* ═══════════════════════════════════════════════════════════
   TOASTS
═══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  padding: 13px 18px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  min-width: 260px;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn .25s ease;
  pointer-events: auto;
}
.toast::before {
  content: '';
  width: 4px;
  min-height: 32px;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: stretch;
}
.toast--success::before { background: var(--green); }
.toast--error::before   { background: var(--red); }
.toast--info::before    { background: var(--primary); }
.toast.removing { animation: toastOut .2s ease forwards; }

@keyframes toastIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(20px); } }


/* ═══════════════════════════════════════════════════════════
   BOTTOM NAV (mobile)
═══════════════════════════════════════════════════════════ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 16px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 12px;
  transition: all var(--t);
  min-width: 64px;
}
.bnav-item svg { width: 22px; height: 22px; transition: transform var(--t); }
.bnav-item:hover  { color: var(--primary); }
.bnav-item.active { color: var(--primary); }
.bnav-item.active svg { transform: scale(1.1); }


/* ═══════════════════════════════════════════════════════════
   PRINT STYLES
═══════════════════════════════════════════════════════════ */
@media print {
  .sidebar, .top-header, .bottom-nav,
  .report-filter-card, .page-header button,
  .toast-container, .modal-backdrop { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  .data-table td, .data-table th { padding: 8px 12px; }
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤ 1100px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .report-grid { grid-template-columns: 1fr; }
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 768px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay.visible {
    display: block;
  }

  .main-wrapper { margin-left: 0; padding-bottom: var(--bottom-nav-h); }
  .hamburger  { display: flex; }
  .bottom-nav { display: flex; }

  .content { padding: 20px 16px 32px; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-value { font-size: 1.4rem; }

  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header .btn-sm { align-self: flex-end; }

  .period-tabs { flex-wrap: wrap; width: 100%; }
  .period-tab { flex: 1; min-width: 80px; text-align: center; }

  .filters-actions { flex-direction: column; align-items: stretch; }
  .filters-actions .btn { justify-content: center; }
  .field--inline { flex-direction: column; align-items: stretch; }

  .card-toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }

  .toast-container { bottom: calc(var(--bottom-nav-h) + 12px); right: 12px; left: 12px; }
  .toast { min-width: unset; }

  .fields-2col { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-icon-wrap { width: 42px; height: 42px; }
  .stat-icon-wrap svg { width: 18px; height: 18px; }
  .stat-value { font-size: 1.25rem; }
  .workers-grid { grid-template-columns: 1fr; }
}
