:root {
  --bg: #f3f6fb;
  --panel: #fff;
  --ink: #152238;
  --muted: #6a7688;
  --line: #dfe7f2;
  --blue: #1476ff;
  --cyan: #10a6b5;
  --green: #17a668;
  --amber: #d99018;
  --red: #dc4c4c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: 236px 1fr;
}
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(360px, .85fr);
  background: var(--bg);
}
.auth-ready .auth-screen { display: none; }
.auth-pending > .sidebar, .auth-pending > .shell,
.auth-required > .sidebar, .auth-required > .shell { visibility: hidden; }
.auth-brand {
  padding: clamp(32px, 7vw, 96px);
  background: #071221;
  color: #fff;
  display: grid;
  grid-template-columns: 74px 1fr;
  align-content: end;
  gap: 24px;
}
.auth-brand img { width: 74px; height: 74px; border-radius: 8px; }
.auth-brand div { display: grid; gap: 12px; }
.auth-brand span, .auth-kicker { color: #70d6ff; font: 800 12px/1.4 "Microsoft YaHei", sans-serif; }
.auth-brand h1 { font-size: clamp(32px, 4vw, 58px); letter-spacing: 0; }
.auth-brand p { color: rgba(255,255,255,.72); line-height: 1.7; }
.auth-workspace {
  width: min(440px, calc(100% - 48px));
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 18px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.auth-workspace h2 { font-size: 28px; }
.auth-copy { color: var(--muted); line-height: 1.7; }
.auth-primary {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}
.auth-qr { min-height: 232px; padding: 14px; border: 1px solid #cbdcf2; background: #f7faff; display: grid; justify-items: center; gap: 9px; }
.auth-qr[hidden] { display: none; }
.auth-qr img { width: 190px; height: 190px; object-fit: contain; }
.auth-qr span { color: var(--muted); font-size: 12px; }
.auth-status { min-height: 24px; color: var(--muted); font-size: 13px; }
.auth-status.error { color: #c43d32; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

.sidebar {
  min-height: 100vh;
  padding: 18px;
  background: #0b1220;
  color: #fff;
  display: grid;
  align-content: start;
  gap: 10px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 8px 4px 18px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 8px; }
.brand img { width: 42px; height: 42px; border-radius: 10px; }
.brand div { display: grid; gap: 3px; }
.brand span, .topbar p, .tenant, .panel span, .hint, td { color: var(--muted); font-size: 13px; }
.sidebar button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,.72);
  text-align: left;
  padding: 0 12px;
  font-weight: 800;
}
.sidebar button.active { background: #1476ff; color: #fff; }
.nav-group {
  margin-top: 12px;
  padding: 14px 12px 4px;
  color: rgba(255,255,255,.42);
  font-size: 12px;
  font-weight: 900;
}
.platform-only { display: none; }
.is-platform-admin .sidebar .platform-only { display: block; }
.is-platform-admin .sidebar button.platform-only { width: 100%; }
.is-platform-admin section.platform-only { display: none; }
.is-platform-admin section.platform-only.active { display: block; }
.is-client .sidebar button:not([data-view="materials"]) { display: none; }
.is-client .sidebar [data-view="materials"] { display: block; width: 100%; }

.shell { min-width: 0; }
.topbar {
  height: 76px;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 24px; }
.account-area { display: flex; align-items: center; gap: 14px; }
.account-area div { display: grid; justify-items: end; gap: 3px; }
.account-area button { min-height: 34px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #40516b; padding: 0 12px; }
.account-area .mini-program-entry { border-color: var(--blue); background: var(--blue); color: #fff; font-weight: 800; }
.mini-program-dialog { width: min(390px, calc(100vw - 32px)); padding: 30px; border: 0; border-radius: 8px; color: var(--ink); text-align: center; box-shadow: 0 24px 80px rgba(7,18,33,.28); }
.mini-program-dialog::backdrop { background: rgba(7,18,33,.68); }
.mini-program-dialog .dialog-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 4px; background: #eef3f8; color: #40516b; font-size: 24px; line-height: 1; }
.mini-program-dialog .dialog-kicker { display: block; color: var(--blue); font-size: 12px; font-weight: 900; }
.mini-program-dialog h2 { margin: 10px 0 8px; font-size: 24px; }
.mini-program-dialog p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.mini-program-dialog img { width: 230px; height: 230px; margin: 22px auto 14px; object-fit: contain; }
.mini-program-dialog strong, .mini-program-dialog small { display: block; }
.mini-program-dialog small { margin-top: 7px; color: var(--muted); }
.project-switcher { width: 240px; display: grid; gap: 3px; color: var(--muted); font-size: 12px; }
.project-switcher select { height: 36px; padding: 6px 10px; }
.view { display: none; padding: 22px; }
.view.active { display: block; }

.hero {
  min-height: 190px;
  border-radius: 8px;
  padding: 22px;
  color: #fff;
  display: grid;
  align-content: end;
  gap: 8px;
  background: linear-gradient(125deg, rgba(8,28,62,.94), rgba(20,118,255,.68));
}
.admin-hero {
  min-height: 190px;
  border-radius: 8px;
  padding: 22px;
  color: #fff;
  display: grid;
  align-content: end;
  gap: 8px;
  background: linear-gradient(125deg, #111827, #0f766e);
}
.admin-hero strong { font-size: 30px; }
.admin-hero span, .admin-hero small { opacity: .86; font-weight: 800; }
.hero strong { font-size: 30px; }
.hero span, .hero small { opacity: .85; font-weight: 800; }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin: 18px 0; }
.metric, .panel, .quote-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.metric { padding: 16px; display: grid; gap: 8px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { color: var(--blue); font-size: 28px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { padding: 16px; margin-bottom: 16px; }
.panel header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel h2 { font-size: 18px; }
.actions { display: flex; gap: 8px; }
.actions button, .panel header button, #copyQuoteBtn, #addPointBtn, #exportBtn, #addLevelBtn, #createTenantBtn, #exportTenantBtn, #healthBtn, #seedBtn, .table-btn {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  padding: 0 12px;
  font-weight: 800;
}
.filters { display: grid; grid-template-columns: 1fr 160px; gap: 10px; margin-bottom: 14px; }
.form-grid {
  display: grid;
  grid-template-columns: 180px 1fr 1fr 120px;
  gap: 10px;
  margin-bottom: 14px;
}
.form-grid label { display: grid; gap: 6px; }
.levels-form { grid-template-columns: 160px 120px 1fr 1fr 120px; }
.tenants-form { grid-template-columns: 1fr 180px 120px; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; color: var(--ink); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: 13px; color: #40516b; background: #f7f9fc; }
.status { padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 900; color: var(--blue); background: rgba(20,118,255,.12); }
.status.approved, .status.shot { color: var(--green); background: rgba(23,166,104,.13); }
.status.review, .status.reshoot { color: var(--red); background: rgba(220,76,76,.13); }
.status.todo { color: var(--amber); background: rgba(217,144,24,.13); }
.row { min-height: 50px; padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 14px; }
.row div { display: grid; gap: 4px; }
.level-row strong { color: #25364d; }
.table-btn { min-height: 30px; margin-right: 6px; padding: 0 8px; font-size: 12px; }
.plan-board {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, #eef3fb 39px, transparent 40px),
    linear-gradient(#eef3fb 39px, transparent 40px),
    #fff;
  background-size: 40px 40px;
}
.plan-title {
  position: absolute;
  left: 14px;
  top: 12px;
  z-index: 2;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: #40516b;
  font-size: 13px;
  font-weight: 900;
}
.pin {
  position: absolute;
  min-width: 38px;
  height: 30px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.plan-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 240px;
  transform: translate(-50%, -50%);
}
.quote-card { padding: 22px; margin-bottom: 16px; background: #0f2544; color: #fff; display: grid; gap: 8px; }
.quote-card strong { font-size: 38px; color: #70d6ff; }
.config-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.config-list label { display: grid; gap: 6px; }
.sync-actions { margin-top: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sync-actions span, #syncStatus { color: var(--muted); font-size: 13px; }
#syncStatus.ok { color: var(--green); }
#syncStatus.warn { color: var(--amber); }
#syncStatus.error { color: var(--red); }
.plan-row {
  min-height: 62px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.plan-row div { display: grid; gap: 4px; }
.plan-row span, .mini-rate { color: var(--muted); font-size: 13px; }
.mini-rate { display: block; margin-top: 6px; white-space: nowrap; }
.hint { margin-top: 14px; line-height: 1.6; }

.materials-panel { padding: 0; overflow: hidden; }
.project-workbench, .project-customer-panel { margin-top: 16px; }
.project-workbench > header > div, .project-customer-panel > header > div { display: grid; gap: 4px; }
.project-form { padding: 16px; border-bottom: 1px solid var(--line); background: #f7fafc; }
.project-table-wrap { overflow-x: auto; }
.project-table { min-width: 780px; }
.project-table td:first-child { display: grid; gap: 3px; }
.project-table td small { color: #66706a; }
.current-project-row { background: #eaf4ff; }
.current-project-row td { border-color: #c9e1f8; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); color: #66706a; font-size: 12px; }
.confirmation-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; }
.confirmation-summary > div { display: grid; gap: 5px; }
.confirmation-summary span { color: #66706a; font-size: 12px; }
.invite-result { display: flex; align-items: center; gap: 18px; padding: 16px; border-top: 1px solid var(--line); background: #f7fafc; }
.invite-result img { width: 132px; aspect-ratio: 1; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.invite-result > div { display: grid; gap: 7px; }
.invite-result strong { font: 700 24px Bahnschrift, sans-serif; color: #1976d2; }
.invite-result small, .invite-result span { color: #66706a; }
.settings-list { display: grid; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; border-bottom: 1px solid var(--line); }
.setting-row > div { display: grid; gap: 5px; }
.setting-row span { color: #66706a; font-size: 12px; }
.setting-editor { padding: 14px 16px; border-bottom: 1px solid var(--line); background: #f7fafc; }
.setting-editor input { width: min(100%, 420px); }
.setting-editor .actions { margin-top: 10px; }
.materials-panel > header { padding: 16px; margin: 0; border-bottom: 1px solid var(--line); }
.materials-panel > header > div { display: grid; gap: 4px; }
.material-storage { padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f7fafc; }
.material-storage > div { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 12px; }
.material-storage strong { color: #202622; }
.material-storage span { color: #66706a; }
.material-storage progress { display: block; width: 100%; height: 8px; accent-color: #1976d2; }
.material-toolbar {
  display: grid;
  grid-template-columns: 170px minmax(240px, 1.4fr) minmax(180px, 1fr) 110px;
  align-items: end;
  gap: 10px;
  padding: 14px 16px;
  background: #f7f9f7;
  border-bottom: 1px solid var(--line);
}
.material-toolbar label { display: grid; gap: 6px; min-width: 0; }
.material-toolbar label > span { color: #39413d; font-size: 12px; font-weight: 800; }
.material-toolbar button, #addVideoLinkBtn {
  min-height: 41px;
  border: 0;
  border-radius: 6px;
  background: #1e8e5a;
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
}
.material-file input { padding: 7px 9px; }
.upload-state { padding: 10px 16px 12px; border-bottom: 1px solid var(--line); background: #fff; }
.upload-state > div { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 12px; }
.upload-state strong { color: #1e8e5a; font-family: Bahnschrift, sans-serif; }
.upload-state progress { width: 100%; height: 8px; accent-color: #1e8e5a; }
.video-link-form { border-bottom: 1px solid var(--line); }
.video-link-form summary { padding: 12px 16px; color: #39413d; font-size: 13px; font-weight: 800; cursor: pointer; }
.video-fields { grid-template-columns: 170px minmax(280px, 2fr) 100px minmax(160px, 1fr) 110px; border-top: 1px solid var(--line); border-bottom: 0; }
.materials-table-wrap { overflow-x: auto; }
.materials-table { min-width: 820px; }
.materials-table td { vertical-align: middle; }
.material-kind { display: inline-block; color: #1e8e5a; font-size: 12px; font-weight: 800; }
.material-name { display: grid; gap: 3px; min-width: 220px; }
.material-name strong { color: #202622; font-size: 13px; overflow-wrap: anywhere; }
.material-name small { color: #66706a; font-size: 12px; }
.material-source { color: #66706a; font-size: 12px; }
.material-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.material-actions button {
  min-height: 30px;
  border: 1px solid #d7ddd9;
  border-radius: 5px;
  background: #fff;
  color: #1e6f49;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}
.material-actions button.danger { color: #c43d32; }
.materials-table .empty { padding: 42px 16px; text-align: center; color: #66706a; }

@media (max-width: 980px) {
  .auth-screen { grid-template-columns: 1fr; overflow: auto; }
  .auth-brand { min-height: 230px; padding: 30px 24px; grid-template-columns: 58px 1fr; }
  .auth-brand img { width: 58px; height: 58px; }
  .auth-workspace { width: calc(100% - 32px); margin: 24px 16px 48px; padding: 24px; }
  body { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; grid-template-columns: repeat(3, 1fr); }
  .brand { grid-column: 1 / -1; }
  .metrics, .grid, .config-list, .form-grid, .levels-form, .tenants-form { grid-template-columns: 1fr; }
  .material-toolbar, .video-fields { grid-template-columns: 1fr; }
  .material-toolbar button { width: 100%; }
  .topbar { height: auto; min-height: 76px; flex-wrap: wrap; gap: 12px; }
  .account-area { flex: 1; flex-wrap: wrap; justify-content: flex-end; }
  .project-switcher { width: min(240px, 100%); }
  .invite-result, .confirmation-summary, .setting-row { align-items: stretch; flex-direction: column; }
}
