:root {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --bg-card: #162033;
  --bg-hover: #1e293b;
  --border: #263349;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #a3e635;       /* Padel ball lime */
  --accent-dark: #65a30d;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --sky: #38bdf8;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

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

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

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.75rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--emerald));
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.nav-tabs {
  display: flex;
  gap: 0.4rem;
  background: var(--bg);
  padding: 0.3rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

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

.nav-tab.active {
  background: var(--accent);
  color: #0f172a;
}

.live-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--accent);
  background: rgba(163, 230, 53, 0.1);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(163, 230, 53, 0.25);
}

/* MAIN */
.main-content {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.75rem 3rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

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

.kpi-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi-value.accent { color: var(--accent); }
.kpi-value.emerald { color: var(--emerald); }
.kpi-value.amber { color: var(--amber); }
.kpi-value.sky { color: var(--sky); }

/* SECTION HEADER & PILLS */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.filter-pills, .category-pills {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.pill {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.pill:hover { color: var(--text); border-color: var(--text-muted); }
.pill.active { background: var(--accent); color: #0f172a; border-color: var(--accent); }

/* COURTS GRID */
.courts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.2rem;
}

.court-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}

.court-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--emerald);
}

.court-card.status-in_use::before { background: var(--amber); }
.court-card.status-maintenance::before { background: var(--rose); }

.court-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.court-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.court-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-available { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.badge-in_use { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.badge-maintenance { background: rgba(244, 63, 94, 0.15); color: var(--rose); }
.badge-active { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.badge-inactive { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

.session-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.session-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}

.session-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
}

.session-items-preview {
  border-top: 1px dashed var(--border);
  padding-top: 0.55rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 110px;
  overflow-y: auto;
}

.session-item-line {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.session-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 0.55rem;
  font-weight: 700;
  font-size: 1rem;
}

.court-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
}

/* BUTTONS & INPUTS */
.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 0.38rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: #0f172a; }
.btn-primary:hover:not(:disabled) { background: #bef264; }

.btn-emerald { background: var(--emerald); color: #042f2e; }
.btn-emerald:hover:not(:disabled) { opacity: 0.9; }

.btn-amber { background: var(--amber); color: #1c1917; }
.btn-amber:hover:not(:disabled) { opacity: 0.9; }

.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--text-muted); }

.btn-danger { background: rgba(244, 63, 94, 0.15); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(244, 63, 94, 0.25); }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-input { max-width: 280px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* POS LAYOUT */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 960px) {
  .pos-layout { grid-template-columns: 1fr; }
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 0.9rem;
}

.product-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: 0.15s;
  text-align: left;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.product-tile:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.product-tile:disabled { opacity: 0.4; cursor: not-allowed; }
.product-tile-cat { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; }
.product-tile-name { font-weight: 600; font-size: 0.95rem; }
.product-tile-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 0.4rem;
}
.product-tile-price { color: var(--accent); font-weight: 700; }
.product-tile-stock { font-size: 0.75rem; color: var(--text-muted); }

.pos-cart {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: sticky;
  top: 84px;
}

.pos-cart h3 { margin-bottom: 1rem; }

.cart-items {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.86rem;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cart-footer {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  margin-bottom: 0.9rem;
}

/* ADMIN & TABLES */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 1.25rem;
}

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

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

.card h3 { margin-bottom: 1rem; }

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
}

/* HISTORY */
.date-filter {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.date-filter .input { width: auto; }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.history-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1.5rem 0;
  text-align: center;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop.hidden { display: none; }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-body { padding: 1.25rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1rem;
}

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 60;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}

.toast.error { border-left-color: var(--rose); }
