/* Taplex Admin — dark theme, same token language as websites/speedclicker.app/dark-theme.css
   and workers/dashboard (self-contained: no external fonts/CDNs, CSP-safe). */

:root {
  --bg: #0d1121;
  --bg-elevated: #161c33;
  --bg-card: rgba(22, 28, 51, .65);
  --border: rgba(56, 63, 94, .5);
  --border-hover: rgba(99, 102, 241, .4);
  --text: #f0f2f8;
  --text-secondary: #a3a8c3;
  --text-muted: #6b7194;
  --cyan: #06b6d4;
  --violet: #7c3aed;
  --rose: #e11d48;
  --amber: #f59e0b;
  --indigo: #6366f1;
  --green: #22c55e;

  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); }
p { margin: 0 0 .75em; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.warn { color: var(--amber); }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  background: var(--indigo);
  color: #fff;
  padding: 8px 16px;
  transition: opacity .15s ease;
}
button:hover { opacity: .9; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.secondary { background: transparent; border-color: var(--border); color: var(--text-secondary); }
button.small { padding: 4px 10px; font-size: 12px; }
button.link-button { background: none; border: none; color: var(--text-secondary); text-decoration: underline; padding: 0; }
button.active { background: var(--cyan); border-color: var(--cyan); }

input, select {
  font: inherit;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
}
input:focus, select:focus { outline: none; border-color: var(--border-hover); }
input[type="checkbox"] { width: auto; margin-right: 6px; }

/* ---- shell ---- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }

.env-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px;
  font-weight: 700;
  letter-spacing: .05em;
}
.env-banner__url { font-weight: 400; opacity: .85; font-family: ui-monospace, monospace; font-size: 12px; }
.env-banner button { margin-left: auto; }
.env-banner--green { background: rgba(34, 197, 94, .18); color: var(--green); border-bottom: 1px solid rgba(34,197,94,.35); }
.env-banner--yellow { background: rgba(245, 158, 11, .18); color: var(--amber); border-bottom: 1px solid rgba(245,158,11,.35); }
.env-banner--red { background: rgba(225, 29, 72, .2); color: var(--rose); border-bottom: 1px solid rgba(225,29,72,.4); }

.prod-notice {
  background: rgba(225, 29, 72, .12);
  border-bottom: 1px solid rgba(225, 29, 72, .3);
  color: var(--text);
  padding: 10px 24px;
  font-size: 13px;
}

.tabs { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--bg-elevated); }
.tab { padding: 12px 16px; color: var(--text-secondary); text-decoration: none; font-size: 13px; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab--active { color: var(--text); border-bottom-color: var(--cyan); }

.screen-content { flex: 1; max-width: 960px; width: 100%; margin: 0 auto; padding: 24px; }

.screen-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.screen-header .actions { display: flex; gap: 8px; }

/* ---- panels ---- */
.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.panel.error { border-color: rgba(225,29,72,.5); background: rgba(225,29,72,.08); color: #ffb4c4; }
.panel.success { border-color: rgba(34,197,94,.5); background: rgba(34,197,94,.08); color: #b8f0c9; }

/* ---- sign-in ---- */
.signin { max-width: 420px; margin: 10vh auto; padding: 32px; }
.signin fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 0 0 16px; }
.signin legend { padding: 0 6px; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; }
.env-choice { display: flex; align-items: center; gap: 8px; padding: 8px 4px; cursor: pointer; }
.env-choice input { margin: 0; }
.env-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.env-dot--green { background: var(--green); }
.env-dot--yellow { background: var(--amber); }
.env-dot--red { background: var(--rose); }
.signin .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.signin button[type="submit"] { width: 100%; padding: 10px; }
.error { color: #ffb4c4; font-size: 13px; margin-top: 8px; }

/* ---- sign-in: advanced (automation tokens) disclosure ---- */
.signin-advanced { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.signin-advanced summary { cursor: pointer; color: var(--text-secondary); font-size: 13px; }
.signin-advanced[open] summary { margin-bottom: 12px; }

/* ---- re-auth modal (ADR-009 decision 3: confirm password to save) ---- */
.reauth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 7, 16, .72);
}
.reauth-box {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 360px;
}
.reauth-form .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---- policy groups ---- */
.policy-group { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.policy-group dl { display: grid; grid-template-columns: 1fr; gap: 2px; margin: 0; }
.policy-row { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.policy-row:last-child { border-bottom: none; }
.policy-row dt { color: var(--text-secondary); }
.policy-row dd { margin: 0; font-weight: 600; }
.policy-row--changed dd { color: var(--cyan); }
.badge { display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; background: rgba(6,182,212,.18); color: var(--cyan); border-radius: 999px; padding: 1px 8px; margin-left: 8px; }
.badge--muted { background: rgba(163,168,195,.15); color: var(--text-secondary); }

.field { display: block; margin-bottom: 10px; color: var(--text-secondary); font-size: 12px; }
.field input, .field select { display: block; margin-top: 4px; width: 100%; max-width: 320px; }
.field--checkbox { display: flex; align-items: center; gap: 6px; }
.field--checkbox input { margin-top: 0; width: auto; }
.field--error input, .field--error select { border-color: var(--rose); }
.field-error { display: block; color: var(--rose); font-size: 11px; margin-top: 4px; }

.kill-confirm { margin-top: 12px; padding: 12px; border: 1px dashed var(--rose); border-radius: 8px; background: rgba(225,29,72,.06); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.tiers-table tr.tier-default { background: rgba(99,102,241,.06); }

.diff-table td:nth-child(2) { color: var(--rose); }
.diff-table td:nth-child(3) { color: var(--green); }

/* ---- stats ---- */
.day-picker { display: flex; gap: 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile-value { font-size: 24px; font-weight: 700; }
.tile-label { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
