/* ============================================================
   ATLAS 管理后台 · 通用样式
   对齐 outputs/通用页面设计规范.md 设计令牌
   ============================================================ */

:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --text: #1d1f24;
  --muted: #69707d;
  --line: #e2e5e9;
  --primary: #cf0a2c;
  --primary-dark: #a5001e;
  --primary-soft: #fff1f3;
  --green: #17875d;
  --orange: #b76a00;
  --radius: 5px;
  --shadow: 0 1px 2px rgba(18, 20, 24, 0.04);
  /* Admin-specific */
  --red: var(--primary);
  --red-soft: var(--primary-soft);
  --ink: var(--text);
  --nav: #20252d;
  --bad: #c73535;
  --yellow: #a96908;
}

/* ---- Global Reset ---- */
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }

/* ============================================================
   App Shell
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--nav);
  color: #e8ebef;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  border-bottom: 1px solid #363c45;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: var(--primary);
  font-weight: 800;
  color: white;
}
.brand strong { display: block; font-size: 14px; }
.brand small, .side-user small {
  display: block;
  color: #9199a5;
  font-size: 10px;
  margin-top: 2px;
  letter-spacing: .5px;
}
.sidebar nav { padding-top: 12px; }
.sidebar nav p {
  margin: 14px 10px 5px;
  color: #79818c;
  font-size: 10px;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #c7cdd5;
  padding: 9px 10px;
  text-align: left;
  margin: 2px 0;
}
.nav-item span { width: 16px; color: #9098a4; text-align: center; }
.nav-item:hover { background: #2a3038; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.active span { color: #fff; }
.side-user {
  margin-top: auto;
  border-top: 1px solid #363c45;
  padding: 14px 5px 0;
}
.side-user-profile {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.side-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: #444c57;
  font-size: 11px;
}
.side-user strong { font-size: 11px; }
.side-return-home {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 11px;
  border: 1px solid #414954;
  border-radius: 4px;
  background: #292f37;
  color: #d9dde3;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 650;
}
.side-return-home > span {
  font-size: 14px;
  line-height: 1;
  transition: transform 160ms ease;
}
.side-return-home:hover,
.side-return-home:focus-visible {
  border-color: #727b87;
  background: #343b45;
  color: #fff;
}
.side-return-home:hover > span {
  transform: translateX(-2px);
}

/* ---- Topbar ---- */
.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 4;
}
.topbar > div:first-child strong { display: block; font-size: 14px; }
.topbar > div:first-child small { display: block; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.search {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 280px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 10px;
  color: #8a94a3;
}
.search input { border: 0; outline: 0; width: 100%; background: transparent; }
.icon-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 4px;
  color: #667085;
  display: grid; place-items: center;
}

/* ============================================================
   Page Layout
   ============================================================ */
.page { display: none; padding: 22px 24px 40px; }
.page.active { display: block; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 17px;
}
.page-head h1 { font-size: 20px; margin: 0 0 3px; }
.page-head p { margin: 0; color: var(--muted); font-size: 11px; }

/* ============================================================
   Buttons (aligned with common spec)
   ============================================================ */
button.primary, button.secondary {
  border-radius: 4px;
  padding: 8px 13px;
  font-weight: 650;
}
.primary {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}
.primary:hover { background: var(--primary-dark); }
.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: #344054;
}
.link {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 2px 4px;
  font-size: 11px;
  font-weight: 650;
}
.link:hover { text-decoration: underline; }

/* ============================================================
   Status Strip & Source Strip
   ============================================================ */
.status-strip, .source-strip {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 10px 14px;
  margin-bottom: 14px;
  color: #596579;
  border-radius: var(--radius);
}
.status-strip span:first-child { color: var(--text); font-weight: 600; }

/* Status dots */
.ok, .warn-dot, .bad-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
}
.warn-dot { background: var(--orange); }
.bad-dot, .red { background: var(--bad) !important; }
.yellow { background: var(--orange) !important; }

/* ============================================================
   KPI Grid
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.kpi-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}
.kpi-grid span { display: block; color: #5e6b7c; font-size: 11px; }
.kpi-grid strong { display: block; font-size: 25px; margin: 7px 0 2px; }
.kpi-grid small { color: #7d8795; }
.danger { color: var(--primary) !important; }

/* ============================================================
   Grids
   ============================================================ */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(330px, 1fr);
  gap: 14px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 180px minmax(420px, 1.5fr) minmax(260px, .8fr);
  gap: 14px;
}

/* ============================================================
   Panel / Card
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}
.panel h2 { font-size: 14px; margin: 0; }
.panel-head p { margin: 3px 0 0; color: #7c8795; font-size: 11px; }

/* ============================================================
   Data Table (aligned with common spec)
   ============================================================ */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  background: var(--surface-soft);
  color: var(--muted);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf0f3;
  vertical-align: middle;
}
td strong, td small { display: block; }
td small { color: #8a94a3; margin-top: 2px; font-size: 11px; }
tbody tr:hover { background: #fbfbfc; }
tbody tr:last-child td { border-bottom: 0; }
tr.sep td {
  padding: 8px 12px;
  background: var(--surface-soft);
  border: none;
}
tr.sep td small.tag { margin-right: 6px; }
.num { text-align: right !important; }
.num.bold { font-weight: 650; }

/* ============================================================
   Tags (aligned with common spec)
   ============================================================ */
.tag {
  display: inline-block;
  border-radius: 4px;
  background: #f0f1f3;
  color: #626975;
  padding: 2px 6px;
  font-size: 10px;
  font-style: normal;
  font-weight: 650;
  white-space: nowrap;
}
.tag.good { background: #edf8f3; color: var(--green); }
.tag.warn { background: #fff4df; color: #a65f00; }
.tag.bad, .danger-tag { background: var(--primary-soft); color: var(--primary); }

/* ============================================================
   Tabs & Sub-tabs
   ============================================================ */
.tabs, .module-tabs {
  display: flex;
  gap: 1px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  background: var(--surface);
}
.tabs button, .module-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 10px 20px;
  color: #5e646e;
  font-size: 13px;
  font-weight: 600;
  position: relative;
}
.tabs button.active, .module-tabs button.active {
  color: var(--primary);
  font-weight: 700;
  background: var(--primary-soft);
}
.tabs button.active::after, .module-tabs button.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

/* Sub-panels (for tab content within a page) */
.sub-panel { display: none; }
.sub-panel.active { display: block; }

/* BI config inner tabs (dim-panel, report-panel) */
.dim-panel, .report-panel { display: none; }
.dim-panel.active, .report-panel.active { display: block; }
.non-bi-module-panel { display: none; padding: 16px; }
.non-bi-module-panel.active { display: block; }
[hidden] { display: none !important; }

/* ============================================================
   Toolbar & Filters
   ============================================================ */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.toolbar > div { display: flex; gap: 5px; }
.filter {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 4px;
  padding: 6px 10px;
  color: #596579;
  font-size: 11px;
  font-weight: 650;
}
.filter.active {
  border-color: rgba(207, 10, 44, 0.35);
  background: var(--primary-soft);
  color: var(--primary);
}
.input {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 10px;
  margin-right: 6px;
  outline: none;
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: #d56276;
  box-shadow: 0 0 0 2px rgba(207, 10, 44, 0.08);
}
.table-panel { overflow: hidden; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 10px 14px;
  color: var(--muted);
}
.pagination span { margin-right: auto; }
.pagination button {
  border: 1px solid var(--line);
  background: var(--surface);
  min-width: 27px;
  height: 27px;
  border-radius: 3px;
}
.pagination button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ============================================================
   Permission Summary
   ============================================================ */
.permission-summary {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  align-items: center;
  border-left: 3px solid var(--primary);
  background: var(--surface);
  padding: 11px 14px;
  margin-bottom: 14px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.permission-summary span { color: var(--primary); font-weight: 600; }
.permission-summary small { color: #8a5b63; }

/* ============================================================
   Level Tags
   ============================================================ */
.level {
  display: inline-block;
  padding: 2px 5px;
  background: #f0f2f5;
  color: #596579;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 650;
}
.level.l4 { background: var(--primary-soft); color: var(--primary); }

/* ============================================================
   Activity List (Overview)
   ============================================================ */
.activity {
  list-style: none;
  margin: 0;
  padding: 5px 15px;
}
.activity li {
  display: flex;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid #edf0f3;
}
.activity i {
  width: 7px; height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: #8893a0;
}
.activity strong { font-size: 12px; }
.activity p { margin: 2px 0 0; color: #818b98; font-size: 11px; }

/* ============================================================
   Drawer
   ============================================================ */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 9;
}
.drawer {
  position: fixed;
  right: 0; top: 0;
  width: 520px;
  height: 100vh;
  background: var(--surface);
  box-shadow: -12px 0 28px rgba(18, 20, 24, 0.12);
  transform: translateX(100%);
  transition: .22s;
  z-index: 10;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}
.drawer.open { transform: translateX(0); }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-head, .drawer-foot {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-head strong, .drawer-head small { display: block; }
.drawer-head small { color: #8a94a3; margin-top: 3px; }
.drawer-head button {
  border: 0;
  background: transparent;
  font-size: 22px;
  color: #667085;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.drawer-body { flex: 1; overflow: auto; padding: 3px 4px; }
.drawer-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
  gap: 8px;
}
.drawer-body > label {
  display: block;
  margin: 12px 15px 0;
  color: #4a5565;
  font-size: 11px;
}
.drawer-body input,
.drawer-body select,
.drawer-body textarea {
  display: block;
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  padding: 6px 8px;
  margin-top: 5px;
  outline: none;
}
.drawer-body textarea { height: 80px; resize: none; }

/* Form helpers */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 15px 0;
}
.form-row label { color: #4a5565; font-size: 11px; }
.form-row select,
.form-row input {
  display: block;
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  padding: 6px 8px;
  margin-top: 5px;
  outline: none;
}
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}
.check-grid span {
  border: 1px solid var(--line);
  padding: 8px;
  border-radius: 4px;
}

/* ============================================================
   Notices
   ============================================================ */
.notice {
  margin: 12px 15px 0;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 11px;
}
.danger-lite { background: var(--primary-soft); color: #9d1d33; }
.info-lite { background: #eef5ff; color: #335c8a; }
.warn-lite { background: #fff7e8; color: #8a5a08; }

/* ============================================================
   Toggle & Switch
   ============================================================ */
.toggle input { accent-color: var(--primary); }
.switch-row {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid #edf0f3;
}
.switch-row span strong, .switch-row span small { display: block; }
.switch-row span small { color: #8a94a3; margin-top: 2px; }
.switch-row input[type="checkbox"] { accent-color: var(--primary); }

/* ============================================================
   Misc
   ============================================================ */
.mini {
  width: 33px;
  border: 1px solid var(--line);
  border-radius: 3px;
  text-align: center;
}
.full { width: 100%; margin-top: 12px; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #20252d;
  color: #fff;
  padding: 10px 16px;
  border-radius: 4px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ============================================================
   Watermark Preview
   ============================================================ */
.watermark-preview {
  position: fixed;
  right: 28px;
  bottom: 18px;
  color: rgba(207, 10, 44, 0.13);
  font-size: 15px;
  transform: rotate(-8deg);
  pointer-events: none;
}

/* ============================================================
   Portal specific
   ============================================================ */
.portal-grid { grid-template-columns: 1fr 1fr; }
.portal-grid .switch-row { margin: 0 15px; }
.entrance-list {
  list-style: none;
  margin: 0;
  padding: 0 15px;
}
.entrance-list li {
  display: grid;
  grid-template-columns: 32px 1fr auto 28px;
  gap: 9px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid #edf0f3;
}
.entry-icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: #f2f4f7;
  border-radius: 4px;
  color: #475467;
  font-weight: 600;
}
.entrance-list strong, .entrance-list small { display: block; }
.entrance-list small { color: #8a94a3; }

/* ============================================================
   Source strip
   ============================================================ */
.source-strip { background: var(--surface-soft); }

/* ============================================================
   Page Actions
   ============================================================ */
.page-actions { display: flex; gap: 8px; }

.construction-page {
  min-height: calc(100vh - 49px);
  padding: 34px 28px;
}

.construction-page-head {
  margin-bottom: 28px;
}

.construction-page-head p {
  margin: 0;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.construction-page-head h1 {
  margin: 7px 0 0;
  color: var(--text);
  font-size: 24px;
  line-height: 1.2;
}

.construction-notice {
  display: flex;
  min-height: 60px;
  align-items: center;
  gap: 28px;
  border-left: 3px solid var(--primary);
  background: var(--surface-soft);
  padding: 0 18px;
}

.construction-notice strong {
  color: var(--text);
  font-size: 17px;
}

.construction-notice span {
  color: var(--muted);
  font-size: 13px;
}

.construction-baseline {
  margin-top: 56px;
  border-top: 1px solid var(--line);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1250px) {
  .grid-3 { grid-template-columns: 160px 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .construction-page {
    padding: 28px 20px;
  }

  .construction-notice {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
  }
}

/* ATLAS compact wordmark for the dark admin sidebar. */
.atlas-admin-brand {
  min-height: 53px;
}

.atlas-admin-brand .atlas-compact-wordmark {
  color: #ffffff;
  font-size: 17px;
  font-weight: 850;
  letter-spacing: 0.105em;
  line-height: 1;
}

.atlas-admin-brand small {
  margin-top: 5px;
  color: #aeb5bf;
  font-size: 9px;
  letter-spacing: 0.08em;
}
