/* Tahres License Server — admin dashboard styles.
   Dark theme matching the Tahres app palette (gold accent #d4a23a). */

:root {
  --bg:        #0a0a0a;
  --surface:   #161616;
  --surface-2: #1f1f1f;
  --border:    #2a2a2a;
  --border-2:  #3a3a3a;
  --fg:        #e7e7e7;
  --fg-dim:    #b3b3b3;
  --fg-mute:   #6b7280;
  --accent:    #d4a23a;
  --accent-2:  #b8881a;
  --green:     #22c55e;
  --orange:    #f59e0b;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --radius:    10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body { min-height: 100vh; }

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

button {
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--fg);
  padding: 7px 14px;
  border-radius: 8px;
  transition: background .15s, border-color .15s, color .15s;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; border-color: var(--border); }

.btn.primary {
  background: var(--accent);
  color: #1a1208;
  border-color: var(--accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #1a1208; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: rgba(239,68,68,0.1); }
.btn.warn { color: var(--orange); border-color: var(--orange); }
.btn.warn:hover { background: rgba(245,158,11,0.1); }
.btn.sm { padding: 4px 10px; font-size: 11px; }

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--fg);
  padding: 9px 12px;
  border-radius: 8px;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Login page ──────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  padding: 32px;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand h1 {
  font-size: 24px;
  margin: 0 0 6px;
  letter-spacing: 0.5px;
}
.login-brand p {
  color: var(--fg-dim);
  font-size: 12px;
  margin: 0;
}
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card button { padding: 11px 16px; font-size: 14px; }
.login-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}

/* ── Dashboard layout ────────────────────────────────────────────────── */
.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.header h1 {
  font-size: 22px;
  margin: 0;
  letter-spacing: 0.4px;
}
.header h1 .accent { color: var(--accent); }
.header-actions { display: flex; gap: 10px; align-items: center; }
.header-actions .who { color: var(--fg-dim); font-size: 12px; }

/* ── Stat cards ──────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
@media (max-width: 800px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 440px) { .stats { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent);
}
.stat-card.licensed::before { background: var(--green); }
.stat-card.suspended::before { background: var(--orange); }
.stat-card.expired::before { background: var(--red); }
.stat-card.revoked::before { background: var(--red); }
.stat-card .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--fg-mute);
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.stat-card .sub {
  font-size: 11px;
  color: var(--fg-dim);
  margin-top: 4px;
}
.stat-card .breakdown {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  font-size: 11px;
}
.stat-card .breakdown span { color: var(--fg-dim); }
.stat-card .breakdown b { color: var(--fg); font-variant-numeric: tabular-nums; }
.stat-card .breakdown .l { color: var(--green); }
.stat-card .breakdown .s { color: var(--orange); }
.stat-card .breakdown .e, .stat-card .breakdown .r { color: var(--red); }

/* ── Toolbar above the table ─────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.toolbar h2 { font-size: 16px; margin: 0; }

/* ── Licenses table ──────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table.licenses {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.licenses th {
  background: var(--surface-2);
  color: var(--fg-mute);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.licenses td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.licenses tr:last-child td { border-bottom: none; }
table.licenses tr.row { cursor: pointer; transition: background .12s; }
table.licenses tr.row:hover { background: var(--surface-2); }
table.licenses .store-name { font-weight: 600; }
table.licenses .store-sub { color: var(--fg-dim); font-size: 11px; }
table.licenses code {
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--fg-dim);
}
table.licenses .key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
table.licenses .key.revealed code { color: var(--fg); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid;
}
.badge.LICENSED  { color: var(--green);  border-color: var(--green);  background: rgba(34,197,94,0.10); }
.badge.SUSPENDED { color: var(--orange); border-color: var(--orange); background: rgba(245,158,11,0.10); }
.badge.EXPIRED   { color: var(--red);    border-color: var(--red);    background: rgba(239,68,68,0.10); }
.badge.REVOKED   { color: var(--red);    border-color: var(--red);    background: rgba(239,68,68,0.10); }
.badge.INVALID   { color: var(--fg-mute);border-color: var(--fg-mute);background: rgba(107,114,128,0.10); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { padding: 4px 10px; font-size: 11px; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--fg-mute);
  font-size: 13px;
}

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  padding: 24px 28px;
  box-shadow: var(--shadow);
}
.modal.wide { max-width: 920px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 18px; margin: 0; }
.modal-header .close {
  background: transparent;
  border: none;
  color: var(--fg-mute);
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.modal-header .close:hover { color: var(--fg); }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--fg-mute);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* The "license created — copy now" success card */
.created-card {
  background: rgba(212,162,58,0.08);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.created-card .warn-line {
  font-weight: 700;
  color: var(--accent);
  font-size: 13px;
  margin-bottom: 12px;
}
.created-key {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 14px;
}
.created-key code {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-2);
  padding: 12px 14px;
  border-radius: 8px;
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 15px;
  letter-spacing: 1px;
  word-break: break-all;
}
.created-actions { display: flex; gap: 8px; }

/* ── Detail modal sections ───────────────────────────────────────────── */
.detail-section + .detail-section { margin-top: 18px; }
.detail-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--fg-mute);
  margin: 0 0 10px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px 14px;
  font-size: 13px;
}
.detail-grid dt { color: var(--fg-mute); }
.detail-grid dd { margin: 0; color: var(--fg); word-break: break-word; }
.detail-grid code {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 12px;
}

.checks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.checks-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--fg-mute);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.checks-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.checks-table tr:last-child td { border-bottom: none; }
.checks-table code {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--fg-dim);
}

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 200;
  max-width: 360px;
  animation: toast-in .2s ease-out;
}
.toast.error   { border-left-color: var(--red);    color: #fca5a5; }
.toast.success { border-left-color: var(--green);  color: #86efac; }
.toast.info    { border-left-color: var(--blue);   color: #93c5fd; }
@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Misc utilities ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mono { font-family: 'SF Mono', ui-monospace, monospace; }
.dim { color: var(--fg-dim); }
.mute { color: var(--fg-mute); }
.small { font-size: 11px; }
.tabnum { font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .shell { padding: 16px; }
  table.licenses { font-size: 12px; }
  table.licenses th, table.licenses td { padding: 10px 8px; }
  .header h1 { font-size: 18px; }
}

/* ── Top-level tabs (v2.0.0) ─────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.tab {
  background: transparent;
  border: none;
  color: var(--fg-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 0;
  position: relative;
  cursor: pointer;
}
.tab:hover { color: var(--fg); border-color: transparent; }
.tab.active { color: var(--accent); }
.tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.tab-view { animation: fade-in .15s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── Commission tab ──────────────────────────────────────────────────── */
.comm-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.comm-controls {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: flex-end;
  flex: 1;
  min-width: 0;
}
.comm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.comm-field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--fg-mute);
}
.comm-field select { min-width: 240px; }
.comm-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.comm-presets .active { border-color: var(--accent); color: var(--accent); background: rgba(212,162,58,0.08); }
.comm-custom-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.comm-custom-row input[type=date] { width: 160px; }

.comm-total-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  min-width: 200px;
  position: relative;
  overflow: hidden;
}
.comm-total-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent);
}
.comm-total-card .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--fg-mute);
  margin-bottom: 4px;
}
.comm-total-card .value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.comm-total-card .sub {
  font-size: 11px;
  color: var(--fg-dim);
  margin-top: 4px;
}

.comm-note {
  background: rgba(245,158,11,0.10);
  border: 1px solid rgba(245,158,11,0.35);
  color: #fbbf24;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  margin-bottom: 14px;
}

table.commission {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.commission th {
  background: var(--surface-2);
  color: var(--fg-mute);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.commission th.num, table.commission td.num { text-align: right; }
table.commission td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.commission tr:last-child td { border-bottom: none; }
table.commission tfoot tr td { border-top: 1px solid var(--border-2); border-bottom: none; padding-top: 14px; }
table.commission .total-row { background: var(--surface-2); }
table.commission .tins-cell {
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--fg-dim);
  word-break: break-word;
  max-width: 420px;
}
table.commission .tins-cell .tins-inline { display: inline; }
table.commission .tins-cell .tins-full { display: none; }
table.commission .tins-cell.expanded .tins-inline { display: none; }
table.commission .tins-cell.expanded .tins-full { display: inline; }

.comm-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  gap: 10px;
  flex-wrap: wrap;
}
.comm-footer > div:first-child { display: flex; gap: 8px; }

@media (max-width: 720px) {
  .comm-toolbar { flex-direction: column; }
  .comm-total-card { width: 100%; }
  .comm-field select { min-width: 100%; }
  table.commission { font-size: 12px; }
}
