:root {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-2: #1a2234;
  --border: #263147;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* LOGIN */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: radial-gradient(circle at top, #172554 0%, var(--bg) 65%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
}

.login-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--info);
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 3px 8px;
  border-radius: 99px;
  margin-bottom: 0.75rem;
}

/* TOPBAR & NAV */
.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.clock-pill, .shift-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.role-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  margin-left: 6px;
}

.nav-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  background: #0e1422;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-tab.active {
  background: var(--primary);
  color: #fff;
}

/* LAYOUT & CARDS */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
}

.grid-sidebar {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.card-inner {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt-xs { margin-top: 0.4rem; }
.mt-md { margin-top: 1rem; }
.mb-sm { margin-bottom: 0.75rem; }
.mb-md { margin-bottom: 1.25rem; }

.stack-xs { display: flex; flex-direction: column; gap: 0.4rem; }
.stack-sm { display: flex; flex-direction: column; gap: 0.75rem; }
.stack-md { display: flex; flex-direction: column; gap: 1rem; }

/* FORMS & BUTTONS */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: #d1d5db;
}

input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.92; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 12px; }
.btn-lg { padding: 0.85rem 1.2rem; font-size: 15px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #052e16; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-danger-outline { background: transparent; border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }

/* TIMER & KPIS */
.timer-box {
  background: var(--surface-2);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
}

.timer-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--success);
  margin: 0.3rem 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.kpi-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
}

.kpi-label { font-size: 12px; color: var(--muted); display: block; }
.kpi-num { font-size: 1.25rem; margin-top: 0.2rem; display: block; }
.kpi-green .kpi-num { color: var(--success); }
.kpi-red .kpi-num { color: #f87171; }
.kpi-amber .kpi-num { color: var(--warning); }
.kpi-blue .kpi-num { color: #60a5fa; }

/* TABLES */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 0.6rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
}

/* BADGES & ALERTS */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.badge-success { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.badge-danger { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.badge-warning { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.badge-info { background: rgba(6, 182, 212, 0.18); color: #67e8f9; }
.badge-muted { background: var(--surface-2); color: var(--muted); }

.alert {
  padding: 0.65rem 0.85rem;
  border-radius: 7px;
  font-size: 13px;
}
.alert-danger { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.4); color: #fecaca; }
.alert-info { background: rgba(59, 130, 246, 0.15); border: 1px solid rgba(59, 130, 246, 0.4); color: #bfdbfe; }
.alert-warning { background: rgba(245, 158, 11, 0.15); border: 1px solid rgba(245, 158, 11, 0.4); color: #fde68a; }

.summary-box {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.highlight-row {
  background: var(--surface-2);
  padding: 0.6rem 0.75rem;
  border-radius: 7px;
  border: 1px solid var(--border);
}

.text-green { color: var(--success); }
.text-red { color: #f87171; }
.text-amber { color: var(--warning); }

/* SECTORES DINÁMICOS & GRILLA */
.sectores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.9rem;
}

.sector-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
}

.grilla-legend {
  display: flex;
  gap: 1.25rem;
  font-size: 12px;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
}
.dot-free { background: rgba(16, 185, 129, 0.25); border: 1px solid var(--success); }
.dot-taken { background: rgba(239, 68, 68, 0.25); border: 1px solid var(--danger); }

.grilla-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 0.5rem;
}

.grilla-cell {
  border-radius: 7px;
  padding: 0.55rem 0.4rem;
  text-align: center;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.1s;
}

.grilla-cell.free {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.4);
}
.grilla-cell.free:hover {
  transform: translateY(-2px);
  background: rgba(16, 185, 129, 0.22);
}

.grilla-cell.taken {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
  cursor: default;
}

.grilla-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  font-weight: 800;
  display: block;
}

.grilla-player {
  font-size: 11px;
  color: #fca5a5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.inline-filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.inline-filters input, .inline-filters select {
  width: auto;
}

.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* MODALS & TOAST */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.modal-lg { max-width: 640px; }

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: #1e293b;
  border: 1px solid var(--primary);
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  z-index: 100;
  font-weight: 600;
}
