/* aiwaverider-licenses — owner dashboard. No build step, no frameworks, no CDN. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e2e6ea;
  --border-strong: #cfd6dd;
  --text: #1b2027;
  --muted: #667085;
  --primary: #2f6bff;
  --primary-ink: #ffffff;
  --primary-weak: #eaf0ff;
  --danger: #d64545;
  --danger-weak: #fdecec;
  --warn: #b4690e;
  --warn-weak: #fdf1e3;
  --ok: #1f9d6b;
  --ok-weak: #e6f6ef;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 6px 24px rgba(16, 24, 40, 0.10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---- controls ---- */
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
button:hover { background: var(--surface-2); }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
button.primary:hover { background: #2559d8; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover { background: #c23a3a; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button.sm { padding: 4px 9px; font-size: 12.5px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-weak);
}
textarea { resize: vertical; min-height: 64px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.check label { margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 1em; }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; }

/* ---- layout ---- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 750; letter-spacing: -0.02em; font-size: 15px; white-space: nowrap; }
.brand span { color: var(--primary); }
.topbar .spacer { flex: 1; }
.topbar select { width: auto; min-width: 150px; }
.nav { display: flex; gap: 4px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.nav button {
  border: none; background: transparent; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 11px 12px; color: var(--muted); font-weight: 600;
}
.nav button:hover { background: transparent; color: var(--text); }
.nav button.active { color: var(--primary); border-bottom-color: var(--primary); }
main { max-width: 1120px; margin: 0 auto; padding: 22px 20px 60px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px; margin-bottom: 18px;
}
.card h2 { font-size: 15.5px; margin-bottom: 4px; }
.card > .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.section-title h2 { flex: 1; }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow-sm); }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .k { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---- table ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .search { flex: 1 1 220px; min-width: 160px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--primary-weak); }
tbody tr:last-child td { border-bottom: none; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* ---- chips / badges ---- */
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; }
.badge.active { background: var(--ok-weak); color: var(--ok); }
.badge.suspended { background: var(--warn-weak); color: var(--warn); }
.badge.revoked { background: var(--danger-weak); color: var(--danger); }
.badge.archived { background: var(--surface-2); color: var(--muted); }

/* ---- copy block ---- */
.copyblock { position: relative; }
.copyblock pre {
  margin: 0; padding: 13px 14px; background: #10151d; color: #d6e2f0;
  border-radius: var(--radius-sm); overflow-x: auto; font-family: var(--mono);
  font-size: 12px; line-height: 1.55;
}
.copyblock .copy { position: absolute; top: 8px; right: 8px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

/* ---- login ---- */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { font-size: 20px; margin-bottom: 4px; }

/* ---- modal / drawer ---- */
.scrim { position: fixed; inset: 0; background: rgba(16, 24, 40, 0.42); z-index: 40; display: flex; }
.modal {
  margin: auto; width: 100%; max-width: 460px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 20px;
  max-height: 90vh; overflow-y: auto;
}
.drawer {
  margin-left: auto; width: 100%; max-width: 560px; height: 100%;
  background: var(--surface); box-shadow: var(--shadow-md); overflow-y: auto;
  animation: slidein 0.16s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.drawer-head { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 20px; display: flex; align-items: center; gap: 12px; z-index: 2; }
.drawer-head h2 { flex: 1; font-size: 16px; }
.drawer-body { padding: 18px 20px 40px; }
.modal h2 { margin-bottom: 4px; }
.modal .actions, .drawer .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.sub-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 16px; background: var(--surface-2); }
.sub-block h3 { font-size: 13px; margin-bottom: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.machine-item, .event-item { display: flex; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.machine-item:last-child, .event-item:last-child { border-bottom: none; }
.machine-item .grow, .event-item .grow { flex: 1; }
.event-item .k { font-family: var(--mono); font-size: 12px; }
.event-item time { color: var(--muted); font-size: 12px; }
.scope-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }

.warn-box { background: var(--warn-weak); border: 1px solid #f0d5ac; color: var(--warn); border-radius: var(--radius-sm); padding: 11px 13px; font-size: 12.5px; margin: 12px 0; }
.code-reveal { font-family: var(--mono); font-size: 18px; font-weight: 600; letter-spacing: 0.04em; text-align: center; padding: 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

/* ---- toast ---- */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #10151d; color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); font-size: 13px; opacity: 0; transform: translateY(8px); transition: opacity 0.16s, transform 0.16s; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--danger); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dt { margin-top: 8px; }
  .topbar { flex-wrap: wrap; }
}
