:root {
  --bg: #f8f8f5;
  --bg2: #f0f0ec;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.08);
  --gold: #1a56db;
  --gold-dim: #1044b8;
  --text: #111218;
  --muted: #6b6f80;
  --radius: 14px;
  --font-head: 'Bahnschrift', 'DIN Alternate', 'Franklin Gothic Medium', 'Arial Narrow', sans-serif;
  --font-body: 'Bahnschrift', 'DIN Alternate', 'Franklin Gothic Medium', 'Arial Narrow', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  padding-top: 96px;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

.container { position: relative; z-index: 1; padding: 1.5rem 2.5rem 2.5rem; }
h1, h2, h3 { font-family: var(--font-head); margin: 0 0 .6rem 0; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
.muted { color: var(--muted); font-size: .92rem; }
.small { font-size: .82rem; }
.mt-1 { margin-top: .8rem; }
.hidden { display: none !important; }

body > h1,
body > .card,
body > .grid,
body > .stat-grid,
body > section,
body > #nav {
  position: relative;
  z-index: 1;
  margin-left: 2.5rem;
  margin-right: 2.5rem;
}
body > h1 { display: none; }

/* ───────────── NAV ───────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 2.5rem;
  background: rgba(248,248,245,.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.logo-text {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
}
.logo-text span { color: var(--gold); }
.nav__links { display:flex; flex-wrap:wrap; gap:.45rem; list-style:none; }
.nav__links a {
  display: inline-block;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .4rem .8rem;
  font-size: .82rem;
  background: var(--surface);
  transition: .15s;
}
.nav__links a:hover { color: var(--text); border-color: rgba(26,86,219,.35); }
.nav__links a.active {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}
.nav__links a.nav__logout {
  background: transparent;
  border-color: rgba(220,70,90,.4);
  color: #c4324c;
}
.nav__links a.nav__logout:hover { background: #c4324c; color: #fff; border-color: #c4324c; }

/* ───────────── HERO ───────────── */
.page-hero {
  position: relative;
  z-index: 1;
  margin: .7rem 2.5rem 1rem;
  padding: 1.4rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(26,86,219,.12), rgba(26,86,219,.03));
}
.page-hero__kicker {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .7rem;
  color: var(--gold);
  margin-bottom: .45rem;
}
.page-hero__title { margin: 0; font-size: clamp(1.35rem, 2.4vw, 2rem); }
.page-hero__sub { margin-top: .35rem; color: var(--muted); font-size: .92rem; }

body[data-page="dashboard"] .page-hero { background: linear-gradient(135deg, rgba(26,86,219,.18), rgba(26,86,219,.04)); }
body[data-page="login"]     .page-hero { background: linear-gradient(135deg, rgba(26,86,219,.18), rgba(16,68,184,.06)); }
body[data-page="users"]     .page-hero { background: linear-gradient(135deg, rgba(65,120,255,.16), rgba(65,120,255,.04)); }
body[data-page="tenants"]   .page-hero { background: linear-gradient(135deg, rgba(110,92,255,.16), rgba(110,92,255,.04)); }
body[data-page="locations"] .page-hero { background: linear-gradient(135deg, rgba(0,140,200,.16), rgba(0,140,200,.04)); }
body[data-page="players"]   .page-hero { background: linear-gradient(135deg, rgba(0,160,140,.16), rgba(0,160,140,.04)); }
body[data-page="media"]     .page-hero { background: linear-gradient(135deg, rgba(185,120,30,.16), rgba(185,120,30,.04)); }
body[data-page="playlists"] .page-hero { background: linear-gradient(135deg, rgba(200,90,40,.16), rgba(200,90,40,.04)); }
body[data-page="campaigns"] .page-hero { background: linear-gradient(135deg, rgba(220,70,90,.16), rgba(220,70,90,.04)); }
body[data-page="schedules"] .page-hero { background: linear-gradient(135deg, rgba(120,100,220,.16), rgba(120,100,220,.04)); }
body[data-page="audit"]     .page-hero { background: linear-gradient(135deg, rgba(90,90,110,.16), rgba(90,90,110,.04)); }

/* ───────────── CARDS ───────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: .9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.04);
}
.card h3 { margin-bottom: .5rem; }
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: .8rem;
  flex-wrap: wrap;
}
.card__header h3 { margin: 0; font-size: 1.05rem; }
.card__tools { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.grid { display:grid; grid-template-columns: repeat(auto-fit,minmax(340px,1fr)); gap: .9rem; }
.grid--2 { grid-template-columns: repeat(auto-fit,minmax(420px,1fr)); }
.row { display:flex; gap:.55rem; flex-wrap:wrap; align-items: center; }
.row > * { flex:1; min-width: 140px; }

/* ───────────── STAT-CARDS ───────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .8rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.stat-card__label {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .68rem;
  color: var(--muted);
  font-weight: 700;
}
.stat-card__value {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.02em;
}
.stat-card__sub { font-size: .75rem; color: var(--muted); }
.stat-card--blue  { border-left-color: #1a56db; }
.stat-card--blue  .stat-card__value { color: #1a56db; }
.stat-card--green { border-left-color: #00a08c; }
.stat-card--green .stat-card__value { color: #00a08c; }
.stat-card--amber { border-left-color: #b9781e; }
.stat-card--amber .stat-card__value { color: #b9781e; }
.stat-card--red   { border-left-color: #dc465a; }
.stat-card--red   .stat-card__value { color: #dc465a; }

/* ───────────── BADGES ───────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid transparent;
}
.badge--green { background: #e7f7f3; color: #007561; border-color: #00a08c33; }
.badge--red   { background: #fde8ec; color: #b3263c; border-color: #dc465a33; }
.badge--amber { background: #fdf2e3; color: #8e5b18; border-color: #b9781e33; }
.badge--blue  { background: #e7eeff; color: #1044b8; border-color: #1a56db33; }
.badge--gray  { background: #f0f0ec; color: #6b6f80; border-color: rgba(0,0,0,.08); }

/* ───────────── INPUTS / BUTTONS ───────────── */
input, select, button, textarea {
  padding: .65rem .75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
}
input:disabled, select:disabled { background: #f4f4f1; color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
textarea { width: 100%; min-height: 95px; }
button {
  cursor: pointer;
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
  font-weight: 600;
}
button:hover { background: var(--gold-dim); border-color: var(--gold-dim); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: .35rem .8rem;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: rgba(26,86,219,.35); }
.btn-sm {
  padding: .3rem .55rem;
  font-size: .8rem;
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-sm:hover { background: var(--gold); color: #fff; border-color: var(--gold); }

/* ───────────── TABLES ───────────── */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .88rem; }
th { font-weight: 700; color: var(--text); background: #fafafa; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: none; }
code { background: #f2f4f8; padding: 2px 6px; border-radius: 8px; font-size: .82rem; }
a { color: var(--gold); text-decoration: none; }

body[data-page="dashboard"] .card { border-left: 4px solid #1a56db; }
body[data-page="users"]     .card { border-left: 4px solid #4178ff; }
body[data-page="tenants"]   .card { border-left: 4px solid #6e5cff; }
body[data-page="locations"] .card { border-left: 4px solid #008cc8; }
body[data-page="players"]   .card { border-left: 4px solid #00a08c; }
body[data-page="media"]     .card { border-left: 4px solid #b9781e; }
body[data-page="playlists"] .card { border-left: 4px solid #c85a28; }
body[data-page="campaigns"] .card { border-left: 4px solid #dc465a; }
body[data-page="schedules"] .card { border-left: 4px solid #7864dc; }
body[data-page="audit"]     .card { border-left: 4px solid #5a5a6e; }

body[data-page="users"]     th { background: #eef3ff; }
body[data-page="tenants"]   th { background: #f1efff; }
body[data-page="locations"] th { background: #e9f8ff; }
body[data-page="players"]   th { background: #e9fbf8; }
body[data-page="media"]     th { background: #fff6ea; }
body[data-page="playlists"] th { background: #fff0eb; }
body[data-page="campaigns"] th { background: #ffeef1; }
body[data-page="schedules"] th { background: #f2efff; }
body[data-page="audit"]     th { background: #f2f2f5; }

/* ───────────── LOGIN ───────────── */
body[data-page="login"] .login-shell {
  position: relative;
  z-index: 1;
  margin: 0 2.5rem;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 1rem;
}
body[data-page="login"] .login-shell .card:first-child {
  min-height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(145deg, #ffffff, #f6f8ff);
}
body[data-page="login"] .login-shell .card:last-child {
  border-left: 4px solid var(--gold);
}

/* ───────────── MODAL ───────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20,22,32,.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.modal__box {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from{transform:translateY(15px);opacity:0} to{transform:translateY(0);opacity:1} }
.modal__head {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal__head h3 { margin: 0; font-size: 1.05rem; }
.modal__close {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 1.5rem;
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.modal__close:hover { background: var(--bg2); color: var(--text); }
.modal__body { padding: 1.2rem; }
.modal__foot {
  padding: .9rem 1.2rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .5rem;
  background: var(--bg);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .8rem;
}
.form-grid label {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: .3rem;
}
.form-grid input, .form-grid select { width: 100%; }

/* ───────────── TOAST ───────────── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.toast-item {
  padding: .7rem 1rem;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  animation: slideInRight .25s ease;
  pointer-events: auto;
  max-width: 360px;
  border: 1px solid transparent;
}
@keyframes slideInRight { from{transform:translateX(110%);opacity:0} to{transform:translateX(0);opacity:1} }
.toast--ok  { background: #e7f7f3; color: #007561; border-color: #00a08c55; }
.toast--err { background: #fde8ec; color: #b3263c; border-color: #dc465a55; }

/* ───────────── RESPONSIVE ───────────── */
@media (max-width: 800px) {
  .container { padding: 1rem; }
  .nav { padding: .8rem 1rem; align-items: flex-start; flex-direction: column; }
  body { padding-top: 160px; }
  body > h1, body > .card, body > .grid, body > .stat-grid, body > section, body > #nav,
  .page-hero { margin-left: 1rem; margin-right: 1rem; }
  body[data-page="login"] .login-shell { margin: 0 1rem; grid-template-columns: 1fr; }
  .stat-card__value { font-size: 1.6rem; }
}
