:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #e63946;
  --accent-hover: #c92f3b;
  --green: #2ecc71;
  --amber: #f1c40f;
  --red: #e74c3c;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 700; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.2rem; letter-spacing: .5px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.stat { text-align: center; }
.stat .value { font-size: 1.8rem; font-weight: 800; }
.stat .label { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .5px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); padding: .55rem .9rem; border-radius: 8px;
  font-size: .9rem; font-weight: 600; transition: .15s; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
input, select, textarea {
  width: 100%; padding: .55rem .7rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .9rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(230,57,70,.35); }
.field { margin-bottom: .9rem; }
.form-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: .75rem; letter-spacing: .5px; }
tr:hover td { background: rgba(255,255,255,.02); }
.table-wrap { overflow-x: auto; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab {
  padding: .6rem 1rem; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent;
  font-weight: 600; background: none; border-top: none; border-left: none; border-right: none;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Badges */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-active { background: rgba(46,204,113,.15); color: var(--green); }
.badge-inactive, .badge-expired { background: rgba(231,76,60,.15); color: var(--red); }
.badge-suspended { background: rgba(241,196,15,.15); color: var(--amber); }

/* Progress bars (macros) */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: .5rem; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center;
  justify-content: center; z-index: 100; padding: 1rem;
}
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }

/* Toast */
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--shadow); animation: slideIn .2s ease; max-width: 320px; }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Landing */
.hero { text-align: center; padding: 5rem 1.5rem 3rem; background:
  radial-gradient(circle at 50% 0%, rgba(230,57,70,.18), transparent 60%); }
.hero h1 { font-size: 2.8rem; }
.hero p { color: var(--muted); font-size: 1.15rem; max-width: 600px; margin: 1rem auto 2rem; }
.features { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.feature .icon { font-size: 1.8rem; }
.loader { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; margin: 3rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.small { font-size: .82rem; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.flex-1 { flex: 1; }

/* Accessibility */
/* Visible keyboard focus ring for all interactive elements. */
a:focus-visible, button:focus-visible, .btn:focus-visible, .tab:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
  border-radius: 6px;
}
/* Screen-reader-only text. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
