/* ===================================================================
   StarLight AI Cloud — Admin Console Stylesheet (v2)
   Pure CSS, no framework. Responsive (breakpoints at 1000px / 680px).
   =================================================================== */

:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #fff;
  --line: #dce2e5;
  --text: #172126;
  --muted: #65737a;
  --nav: #17272b;
  --nav-text: #d8e4e6;
  --primary: #087f75;
  --primary-dark: #06665e;
  --danger: #b42318;
  --warning: #a15c00;
  --ok: #18794e;
  --info: #175cd3;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: var(--primary); }

/* ---- Layout ---- */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--nav); color: var(--nav-text);
  padding: 18px 12px;
  display: flex; flex-direction: column;
  z-index: 10;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 20px;
  border-bottom: 1px solid #304247;
}

.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: #d9fffa; color: #075e57;
  font-weight: 800; border-radius: 6px;
}

.brand strong, .brand small { display: block; }
.brand small { font-size: 11px; color: #92a7ac; margin-top: 2px; }

nav { padding-top: 16px; }

.nav-item {
  width: 100%; border: 0; background: transparent;
  color: #bbcacd; padding: 10px 12px; text-align: left;
  border-radius: 5px; margin: 2px 0;
}

.nav-item:hover { background: #263a3f; color: #fff; }
.nav-item.active { background: #d9fffa; color: #075e57; font-weight: 700; }

.nav-section { padding: 16px 12px 4px; font-size: 11px; color: #6b8288; text-transform: uppercase; letter-spacing: 0.5px; }

.side-footer { margin-top: auto; display: grid; gap: 0; }
.side-footer .user-info { padding: 12px 8px; border-top: 1px solid #304247; font-size: 12px; color: #92a7ac; }
.side-footer .user-info strong { display: block; color: #d8e4e6; }
.side-footer .logout-btn { width: 100%; border: 0; background: #263a3f; color: #bbcacd; padding: 8px; border-radius: 5px; font-size: 12px; }
.side-footer .logout-btn:hover { background: #b42318; color: #fff; }

main { min-width: 0; padding: 0 28px 40px; }

/* ---- Topbar ---- */

.topbar {
  min-height: 78px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border-bottom: 1px solid var(--line); margin-bottom: 22px;
}

.topbar h1 { font-size: 22px; margin: 0; letter-spacing: 0; }
.topbar p { margin: 4px 0 0; color: var(--muted); }

.toolbar, .actionbar, .filters, .form-actions {
  display: flex; align-items: center; gap: 8px;
}

/* ---- Buttons ---- */

.primary, .secondary, .danger, .danger-quiet, .info-btn {
  border-radius: 5px; padding: 8px 16px; border: 1px solid transparent;
  min-height: 36px; font-weight: 600;
}

.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #fff; border-color: #cbd4d8; color: #26363c; }
.secondary:hover { background: #eef1f2; }
.danger { background: var(--danger); color: #fff; }
.danger:hover { background: #991b13; }
.danger-quiet { background: #fff; border-color: #e6b8b3; color: var(--danger); }
.info-btn { background: #fff; border-color: #93b8e5; color: var(--info); }

/* ---- Inputs ---- */

input, select, textarea {
  border: 1px solid #cbd4d8; background: #fff;
  border-radius: 4px; padding: 8px 9px; min-height: 36px; color: var(--text);
}

textarea { resize: vertical; }
input.invalid, select.invalid { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(180,35,24,.12); }

/* ---- Notice / Toast ---- */

.notice {
  padding: 10px 12px; border: 1px solid #afd5d0;
  background: #edfffc; color: #075e57; border-radius: 5px; margin-bottom: 16px;
}

.notice.error { border-color: #efb5ae; background: #fff1ef; color: var(--danger); }
.hidden { display: none !important; }

/* ---- Views & Routing ---- */

.view { display: none; }
.view.active { display: block; }

/* ---- Metrics Grid ---- */

.metric-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 16px;
}

.metric {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 15px;
}

.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; font-size: 24px; margin-top: 7px; letter-spacing: 0; }
.metric small { display: block; color: var(--muted); margin-top: 5px; }

/* ---- Split Layout ---- */

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr);
  gap: 16px;
}

/* ---- Panels ---- */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; margin-bottom: 16px; overflow: hidden;
}

.panel-head {
  min-height: 50px; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); gap: 12px;
}

.panel-head h2 { font-size: 15px; margin: 0; }
.panel-head span, .panel-head a { font-size: 12px; color: var(--muted); }
.panel-head a { color: var(--primary); text-decoration: none; }

/* ---- Tables ---- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid #edf0f1; vertical-align: middle; }
th { font-size: 12px; color: #58666d; background: #fafbfb; font-weight: 650; }
tbody tr:hover { background: #f8fbfb; }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap { overflow: auto; }
.check { width: 38px; }

/* ---- Badges ---- */

.badge {
  display: inline-flex; align-items: center; width: max-content;
  padding: 3px 7px; border-radius: 4px; font-size: 12px;
  background: #eef2f3; color: #526067;
}

.badge.ok { background: #e8f7ef; color: var(--ok); }
.badge.error { background: #fff0ee; color: var(--danger); }
.badge.warning { background: #fff5e5; color: var(--warning); }
.badge.info { background: #e4effe; color: var(--info); }

/* ---- Forms ---- */

.form-panel { padding-bottom: 15px; }

.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px; padding: 16px;
}

.form-grid label { display: grid; gap: 6px; color: #4f5d63; font-size: 12px; }
.span-2 { grid-column: span 2; }
.form-actions { justify-content: flex-end; padding: 0 16px; }

/* ---- Tabs ---- */

.tabs { display: flex; border-bottom: 1px solid var(--line); gap: 18px; margin-bottom: 12px; }
.tabs button { border: 0; background: transparent; padding: 10px 2px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab { display: none; }
.tab.active { display: block; }

/* ---- Misc ---- */

.muted { color: var(--muted); font-size: 12px; }

pre {
  margin: 0; padding: 16px; min-height: 180px;
  white-space: pre-wrap; word-break: break-word;
  background: #fbfcfc; color: #324249; font: 12px/1.55 Consolas, monospace;
}

.endpoint-list { display: grid; grid-template-columns: 220px 1fr; gap: 0; padding: 8px 16px; }
.endpoint-list code, .endpoint-list span { padding: 10px 0; border-bottom: 1px solid #edf0f1; }
.endpoint-list span { color: var(--muted); }

.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-state strong { display: block; font-size: 16px; margin-bottom: 8px; color: var(--text); }

/* ---- Login Page ---- */

.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0d2b25 0%, #17272b 50%, #0f1f24 100%);
}

.login-card {
  background: #fff; border-radius: 8px; width: 400px; max-width: 94vw;
  padding: 40px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-card .brand-login { text-align: center; margin-bottom: 28px; }
.login-card .brand-login .mark { width: 48px; height: 48px; display: inline-grid; place-items: center; background: #d9fffa; color: #075e57; font-weight: 800; border-radius: 8px; font-size: 18px; margin-bottom: 12px; }
.login-card .brand-login h2 { margin: 0; color: #17272b; }
.login-card .brand-login p { color: var(--muted); margin: 4px 0 0; }
.login-card label { display: block; margin-bottom: 16px; color: #4f5d63; font-size: 12px; }
.login-card input { width: 100%; display: block; margin-top: 6px; }
.login-card button { width: 100%; margin-top: 8px; }
.login-card .login-error { color: var(--danger); font-size: 12px; margin-top: 8px; text-align: center; min-height: 20px; }

/* ---- Modal ---- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}

.modal-box {
  background: #fff; border-radius: 8px; width: 520px; max-width: 94vw;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.modal-box .modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-box .modal-head h3 { margin: 0; font-size: 16px; }
.modal-box .modal-head .close-btn { border: 0; background: transparent; font-size: 20px; padding: 4px 8px; color: var(--muted); }
.modal-box .modal-body { padding: 20px; }
.modal-box .modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---- Provider Detail ---- */

.detail-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  margin-bottom: 16px;
}

.detail-item { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.detail-item label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.detail-item .value { font-weight: 650; }

/* ---- Responsive ---- */

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .brand > span:last-child, .nav-item span, .nav-section, .side-footer .user-info { display: none; }
  .brand { justify-content: center; }
  .nav-item { text-align: center; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .split-layout { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; padding: 14px 0; }
  .toolbar { flex-wrap: wrap; justify-content: flex-end; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  main { padding: 0 12px 28px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 8px; display: block; }
  .brand { display: none; }
  nav { display: flex; padding: 0; overflow: auto; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-item span { display: block; }
  .topbar { display: block; }
  .toolbar { justify-content: flex-start; margin-top: 12px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .panel { overflow: auto; }
  .endpoint-list { grid-template-columns: 1fr; }
  .endpoint-list code { border-bottom: 0; padding-bottom: 2px; }
  .endpoint-list span { padding-top: 2px; }
  .topbar h1 { font-size: 19px; }
  .detail-grid { grid-template-columns: 1fr; }
  .login-card { padding: 24px; }
}
