/* ============================================================
   XENT — flat dark minimal theme
   Monochrome first: color is used ONLY for status.
   ============================================================ */

:root {
  --bg: #0A0A0A;
  --panel: #111111;
  --panel-2: #0F0F0F;
  --border: #232323;
  --hover: #1A1A1A;
  --text: #EDEDED;
  --muted: #8A8A8A;
  --accent: #FFFFFF;
  --danger: #E5484D;
  --success: #46A758;
  --radius: 8px;
  --sidebar-w: 240px;
  --content-w: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, Menlo, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }

h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.015em; }
h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

/* Selection + scrollbars, subtle but polished */
::selection { background: #2E2E2E; color: #FFFFFF; }
* { scrollbar-width: thin; scrollbar-color: #262626 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #262626; border-radius: 6px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid #3D3D3D; outline-offset: 2px; border-radius: 4px; }

/* ============================ Background FX =============================== */
/* Sober ambient layer. Static texture: clouds (large turbulence noise), dot
   grid, grain (fine noise). Live part driven by app.js: a soft glow plus a
   smooth canvas trail that follow the pointer — desktop mice only. */

.shell, .auth-wrap { position: relative; z-index: 1; }

.bg-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.bg-clouds {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900'%3E%3Cfilter id='c'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.008' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='900' height='900' filter='url(%23c)'/%3E%3C/svg%3E");
  background-size: 900px 900px;
  opacity: 0.04;
  -webkit-mask-image: radial-gradient(120% 100% at 55% 0%, #000 30%, transparent 90%);
          mask-image: radial-gradient(120% 100% at 55% 0%, #000 30%, transparent 90%);
}
.bg-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(237, 237, 237, 0.05) 1px, transparent 1.4px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(130% 100% at 55% 0%, #000 35%, transparent 85%);
          mask-image: radial-gradient(130% 100% at 55% 0%, #000 35%, transparent 85%);
}
.bg-grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
  opacity: 0.045;
}
.bg-trail { position: absolute; inset: 0; width: 100%; height: 100%; }
.bg-glow {
  position: absolute;
  top: 0; left: 0;
  width: 620px; height: 620px;
  margin: -310px 0 0 -310px;
  background: radial-gradient(circle, rgba(237, 237, 237, 0.05) 0%, rgba(237, 237, 237, 0.018) 38%, transparent 66%);
  will-change: transform;
}

/* Custom crosshair cursor — plain crosshair everywhere, "target-lock" ring
   on clickable things. Applied on desktop pointers (media query) or as soon
   as JS sees a real mouse move (html.fx-mouse), whichever fires first. */
:root {
  --cur-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 22 22'%3E%3Cg fill='none' stroke='%23EDEDED' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M11 1.5v4.2M11 16.3v4.2M1.5 11h4.2M16.3 11h4.2'/%3E%3C/g%3E%3Ccircle cx='11' cy='11' r='1.1' fill='%23EDEDED'/%3E%3C/svg%3E") 11 11, crosshair;
  --cur-t: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 22 22'%3E%3Cg fill='none' stroke='%23EDEDED' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M11 1.5v3.4M11 17.1v3.4M1.5 11h3.4M17.1 11h3.4'/%3E%3Ccircle cx='11' cy='11' r='4.4'/%3E%3C/g%3E%3C/svg%3E") 11 11, pointer;
}
@media (hover: hover) and (pointer: fine) {
  body { cursor: var(--cur-x); }
  a, button, select, .check, [role='button'] { cursor: var(--cur-t); }
  input[type='text'], input[type='email'], input[type='password'],
  input[type='number'], textarea { cursor: text; }
  .btn:disabled { cursor: not-allowed; }
}
html.fx-mouse body { cursor: var(--cur-x); }
html.fx-mouse a, html.fx-mouse button, html.fx-mouse select,
html.fx-mouse .check, html.fx-mouse [role='button'] { cursor: var(--cur-t); }

/* The live followers only exist visually once JS detected a real mouse
   (class fx-live on .bg-fx). Reduced motion keeps them hidden for good. */
.bg-fx:not(.fx-live) .bg-trail, .bg-fx:not(.fx-live) .bg-glow { display: none; }
@media (prefers-reduced-motion: reduce) {
  .bg-trail, .bg-glow { display: none !important; }
}

/* ============================== Shell layout ============================== */

.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: rgba(10, 10, 10, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 24px;
  z-index: 10;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.logo:hover { text-decoration: none; }
.logo-center { justify-content: center; display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; font-size: 16px; }

.logo-img {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: inline-block;
  flex: none;
  background: #000;
}
.logo-img-lg { width: 44px; height: 44px; border-radius: 10px; }

.logo-dot {
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 2px;
  display: inline-block;
  flex: none;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
  transition: background 120ms ease, color 120ms ease;
}
.nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--hover); color: var(--text); }

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-badge {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.plan-name { font-weight: 600; font-size: 13px; }
.plan-exp { color: var(--muted); font-size: 12px; }

.content {
  /* Centered in the space right of the sidebar (falls back to sidebar width
     when the viewport is too narrow, so the content simply fills). */
  margin-left: max(var(--sidebar-w), calc(50% - var(--content-w) / 2 + var(--sidebar-w) / 2));
  padding: 28px 24px 48px;
  max-width: var(--content-w);
}

.topbar { display: none; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

/* ================================ Cards =================================== */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color 160ms ease;
}
.card:hover { border-color: #2C2C2C; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h2 { margin-bottom: 0; }

/* ================================ Buttons ================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px) scale(0.99); }

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #E6E6E6; box-shadow: 0 0 28px rgba(237, 237, 237, 0.08); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--hover); }

.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--hover); border-color: var(--danger); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-big { width: 100%; padding: 14px 20px; font-size: 15px; margin-top: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Card header with actions on the right (e.g. "Purge all lines") */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head form { margin: 0; }

/* Separator + row of small inline buttons (danger zone in admin) */
.sep { border: 0; border-top: 1px solid var(--border); margin: 20px 0 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row form { margin: 0; }

/* Big purchase CTAs (Pricing page) */
.cta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0 10px;
}
.btn-cta {
  padding: 13px 20px;
  font-size: 14px;
  border-radius: 8px;
  gap: 10px;
}
.btn-cta svg { flex: none; }
.btn-cta-primary { background: var(--accent); color: #000; }
.btn-cta-primary:hover { background: #E6E6E6; }
.btn-cta-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-cta-ghost:hover { background: var(--hover); border-color: #3A3A3A; }

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

/* ================================= Forms ================================== */

.field { display: block; margin-bottom: 14px; flex: 1; }
.field > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  padding: 9px 12px;
  transition: border-color 120ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--muted);
}
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238A8A8A' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.check input { accent-color: var(--accent); }

.field-row { display: flex; gap: 16px; }

.form-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-inline .field { margin-bottom: 0; min-width: 180px; }
.form-inline .btn { margin-bottom: 1px; }

.redeem-form { max-width: 420px; }

/* ================================ Tables ================================== */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  word-break: break-all;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--hover); }
.row-current td { background: var(--hover); }

.kv-table th {
  width: 140px;
  text-transform: none;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0;
  border-bottom: 1px solid var(--border);
}
.kv-table td { border-bottom: 1px solid var(--border); }
.kv-table tr:last-child th, .kv-table tr:last-child td { border-bottom: none; }

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

/* ============================ Badges & flashes ============================= */

.badge {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-ok { color: var(--success); border-color: var(--success); }
.badge-danger { color: var(--danger); border-color: var(--danger); }

.flash {
  border: 1px solid var(--border);
  border-left: 2px solid var(--muted);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.flash-success { border-left-color: var(--success); background: rgba(70, 167, 88, 0.06); }
.flash-danger  { border-left-color: var(--danger);  background: rgba(229, 72, 77, 0.06); }

/* ================================= Stats ================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat { padding: 18px 20px; }
.stat-num {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 650;
  line-height: 1.2;
}
.stat-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ============================ Two-column split ============================ */
/* Main card + side panel on wide screens (Generate, Home). */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}
.split > .card, .split-side > .card { margin-bottom: 0; }
.split-side { display: grid; gap: 16px; }
.split-side .btn { margin-top: 10px; }

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

/* ================================ Generate ================================ */

/* The gen card stretches to the height of the side column (no dead space
   under the button) and pins a meta strip to its bottom. */
.gen-card { display: flex; flex-direction: column; }
.gen-card .btn-big { margin-top: 20px; }
.gen-meta {
  margin-top: auto;
  padding-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  border-top: 1px solid var(--border);
}
.gen-meta .k {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 2px;
}
.gen-meta .v { font-size: 13.5px; }
@media (max-width: 640px) {
  .gen-meta { grid-template-columns: 1fr; gap: 10px; }
}

.cooldown-state {
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-ready { background: var(--success); }
.dot-wait { background: #4A4A4A; }
.waiting .mono { color: var(--text); }

.gen-result {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  margin-top: 16px;
  overflow: hidden;
}
.gen-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.gen-result-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}
.gen-result-body code {
  font-size: 15px;
  letter-spacing: 0.01em;
  word-break: break-all;
}
.gen-result textarea {
  border: none;
  background: transparent;
  color: var(--text);
  min-height: 0;
  margin: 0;
}
.gen-result .gen-result-body { flex-wrap: wrap; }

.plan-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); }
.plan-line strong { color: var(--text); font-weight: 600; }
.plan-line .badge { color: var(--text); }

/* ================================= Auth =================================== */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
}
.auth-card h1 { margin-bottom: 18px; text-align: center; }
.auth-card .btn { margin-top: 4px; }
.auth-card .center { margin-top: 14px; }

/* =============================== Code block =============================== */

.code-block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  font-size: 12.5px;
  overflow-x: auto;
  white-space: pre;
  color: var(--muted);
}

/* =============================== Responsive =============================== */

@media (max-width: 768px) {
  .sidebar {
    display: none;
    width: 260px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5);
  }
  .sidebar.open { display: flex; }

  .topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: rgba(10, 10, 10, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 5;
  }
  .topbar-title { font-weight: 700; }

  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
  }
  .nav-toggle span {
    display: block;
    width: 18px; height: 2px;
    background: var(--text);
  }

  .content { margin-left: 0; padding: 20px 16px 40px; }
  .field-row { flex-direction: column; gap: 0; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .form-inline .field { min-width: 0; }
}

@media (min-width: 769px) {
  .nav-toggle { display: none; }
}
