:root {
  --brand: #1a73e8;
  --brand-dark: #1557b0;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1c2433;
  --muted: #6b7a90;
  --line: #e3eaf4;
  --green: #00a862;
  --red: #e53935;
  --orange: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
button, input, select { font: inherit; }
.hidden { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn { border: 0; border-radius: 10px; padding: 9px 16px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.light { background: #e8f0fe; color: var(--brand); }
.btn.danger { background: var(--red); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; color: var(--text); outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(26, 115, 232, .15); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 120px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 32px 28px; }
.logo { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, #1a73e8, #0b1426); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; margin: 0 auto 12px; }
.login-card h1 { text-align: center; margin: 0 0 4px; font-size: 22px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 24px; }
.login-card .btn { width: 100%; padding: 12px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100%; }
.sidebar { width: 230px; background: var(--card); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 800; font-size: 16px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; margin: 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: #e8f0fe; color: var(--brand); font-weight: 700; }
.nav .ico { width: 18px; text-align: center; }
.sidebar .foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sidebar .foot b { color: var(--text); display: block; font-size: 13px; }
.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.topbar { display: none; }
h2.page { margin: 0 0 4px; font-size: 22px; }
p.page-sub { margin: 0 0 20px; color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: 320px 1fr; align-items: start; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .n { font-size: 26px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.brand { background: linear-gradient(135deg, #1a73e8, #1557b0); color: #fff; }
.stat.brand .l { color: #dbe7fb; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
td.actions { text-align: right; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.active { background: #e6f6ee; color: var(--green); }
.pill.expired { background: #fff4e5; color: #b26a00; }
.pill.blocked { background: #fdecec; color: var(--red); }
.uname { font-weight: 700; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 13px; }
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn.red:hover { border-color: var(--red); color: var(--red); }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--card); border-radius: 18px; width: 100%; max-width: 420px; padding: 22px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1c2433; color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 60; max-width: 90%; box-shadow: var(--shadow); }
.toast.err { background: var(--red); }
.copybox { display: flex; gap: 8px; }
.copybox .input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.log-list div { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }
.log-list div:last-child { border-bottom: 0; }
.tag { font-size: 12px; background: var(--bg); padding: 1px 8px; border-radius: 6px; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 12px; background: var(--card); padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; font-weight: 800; }
  .layout { flex-direction: column; }
  .main { padding: 16px 14px 60px; }
  th.hide-sm, td.hide-sm { display: none; }
}
.mb12 { margin-bottom: 12px; }
.mt12 { margin-top: 12px; }
.small { font-size: 12px; }
.w-auto { width: auto; }
.grid > * { min-width: 0; }
@media (max-width: 720px) {
  /* Accounts table becomes stacked rows: name/status/expiry on top, buttons underneath */
  table.acc thead { display: none; }
  table.acc tbody tr { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.acc td { border: 0; padding: 0; }
  table.acc td.actions { grid-column: 1 / -1; text-align: left; white-space: normal; padding-top: 6px; }
  table.acc td.actions .icon-btn { margin: 0 4px 4px 0; padding: 7px 11px; }
}
.credits { margin: 8px 0 4px; padding: 8px 10px; border-radius: 10px; background: #e8f0fe; color: var(--brand); font-size: 13px; }
.credits b { display: inline; color: var(--brand); }
.pill.trial { background: #efe9ff; color: #6d28d9; }
.dot-on { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 4px; }
.hint { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 8px 0; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
