/* License Portal admin UI
   Server path: /var/www/html/license-portal/public/assets/style.css */

:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f9faf7;
  --ink: #1d211f;
  --ink-2: #4e5651;
  --muted: #7a827d;
  --line: #dfe3dc;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0eb;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --ok: #1f6f3c;
  --ok-soft: #e4f3e8;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 1px 1px rgba(20, 30, 25, .04);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121513;
    --surface: #1a1e1c;
    --surface-2: #202522;
    --ink: #e7ebe8;
    --ink-2: #b9c1bc;
    --muted: #8a938e;
    --line: #2e3531;
    --accent: #5cc3a6;
    --accent-ink: #0d1a15;
    --accent-soft: #1d3a31;
    --danger: #f2877e;
    --danger-soft: #3a1f1d;
    --warn: #e8b74f;
    --warn-soft: #362b14;
    --ok: #6fcf8f;
    --ok-soft: #1b3324;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.wrap { white-space: pre-wrap; word-break: break-all; }
.prewrap { white-space: pre-wrap; }

/* --- Top bar --------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 5px;
  background: linear-gradient(135deg, var(--accent) 0 55%, var(--accent-soft) 55%);
  border: 1px solid var(--accent);
}
.mainnav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.mainnav a {
  color: var(--ink-2); padding: 6px 10px; border-radius: 6px; white-space: nowrap;
}
.mainnav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.mainnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.usermenu { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.usermenu a { color: var(--ink-2); }
.usermenu a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.role { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* --- Layout ---------------------------------------------------------- */
.page { max-width: 1240px; margin: 0 auto; padding: 24px; }
.page-narrow { max-width: 420px; padding-top: 10vh; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.narrow { max-width: 520px; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline { display: inline; }

@media (max-width: 900px) {
  .grid-2, .grid-side { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px 16px; }
  .mainnav { order: 3; flex-basis: 100%; }
  .page { padding: 16px; }
}

/* --- Stats ----------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat a { color: inherit; display: block; }
.stat a:hover { text-decoration: none; }
.stat-value { display: block; font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-warn { border-color: var(--warn); background: var(--warn-soft); }

/* --- Forms ----------------------------------------------------------- */
label { display: flex; flex-direction: column; gap: 5px; font-weight: 550; color: var(--ink-2); }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
input[readonly] { background: var(--surface-2); color: var(--muted); }
input.short { max-width: 110px; }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.field-error { color: var(--danger); font-weight: 500; font-size: 12.5px; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filters input[type="search"], .filters input[type="text"] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-small { padding: 4px 10px; font-size: 12.5px; }
.linklike {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer;
}
.linklike:hover { text-decoration: underline; }

/* --- Tables ---------------------------------------------------------- */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .tablewrap { border: 0; box-shadow: none; margin: 0 -20px; border-radius: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
table.compact td { padding: 7px 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; color: var(--muted); padding: 28px; }
tr.dim td { color: var(--muted); }
tr.warnrow td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.rowactions { white-space: nowrap; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.inline-details summary { color: var(--accent); cursor: pointer; }
.inline-details[open] form { margin-top: 8px; min-width: 220px; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 2px; color: var(--muted); }

/* --- Badges / flashes ------------------------------------------------ */
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600; text-transform: capitalize;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.badge-active { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-suspended, .badge-locked { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-revoked { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-released, .badge-inactive { color: var(--muted); }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-info { background: var(--accent-soft); color: var(--ink); }
.flash-warn { background: var(--warn-soft); color: var(--ink); border-color: var(--warn); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

/* --- License detail -------------------------------------------------- */
.details { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; min-width: 0; }
.newkey { border: 2px solid var(--accent); background: var(--accent-soft); }
.keybox { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.keybox code {
  font-size: 20px; letter-spacing: .06em; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  user-select: all;
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 120px; }
.timeline code { flex-basis: 100%; color: var(--muted); }

/* --- Login ----------------------------------------------------------- */
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: 16px; margin-bottom: 18px; }
.login .card { padding: 28px; }
.login h1 { font-size: 20px; }

[hidden] { display: none !important; }
