:root {
  --blue: #2563eb; --blue-d: #1d4ed8; --blue-soft: #eef4ff;
  --green: #16a34a; --green-soft: #e9f9ef; --amber: #d97706;
  --ink: #0f1b2d; --muted: #5b6b82; --subtle: #8a97a8;
  --line: #e6ecf5; --bg: #f4f7fc;
  --shadow: 0 18px 44px rgba(19,46,92,.09); --shadow-sm: 0 4px 14px rgba(19,46,92,.06);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { letter-spacing: -.01em; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---- buttons / bits ---- */
.primary, .secondary, .danger { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; transition: all .15s ease; }
.primary { background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.26); }
.primary:hover { background: var(--blue-d); }
.secondary { background: #eef2f7; color: #45566e; }
.secondary:hover { background: #e4eaf2; }
.danger { background: #fef2f2; color: #dc2626; }
.danger:hover { background: #fde5e5; }
.linkbtn { border: 0; background: transparent; color: var(--blue); font-weight: 600; padding: 4px; text-align: center; }
.linkbtn:hover { text-decoration: underline; }
select.inline { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #33415c; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--blue-soft); color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.switcher { margin: 0 0 18px; display: flex; gap: 8px; flex-wrap: wrap; }
.imp-bar { background: #fff7e6; border: 1px solid #ffe1a8; color: #8a5b00; padding: 11px 16px; border-radius: 12px; font-size: 13px; font-weight: 600; margin-bottom: 18px; }
.imp-bar .linkbtn { color: #8a5b00; text-decoration: underline; }

/* ---- auth split screen ---- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, .9fr); }
.brand-panel { padding: 9vh 6vw; color: #fff; display: flex; flex-direction: column; justify-content: center;
  background: radial-gradient(circle at 82% 8%, #3b74ff 0, transparent 42%), linear-gradient(155deg, #1e3a8a, #2563eb 60%, #1d4ed8); }
.brand-mark { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; font-size: 32px; font-weight: 900; color: #fff;
  background: linear-gradient(140deg, #34d399, #16a34a 60%, #047857); box-shadow: 0 16px 36px rgba(4,120,87,.4); }
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 22px; }
.eyebrow { letter-spacing: .14em; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--subtle); margin: 24px 0 8px; }
.brand-panel .eyebrow { color: #bcd0ff; }
.brand-panel h1 { font-size: 46px; line-height: 1.1; margin: 0; font-weight: 850; }
.lead { font-size: 17px; color: #dbe6ff; max-width: 560px; line-height: 1.7; }
.feature-list { margin-top: 40px; display: grid; gap: 14px; }
.feature-list div { display: flex; align-items: center; gap: 13px; color: #eaf1ff; }
.feature-list span { font-family: ui-monospace, monospace; color: #86efc0; }
.auth-card { align-self: center; justify-self: center; width: min(460px, calc(100% - 48px)); background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 32px; box-shadow: var(--shadow); }
.tabs { display: flex; background: #f1f4f8; padding: 4px; border-radius: 12px; margin-bottom: 24px; }
.tab { flex: 1; border: 0; background: transparent; color: #758197; padding: 9px 6px; border-radius: 9px; font-size: 13.5px; }
.tab.active { background: #fff; color: var(--blue); font-weight: 700; box-shadow: var(--shadow-sm); }
.auth-form { display: grid; gap: 15px; }
.auth-form label, .field { font-size: 13px; color: #4e5c72; font-weight: 600; }
.auth-form small, .field small { color: #9aa5b6; font-weight: 400; }
.auth-form input, .field input, .field select { display: block; width: 100%; margin-top: 7px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: #fff; }
.auth-form input:focus, .field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.message { min-height: 20px; color: #dc2626; font-size: 13px; }

/* ---- console shell (light sidebar) ---- */
.console { min-height: 100vh; display: grid; grid-template-columns: 244px 1fr; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 244px; background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; }
.side-brand { display: flex; gap: 11px; align-items: center; margin-bottom: 26px; padding: 4px 6px; }
.side-brand strong, .side-brand span { display: block; }
.side-brand strong { font-size: 15px; }
.side-brand span { font-size: 11.5px; color: var(--muted); }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav button { border: 0; text-align: left; background: transparent; color: #52627a; padding: 11px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; transition: all .12s ease; }
.sidebar nav button:hover { background: #f3f6fb; color: var(--ink); }
.sidebar nav button.active { background: var(--blue-soft); color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.side-user { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 8px 4px; display: flex; align-items: center; justify-content: space-between; }
.side-user strong, .side-user span { display: block; }
.side-user strong { font-size: 13px; }
.side-user span { font-size: 11.5px; color: var(--muted); }
.side-user button { border: 0; background: transparent; color: var(--subtle); }
.side-user button:hover { color: var(--blue); }

.workspace { grid-column: 2; padding: 30px 38px; }
.workspace header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 26px; }
.workspace header .eyebrow { margin: 0 0 6px; }
.workspace h2 { font-size: 27px; margin: 0; font-weight: 800; }
.badge { display: inline-block; padding: 6px 12px; background: var(--blue-soft); color: var(--blue); border-radius: 999px; font-size: 12px; font-weight: 700; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow-sm); }
.metric span { font-size: 12px; color: var(--muted); }
.metric strong { display: block; font-size: 28px; margin-top: 6px; font-weight: 800; font-variant-numeric: tabular-nums; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.panel-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.panel-head h3 { margin: 0; font-size: 16px; }
.panel-body { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: end; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 18px; border-bottom: 1px solid #eef2f7; font-size: 13px; }
th { color: #8593a6; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; background: #fafbfd; font-weight: 700; }
tbody tr:hover { background: #fafcff; }
.status { font-size: 11px; padding: 4px 9px; border-radius: 999px; font-weight: 700; }
.status.active, .status.pending, .status.trialing { background: var(--green-soft); color: var(--green); }
.status.suspended, .status.revoked, .status.expired, .status.past_due { background: #fdeceb; color: #dc2626; }
.status.used { background: #eef1f6; color: #68768b; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.row-actions button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; color: #4a5b74; font-weight: 600; font-size: 12.5px; }
.row-actions button:hover { border-color: var(--blue); color: var(--blue); }
.empty { text-align: center; padding: 44px; color: var(--muted); }

dialog { border: 0; border-radius: 20px; padding: 0; box-shadow: 0 30px 90px rgba(16,33,63,.3); }
dialog::backdrop { background: rgba(16,33,63,.42); backdrop-filter: blur(2px); }
.dialog-body { width: min(440px, 90vw); padding: 28px; }
.dialog-body .eyebrow { margin: 0 0 7px; }
.dialog-body h3 { margin: 0; }
.generated-code { font: 700 22px/1.2 ui-monospace, monospace; letter-spacing: .05em; background: var(--blue-soft); color: var(--blue-d); padding: 17px; border-radius: 12px; text-align: center; margin: 20px 0; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions button { flex: 1; }

.toast { position: fixed; right: 24px; bottom: 24px; background: #14294f; color: #fff; padding: 13px 18px; border-radius: 12px; box-shadow: 0 14px 40px rgba(16,33,63,.3); z-index: 20; font-weight: 600; }
.toast.error { background: #dc2626; }

@media (max-width: 950px) {
  .auth-shell { grid-template-columns: 1fr; }
  .brand-panel { display: none; }
  .console { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace { grid-column: 1; padding: 22px; }
  .metrics, .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .metrics, .form-grid { grid-template-columns: 1fr; }
  .workspace { padding: 16px; }
  .console { display: block; }
}
