/* Purpose: Mobile-first SaaS-style UI without third-party CSS. */
:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d8deea;
  --primary: #1769e0;
  --primary-dark: #0f55ba;
  --ok: #138a53;
  --bad: #c23b3b;
  --shadow: 0 10px 28px rgba(28, 39, 64, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
body.admin-page { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
.hidden { display: none !important; }
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; letter-spacing: 0; }
.topbar nav { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.app-shell { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 60px); }
.admin-page .app-shell { height: calc(100vh - 60px); min-height: 0; }
.sidebar {
  padding: 18px; border-right: 1px solid var(--line); background: #fbfcff;
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
}
.admin-page .sidebar { position: relative; top: 0; height: calc(100vh - 60px); }
.menu {
  width: 100%; border: 0; background: transparent; color: var(--muted); text-align: left;
  padding: 11px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
}
.menu.active, .menu:hover { background: #eaf2ff; color: var(--primary); }
.content { padding: 22px; max-width: 1280px; width: 100%; }
.admin-page .content { height: calc(100vh - 60px); overflow-y: auto; max-width: none; }
h1 { margin: 0 0 18px; font-size: 28px; }
h2 { margin: 0 0 12px; font-size: 18px; }
.grid { display: grid; gap: 14px; }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.settings-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.profile-account-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.form-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}
.form-title { grid-column: 1 / -1; font-weight: 800; font-size: 16px; }
.panel, .stat, .auth-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.stat span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat strong { font-size: 24px; }
.form label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; }
.form input, .form textarea, .form select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  color: var(--text); padding: 11px 12px; min-height: 42px;
}
.form textarea { min-height: 100px; resize: vertical; }
.form.stack { display: grid; gap: 14px; }
.form.inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.form.inline label { min-width: 180px; flex: 1; }
button, .primary, .ghost {
  min-height: 40px; border-radius: 8px; border: 1px solid transparent;
  padding: 9px 14px; cursor: pointer; white-space: nowrap;
}
.form > button, .form-actions button { margin-top: 12px; align-self: end; }
.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.primary:hover { background: var(--primary-dark); }
.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 700; }
td { font-size: 14px; }
pre { white-space: pre-wrap; word-break: break-word; color: #263247; }
.toast {
  position: fixed; right: 18px; bottom: 18px; background: #172033; color: #fff;
  border-radius: 8px; padding: 12px 14px; max-width: min(420px, calc(100vw - 36px));
  box-shadow: var(--shadow); z-index: 20;
}
.modal-backdrop {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(17, 24, 39, .42); padding: 18px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  width: min(460px, 100%); background: var(--panel); border-radius: 8px;
  border: 1px solid var(--line); box-shadow: var(--shadow); padding: 22px;
}
.modal p { color: var(--muted); line-height: 1.7; }
.modal button { width: 100%; margin-top: 8px; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-shell { width: min(980px, 100%); }
.auth-panel {
  display: grid; grid-template-columns: 1fr 400px; gap: 22px; align-items: center;
}
.auth-copy h1 { font-size: 42px; margin: 8px 0 12px; }
.auth-copy p { color: var(--muted); font-size: 17px; line-height: 1.7; }
.eyebrow { color: var(--primary); font-weight: 800; font-size: 13px; }
.feature-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.feature-list span {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; color: var(--muted); box-shadow: var(--shadow);
}
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; background: #fff; border: 1px solid var(--line); }
.tab.active { color: #fff; background: var(--primary); border-color: var(--primary); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
@media (max-width: 860px) {
  body.admin-page { overflow: auto; }
  .app-shell { grid-template-columns: 1fr; }
  .admin-page .app-shell { height: auto; }
  .sidebar {
    position: sticky; top: 60px; z-index: 4; display: flex; gap: 8px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 10px;
  }
  .admin-page .sidebar { position: sticky; top: 60px; height: auto; }
  .admin-page .content { height: auto; overflow: visible; }
  .menu { width: auto; flex: 0 0 auto; margin: 0; }
  .content { padding: 16px; }
  .cards-4, .grid-2, .grid-4, .settings-grid, .profile-account-grid, .auth-panel { grid-template-columns: 1fr; }
  .auth-copy h1 { font-size: 32px; }
}
