@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-glow: rgba(79, 70, 229, 0.15);
  
  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-focus: #818cf8;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.25);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Header & Navigation */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  color: #fff;
  padding: 14px 28px;
  box-shadow: 0 4px 20px rgba(30, 27, 75, 0.25);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.navbtn {
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  border: 0;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.navbtn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.navbtn.active {
  background: #ffffff;
  color: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
}

#userName {
  color: rgba(255, 255, 255, 0.95);
  font-weight: 600;
}

/* Layout */
.container {
  max-width: 1240px;
  margin: 32px auto;
  padding: 0 20px;
}

.card {
  background: var(--bg-card);
  padding: 26px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  transition: var(--transition);
}

.card:hover {
  border-color: #cbd5e1;
}

.narrow {
  max-width: 440px;
  margin: 70px auto;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  border-top: 5px solid var(--primary);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
  align-items: start;
}

/* Typography & Forms */
h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  color: var(--text-main);
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
  color: var(--text-main);
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-muted);
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
}

input, select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text-main);
  background: #fff;
  transition: var(--transition);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px var(--primary-glow);
}

/* Buttons */
.btn {
  margin-top: 16px;
  padding: 11px 22px;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn.secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn.danger {
  background: var(--danger);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.btn.danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

.btn.ok {
  background: var(--success);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.btn.ok:hover {
  background: #059669;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.btn.small {
  margin: 0;
  padding: 6px 14px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-demo {
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  color: #1d4ed8;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 600;
  width: 100%;
  margin-top: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-demo:hover {
  background: #dbeafe;
  border-color: #3b82f6;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}

.alert.error {
  background: var(--danger-bg);
  color: #b91c1c;
  border-color: var(--danger-border);
}

.alert.success {
  background: var(--success-bg);
  color: #065f46;
  border-color: var(--success-border);
}

/* Dashboard Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat {
  background: var(--bg-card);
  padding: 22px 18px;
  border-radius: var(--radius-lg);
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, #a855f7 100%);
}

.stat span {
  display: block;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.stat small {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Slot Grid & Badges */
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search {
  max-width: 320px;
}

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
  background: #f8fafc;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.filters input, .filters select {
  flex: 1;
  min-width: 150px;
  width: auto;
}

.summary {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 10px 0 16px;
  color: var(--text-main);
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-hover);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 10px;
}

.legend {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  margin-right: 5px;
}

.dot.free { background: var(--success); }
.dot.occupied { background: var(--danger); }
.dot.inactive { background: #94a3b8; }

.slot-group {
  margin-bottom: 22px;
}

.slot-group h3 {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 12px;
}

.slot {
  padding: 14px 10px;
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: var(--transition);
  cursor: default;
}

.slot b {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 2px;
}

.slot.free {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: #065f46;
}

.slot.free:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.slot.occupied {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: #991b1b;
}

.slot.occupied:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.slot.inactive {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-size: 0.88rem;
}

th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }

tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: #f8fafc;
}

td.num, th.num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

td input {
  width: 110px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.scroll {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.parked {
  background: var(--warning-bg);
  color: #b45309;
  border: 1px solid var(--warning-border);
}

.badge.exited {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid var(--success-border);
}

.empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 24px;
  text-align: center;
}

/* Tickets & Receipts */
.ticket {
  border: 2px dashed #6366f1;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 12px;
  background: #fafafa;
  position: relative;
}

.ticket .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.92rem;
  border-bottom: 1px dotted #e2e8f0;
}

.ticket .row:last-of-type {
  border-bottom: 0;
}

.ticket .big {
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
  color: var(--primary);
  margin: 12px 0 16px;
  font-family: 'JetBrains Mono', monospace;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.15s ease-out;
}

.modal-box {
  width: 100%;
  max-width: 440px;
  margin: 0;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.3);
  animation: scaleUp 0.15s ease-out;
}

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

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@media print {
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: 2px solid #000;
    background: #fff;
    padding: 24px;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
  }
  nav {
    overflow-x: auto;
    padding-bottom: 6px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
}
