/* style.css — Script-as-a-Service UI */
:root {
  --primary: #2563EB;
  --primary-600: #1D4ED8;
  --success: #16A34A;
  --danger: #DC2626;
  --warning: #D97706;
  --bg-dark: #0F172A;
  --bg-card: #1E293B;
  --bg-elev: #273449;
  --border: #334155;
  --text: #E2E8F0;
  --text-muted: #94A3B8;
  --radius-card: 8px;
  --radius-btn: 6px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg-dark);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ─── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--primary); box-shadow: 0 0 12px var(--primary); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-muted); font-size: 14px; }
.topbar .who b { color: var(--text); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.card .sub { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }
.grid { display: grid; gap: 20px; }
@media (min-width: 860px) { .grid.cols-2 { grid-template-columns: minmax(0,1fr) minmax(0,1fr); } }

/* ─── Quota meter (SIGNATURE) ─── */
.meter { }
.meter__top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.meter__num { font-family: var(--mono); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.meter__num .used { color: var(--text); }
.meter__num .sep { color: var(--text-muted); margin: 0 2px; }
.meter__num .total { color: var(--text-muted); }
.meter__remain { font-size: 13px; color: var(--text-muted); }
.meter__remain b { color: var(--success); font-family: var(--mono); }
.meter__ticks {
  display: flex; gap: 3px; height: 34px; align-items: stretch;
}
.tick { flex: 1; border-radius: 2px; background: var(--bg-elev); min-width: 2px; transition: background .2s; }
.tick.on { background: var(--primary); }
.tick.on.near { background: var(--warning); }
.tick.on.full { background: var(--danger); }
/* ko'p bo'lsa ticks o'rniga bitta bar */
.meter__bar { height: 12px; border-radius: 6px; background: var(--bg-elev); overflow: hidden; }
.meter__bar > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s; }
.meter__bar > i.near { background: var(--warning); }
.meter__bar > i.full { background: var(--danger); }

/* ─── Buttons ─── */
.btn {
  font: inherit; font-weight: 500; font-size: 14px;
  padding: 9px 16px; border-radius: var(--radius-btn);
  border: 1px solid transparent; cursor: pointer;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--primary-600); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--bg-elev); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #B91C1C; }
.btn--sm { padding: 6px 11px; font-size: 13px; }
.btn--icon { padding: 6px 9px; }

/* ─── Forms ─── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; font: inherit; font-size: 14px;
  background: var(--bg-dark); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  padding: 9px 11px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .25);
}
.textarea { resize: vertical; min-height: 90px; }
.textarea.mono { font-family: var(--mono); font-size: 13px; }

/* ─── Login ─── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; margin-bottom: 20px; font-size: 20px; }
.auth-card .err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-card); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--bg-elev); }
tr:last-child td { border-bottom: none; }
tbody tr:hover, tbody tr:hover { background: rgba(255,255,255,.02); }
.empty { text-align: center; color: var(--text-muted); padding: 32px; font-size: 14px; }

/* ─── Badges ─── */
.badge { font-size: 12px; padding: 3px 9px; border-radius: 20px; font-weight: 500; display: inline-block; }
.badge--ok { background: rgba(22,163,74,.15); color: #4ADE80; }
.badge--danger { background: rgba(220,38,38,.15); color: #F87171; }
.badge--warn { background: rgba(217,119,6,.15); color: #FBBF24; }
.badge--muted { background: var(--bg-elev); color: var(--text-muted); }

/* ─── Token / code box ─── */
.codebox {
  display: flex; align-items: stretch; gap: 8px;
}
.codebox code {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px;
  background: var(--bg-dark); border: 1px solid var(--border);
  border-radius: var(--radius-btn); padding: 10px 12px;
  overflow-x: auto; white-space: nowrap; color: var(--text-muted);
}
.mono { font-family: var(--mono); }

/* ─── Tabs ─── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  background: none; border: none; font: inherit; font-size: 14px; font-weight: 500;
  color: var(--text-muted); padding: 11px 16px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(2,6,23,.7);
  display: none; place-items: center; z-index: 40; padding: 20px;
}
.modal-overlay.show { display: grid; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-card); width: 100%; max-width: 520px;
  padding: 22px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ─── Toolbar row ─── */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ─── Bell / notifications ─── */
.bell { position: relative; cursor: pointer; background: none; border: none; color: var(--text); font-size: 18px; padding: 6px; }
.bell .count {
  position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: grid; place-items: center; padding: 0 4px;
}

/* ─── Spinner ─── */
.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─── */
.toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: var(--radius-btn); font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s; max-width: 340px;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--danger); }
.toast--info { border-left: 3px solid var(--primary); }

.notif-item { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.notif-item:last-child { border-bottom: none; }
.notif-item .msg { flex: 1; font-size: 14px; }
.notif-item .time { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.notif-item.unread .msg::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-right: 8px; vertical-align: middle; }

.help { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.help code { font-family: var(--mono); background: var(--bg-dark); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
