:root {
  --bg: #F6F5FA;
  --card: #FFFFFF;
  --line: #E9E7F0;
  --text: #02020E;
  --muted: #5F5C70;
  --purple: #6124DB;
  --pink: #E8459B;
  --gradient: linear-gradient(135deg, var(--pink) 0%, var(--purple) 100%);
  --soft: linear-gradient(135deg, rgba(232, 69, 155, .08) 0%, rgba(97, 36, 219, .08) 100%);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 12, 40, .04), 0 8px 24px rgba(16, 12, 40, .06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }
h1, h2 { margin: 0 0 20px; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
.card > h2 { margin-bottom: 28px; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand-sub {
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  background: var(--gradient); color: #fff; font-weight: 700;
}
.logo-big { width: 52px; height: 52px; border-radius: 16px; font-size: 24px; margin-bottom: 16px; }
.env { font-size: 11px; font-weight: 600; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: #FFF1D6; color: #A15C00; }
.user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }

/* layout */
.container { max-width: 1040px; margin: 48px auto; padding: 0 24px; display: flex; flex-direction: column; align-items: center; }
.panel { width: 100%; display: flex; justify-content: center; }
.panel > .card { width: 100%; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 40px 44px; }
.panel > .narrow { max-width: 640px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.card-head h2 { margin: 0; }
.card-head select { width: 280px; }
.row { display: flex; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 22px; }

/* login */
.login { min-height: calc(100vh - 61px); display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 440px; text-align: center; }
.login-card form { text-align: left; }

/* tabs */
.tabs {
  display: inline-flex; gap: 4px; padding: 5px; margin-bottom: 32px;
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow);
}
.tab {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 500;
  padding: 10px 22px; border-radius: 9px; cursor: pointer; transition: .15s;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { background: var(--gradient); color: #fff; }

/* form controls */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
input, select {
  font: inherit; color: var(--text); padding: 13px 16px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; outline: none; transition: .15s;
}
input:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(97, 36, 219, .12); }
.hint { font-weight: 500; color: var(--purple); }

button { font: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
.btn-primary {
  border: 0; color: #fff; background: var(--gradient); font-weight: 600;
  padding: 14px 22px; border-radius: 10px; transition: .15s;
  box-shadow: 0 4px 14px rgba(97, 36, 219, .25);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.btn-ghost {
  border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 500;
  padding: 8px 14px; border-radius: 10px;
}
.btn-ghost:hover { background: var(--bg); }

/* segmented control */
.segmented { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; }
.segmented input { display: none; }
.segmented label {
  flex: 1; text-align: center; padding: 9px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--muted); transition: .15s;
}
.segmented input:checked + label { background: #fff; color: var(--purple); font-weight: 600; box-shadow: var(--shadow); }

/* table */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.table td { padding: 16px 14px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 32px !important; }

/* API key box */
.key-box {
  display: flex; flex-direction: column; gap: 14px;
  padding: 24px; margin-top: 28px; border-radius: 12px; background: var(--soft); border: 1px solid rgba(97, 36, 219, .2);
}
.key-box code { display: block; font-size: 14px; word-break: break-all; padding: 14px 16px; background: #fff; border-radius: 10px; }
.warning { margin: 0; font-size: 14px; font-weight: 500; color: #B4235F; }

/* messages */
.msg { margin: 0; font-size: 14px; min-height: 1em; }
.msg.ok { color: #1E8E5A; }
.msg.error { color: #D2334B; }
