/* =========================================================================
   CodyStore design system
   Ink-dark base, amber-gold as the single primary signal (the "key" color),
   teal as a secondary/status accent. Space Grotesk for display type,
   Inter for body/UI, JetBrains Mono for license keys, prices, and code.
   ========================================================================= */

:root {
  /* Ink scale */
  --ink-950: #0A0C12;
  --ink-900: #12151D;
  --ink-800: #1A1E29;
  --ink-700: #232838;
  --ink-600: #2E3448;
  --ink-500: #3B4258;

  /* Text */
  --text-hi: #F2F3F7;
  --text-mid: #9AA3B8;
  --text-low: #656E85;

  /* Signal colors */
  --gold: #FFB020;
  --gold-hi: #FFC85C;
  --teal: #2DD4BF;
  --blue: #5B8CFF;
  --red: #FF5C72;

  /* Surfaces */
  --paper: #EFF1F5;
  --paper-card: #FFFFFF;
  --paper-text: #1A1E29;
  --paper-text-mid: #5A6178;
  --paper-border: #DDE1EA;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;

  --shadow-card: 0 1px 2px rgba(10,12,18,.04), 0 8px 24px rgba(10,12,18,.06);
  --shadow-pop: 0 12px 40px rgba(10,12,18,.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--paper-text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0 0 .4em; letter-spacing: -0.01em; }
p { margin: 0 0 1em; line-height: 1.6; color: var(--paper-text-mid); }
a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.mono { font-family: var(--font-mono); }

/* ---------------------------------------------------------------------
   App shell: dark sidebar + light content, collapsing to an overlay
   drawer on mobile.
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--ink-950);
  color: var(--text-hi);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
}
.app-sidebar__brand .mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(145deg, var(--gold), #E08F00);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: var(--ink-950);
}
.app-sidebar__brand .name { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.app-sidebar__brand .name small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 11px; color: var(--text-low); }

.app-nav { flex: 1; overflow-y: auto; padding: 8px 12px; }
.app-nav__group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-low); padding: 14px 10px 6px; }
.app-nav a, .app-nav button.navlink {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--text-mid); text-decoration: none;
  padding: 9px 10px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  margin-bottom: 2px; transition: background .12s, color .12s;
}
.app-nav a:hover, .app-nav button.navlink:hover { background: var(--ink-800); color: var(--text-hi); }
.app-nav a.active, .app-nav button.navlink.active { background: var(--ink-800); color: var(--gold-hi); }
.app-nav svg { width: 17px; height: 17px; flex-shrink: 0; }

.app-sidebar__foot { padding: 14px; border-top: 1px solid var(--ink-800); }
.rank-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-mid); }
.rank-dot { width: 7px; height: 7px; border-radius: 50%; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  height: 60px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; background: var(--paper-card); border-bottom: 1px solid var(--paper-border);
  position: sticky; top: 0; z-index: 30;
}
.app-topbar__title { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.app-topbar__actions { display: flex; align-items: center; gap: 12px; }
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.menu-toggle svg { width: 22px; height: 22px; }

.app-content { padding: 24px; max-width: 1180px; width: 100%; margin: 0 auto; }

.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10,12,18,.55); z-index: 39;
}

@media (max-width: 880px) {
  .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-pop); }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }
  .menu-toggle { display: inline-flex; }
  .app-content { padding: 16px; }
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600; font-family: var(--font-body);
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: transform .08s, filter .12s, background .12s;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); color: #241800; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-dark { background: var(--ink-950); color: var(--text-hi); }
.btn-dark:hover { background: var(--ink-800); }
.btn-ghost { background: transparent; border-color: var(--paper-border); color: var(--paper-text); }
.btn-ghost:hover { background: var(--paper); }
.btn-danger { background: rgba(255,92,114,.12); color: #C4223A; }
.btn-danger:hover { background: rgba(255,92,114,.2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------------
   Cards / panels
   --------------------------------------------------------------------- */
.card {
  background: var(--paper-card); border: 1px solid var(--paper-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--paper-border); }
.card-head h3 { font-size: 15px; }
.card-head p { margin: 0; font-size: 12.5px; }

.stat-card { padding: 18px 20px; }
.stat-card .label { font-size: 12px; color: var(--paper-text-mid); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 20px; }

/* ---------------------------------------------------------------------
   Signature element: the keycard. A perforated "hole punch" notch on
   the left edge plus a colored status bar - used for license keys and
   product cards, the two things this whole platform revolves around.
   --------------------------------------------------------------------- */
.keycard {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  background: var(--paper-card); border: 1px solid var(--paper-border);
  border-radius: var(--radius-md); padding: 14px 16px 14px 22px;
  overflow: visible;
}
.keycard::before {
  content: ''; position: absolute; left: -7px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--paper-border);
}
.keycard::after {
  content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px;
  background: var(--status-color, var(--teal));
}
.keycard[data-status="active"] { --status-color: var(--teal); }
.keycard[data-status="suspended"] { --status-color: var(--gold); }
.keycard[data-status="revoked"] { --status-color: var(--red); }
.keycard__icon {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  background: var(--ink-950); color: var(--gold-hi);
  display: flex; align-items: center; justify-content: center;
}
.keycard__body { min-width: 0; flex: 1; }
.keycard__title { font-weight: 600; font-size: 14px; }
.keycard__key { font-family: var(--font-mono); font-size: 12.5px; color: var(--paper-text-mid); user-select: all; word-break: break-all; }
.keycard__actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--paper-text-mid); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; font-size: 14px; font-family: var(--font-body);
  border: 1px solid var(--paper-border); border-radius: var(--radius-sm);
  background: #fff; color: var(--paper-text); transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,176,32,.15); outline: none; }
.textarea { resize: vertical; min-height: 100px; }
.input.mono { font-family: var(--font-mono); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--paper-text-mid); padding: 10px 14px; border-bottom: 1px solid var(--paper-border);
  white-space: nowrap;
}
table.table td { padding: 12px 14px; border-bottom: 1px solid var(--paper-border); vertical-align: middle; }
table.table tr:last-child td { border-bottom: none; }
table.table tr:hover td { background: rgba(255,176,32,.04); }

/* ---------------------------------------------------------------------
   Badges / status pills
   --------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-green { background: rgba(45,212,191,.14); color: #0F8C7D; }
.badge-gold  { background: rgba(255,176,32,.16); color: #9A6300; }
.badge-red   { background: rgba(255,92,114,.14); color: #C4223A; }
.badge-gray  { background: rgba(90,97,120,.1); color: var(--paper-text-mid); }

/* ---------------------------------------------------------------------
   Tabs
   --------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--paper-border); margin-bottom: 20px; overflow-x: auto; }
.tabs button {
  background: none; border: none; cursor: pointer; padding: 10px 14px; font-size: 13.5px; font-weight: 600;
  color: var(--paper-text-mid); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--paper-text); border-color: var(--gold); }

/* ---------------------------------------------------------------------
   Modal + toast
   --------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,12,18,.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal { background: #fff; border-radius: var(--radius-lg); max-width: 480px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-pop); }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--paper-border); }
.modal__body { padding: 20px; }
.modal__foot { padding: 16px 20px; border-top: 1px solid var(--paper-border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--paper-text-mid); font-size: 20px; line-height: 1; }

.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink-950); color: var(--text-hi); padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; box-shadow: var(--shadow-pop); min-width: 220px; display: flex; align-items: center; gap: 8px;
  animation: toast-in .18s ease;
}
.toast.error { background: #4A1420; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------------
   Empty states
   --------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--paper-text-mid); }
.empty-state .bubble {
  width: 52px; height: 52px; border-radius: 16px 16px 16px 4px; margin: 0 auto 14px;
  background: var(--ink-950); color: var(--gold-hi); display: flex; align-items: center; justify-content: center;
}
.empty-state h4 { color: var(--paper-text); font-size: 15px; margin-bottom: 4px; }

/* ---------------------------------------------------------------------
   Product grid (storefront)
   --------------------------------------------------------------------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 16px; }
.product-card {
  background: var(--paper-card); border: 1px solid var(--paper-border); border-radius: var(--radius-lg);
  overflow: hidden; display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.product-card__media {
  aspect-ratio: 16/10; background: linear-gradient(135deg, var(--ink-900), var(--ink-700));
  display: flex; align-items: center; justify-content: center; color: var(--gold-hi); position: relative;
}
.product-card__type {
  position: absolute; top: 10px; left: 10px; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; background: rgba(10,12,18,.55); color: var(--text-hi); padding: 3px 8px; border-radius: 999px;
}
.product-card__body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.product-card__name { font-weight: 600; font-size: 14.5px; }
.product-card__desc { font-size: 12.5px; color: var(--paper-text-mid); flex: 1; }
.product-card__foot { display: flex; align-items: center; justify-content: space-between; padding: 0 16px 16px; }
.price { font-family: var(--font-mono); font-weight: 700; font-size: 15px; }

/* ---------------------------------------------------------------------
   Auth / installer surfaces (dark, centered)
   --------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1c2130 0%, var(--ink-950) 60%);
  padding: 24px;
}
.auth-card { width: 100%; max-width: 420px; background: var(--ink-900); border: 1px solid var(--ink-700); border-radius: var(--radius-lg); padding: 30px 28px; color: var(--text-hi); box-shadow: var(--shadow-pop); }
.auth-card h1 { font-size: 20px; }
.auth-card .sub { color: var(--text-mid); font-size: 13.5px; margin-bottom: 22px; }
.auth-card .input, .auth-card .select { background: var(--ink-800); border-color: var(--ink-600); color: var(--text-hi); }
.auth-card .field label { color: var(--text-mid); }
.auth-card a.link { color: var(--gold-hi); text-decoration: none; font-weight: 600; }

.install-shell { min-height: 100vh; background: var(--ink-950); color: var(--text-hi); padding: 40px 20px; }
.install-wrap { max-width: 560px; margin: 0 auto; }
.install-steps { display: flex; gap: 8px; margin-bottom: 28px; }
.install-steps span { flex: 1; height: 4px; border-radius: 3px; background: var(--ink-700); }
.install-steps span.done { background: var(--gold); }
.install-card { background: var(--ink-900); border: 1px solid var(--ink-700); border-radius: var(--radius-lg); padding: 28px; }
.install-card .input, .install-card .select, .install-card .textarea { background: var(--ink-800); border-color: var(--ink-600); color: var(--text-hi); }
.install-card .field label { color: var(--text-mid); }
.req-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--ink-800); font-size: 13.5px; }
.req-row:last-child { border-bottom: none; }
.req-ok { color: var(--teal); font-weight: 600; }
.req-fail { color: var(--red); font-weight: 600; }
.req-warn { color: var(--gold-hi); font-weight: 600; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px; }
.alert-error { background: rgba(255,92,114,.12); color: #FF8496; border: 1px solid rgba(255,92,114,.3); }
.alert-ok { background: rgba(45,212,191,.12); color: var(--teal); border: 1px solid rgba(45,212,191,.3); }
.alert-info { background: rgba(91,140,255,.12); color: var(--blue); border: 1px solid rgba(91,140,255,.3); }

/* ---------------------------------------------------------------------
   Misc utility
   --------------------------------------------------------------------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.text-mid { color: var(--paper-text-mid); }
.text-sm { font-size: 12.5px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25);
  border-top-color: currentColor; animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; align-items: center; justify-content: center; padding: 60px 0; color: var(--paper-text-mid); gap: 10px; }
