:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --panel: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  font-size: 14px;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 100%);
}
.login-card {
  background: var(--panel);
  padding: 36px;
  border-radius: 12px;
  width: 360px;
  box-shadow: 0 20px 40px rgba(0,0,0,.3);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }

/* ---------- Layout ---------- */
.app { display: none; min-height: 100vh; }
.app.active { display: flex; }
.sidebar {
  width: 230px;
  background: var(--bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}
.sidebar .brand { padding: 0 20px 20px; font-size: 17px; font-weight: 700; color: #fff; }
.sidebar .brand small { display:block; font-size: 11px; font-weight: 400; color: #64748b; }
.nav-item {
  padding: 11px 20px; cursor: pointer; border: none; background: none;
  color: #cbd5e1; text-align: left; width: 100%; font-size: 14px;
}
.nav-item:hover { background: var(--bg-2); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar .spacer { flex: 1; }
.user-box { padding: 14px 20px; border-top: 1px solid var(--bg-2); font-size: 12px; }
.user-box .name { color: #fff; font-weight: 600; }
.user-box .role { color: #64748b; text-transform: uppercase; font-size: 10px; letter-spacing: .5px; }

.main { flex: 1; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h2 { margin: 0; font-size: 18px; }
.content { padding: 24px; overflow: auto; }

/* ---------- Components ---------- */
.btn {
  background: var(--primary); color: #fff; border: none; padding: 9px 16px;
  border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.secondary:hover { background: #cbd5e1; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

label { display: block; font-size: 12px; font-weight: 600; margin: 12px 0 4px; color: #334155; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 14px; font-family: inherit; background: #fff;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f8fafc; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.draft { background: #e2e8f0; color: #475569; }
.badge.upcoming { background: #dbeafe; color: #1d4ed8; }
.badge.live { background: #dcfce7; color: #15803d; }
.badge.closed { background: #fee2e2; color: #b91c1c; }
.badge.ready { background: #dbeafe; color: #1d4ed8; }
.badge.sold { background: #dcfce7; color: #15803d; }
.badge.passed, .badge.withdrawn { background: #fef3c7; color: #92400e; }
.badge.role { background: #ede9fe; color: #6d28d9; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.toolbar .filters { display: flex; gap: 8px; align-items: center; }
.toolbar select { width: auto; }

.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 8px; }
.stat { background: #fff; border-radius: 10px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat .n { font-size: 30px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; }
.muted { color: var(--muted); }
.actions { display: flex; gap: 6px; }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.55);
  align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 50;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 520px; max-width: 100%;
  padding: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.4);
}
.modal h3 { margin: 0 0 4px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.empty { text-align: center; padding: 40px; color: var(--muted); }
.hidden { display: none !important; }
