:root {
  --bg: #07111f;
  --panel: rgba(11, 23, 43, 0.85);
  --panel-strong: #0f1d35;
  --border: rgba(126, 151, 196, 0.18);
  --text: #e7eefc;
  --muted: #8da2c6;
  --primary: #39d0ff;
  --primary-strong: #00a6ff;
  --success: #35d38a;
  --warning: #ffb84d;
  --danger: #ff6b6b;
  --shadow: 0 24px 80px rgba(2, 10, 24, 0.45);
  --radius: 18px;
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --app-background:
    radial-gradient(circle at top right, rgba(37, 151, 255, 0.18), transparent 28%),
    radial-gradient(circle at bottom left, rgba(0, 219, 170, 0.12), transparent 32%),
    linear-gradient(180deg, #06101c 0%, #081423 42%, #09172a 100%);
  --header-bg: rgba(7, 17, 31, 0.8);
  --control-bg: rgba(255, 255, 255, 0.02);
  --field-bg: rgba(255, 255, 255, 0.04);
  --subtle-bg: rgba(255, 255, 255, 0.03);
  --track-bg: rgba(255, 255, 255, 0.06);
  --accent-bg: rgba(57, 208, 255, 0.08);
  --accent-bg-strong: rgba(57, 208, 255, 0.14);
  --accent-border: rgba(57, 208, 255, 0.22);
  --accent-border-strong: rgba(57, 208, 255, 0.28);
  --accent-text: #8be7ff;
  --focus-ring: rgba(57, 208, 255, 0.08);
  --focus-border: rgba(57, 208, 255, 0.55);
  --modal-backdrop: rgba(2, 10, 24, 0.72);
  --dialog-backdrop: rgba(2, 10, 24, 0.78);
  --toast-bg: rgba(9, 17, 31, 0.92);
  --toast-success-bg: linear-gradient(180deg, rgba(12, 31, 26, 0.96), rgba(9, 17, 31, 0.92));
  --toast-warning-bg: linear-gradient(180deg, rgba(41, 30, 12, 0.96), rgba(9, 17, 31, 0.92));
  --toast-danger-bg: linear-gradient(180deg, rgba(39, 18, 18, 0.96), rgba(9, 17, 31, 0.92));
  --dark-panel-bg: linear-gradient(180deg, rgba(8, 20, 39, 0.75), rgba(6, 16, 29, 0.15));
  color-scheme: dark;
}

html[data-theme="mac"] {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #ffffff;
  --border: rgba(29, 29, 31, 0.12);
  --text: #1d1d1f;
  --muted: #626975;
  --primary: #0071e3;
  --primary-strong: #005ecb;
  --success: #138a52;
  --warning: #a45d00;
  --danger: #d70015;
  --shadow: 0 18px 46px rgba(28, 39, 60, 0.12);
  --app-background:
    linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 48%, #ffffff 100%);
  --header-bg: rgba(255, 255, 255, 0.76);
  --control-bg: rgba(255, 255, 255, 0.7);
  --field-bg: rgba(255, 255, 255, 0.88);
  --subtle-bg: rgba(255, 255, 255, 0.66);
  --track-bg: rgba(29, 29, 31, 0.08);
  --accent-bg: rgba(0, 113, 227, 0.08);
  --accent-bg-strong: rgba(0, 113, 227, 0.13);
  --accent-border: rgba(0, 113, 227, 0.2);
  --accent-border-strong: rgba(0, 113, 227, 0.28);
  --accent-text: #0066cc;
  --focus-ring: rgba(0, 113, 227, 0.13);
  --focus-border: rgba(0, 113, 227, 0.5);
  --modal-backdrop: rgba(245, 245, 247, 0.72);
  --dialog-backdrop: rgba(245, 245, 247, 0.78);
  --toast-bg: rgba(255, 255, 255, 0.94);
  --toast-success-bg: linear-gradient(180deg, rgba(239, 255, 248, 0.98), rgba(255, 255, 255, 0.94));
  --toast-warning-bg: linear-gradient(180deg, rgba(255, 248, 232, 0.98), rgba(255, 255, 255, 0.94));
  --toast-danger-bg: linear-gradient(180deg, rgba(255, 241, 242, 0.98), rgba(255, 255, 255, 0.94));
  --dark-panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(245, 245, 247, 0.7));
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font-stack); color: var(--text); background: var(--app-background);
  min-height: 100%;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }

.container { width: min(1180px, calc(100vw - 32px)); margin: 0 auto; }
.site-header { position: sticky; top: 0; z-index: 50; backdrop-filter: blur(14px); background: var(--header-bg); border-bottom: 1px solid var(--border); }
.nav-shell { display: flex; align-items: center; justify-content: space-between; min-height: 76px; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 14px; }
.brand img { width: 44px; height: 44px; }
.brand strong { display: block; font-size: 15px; }
.brand span { color: var(--muted); font-size: 12px; }
.site-nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.site-nav a { color: var(--muted); }
.site-nav a:hover, .sidebar-nav a:hover { color: var(--text); }

.primary-btn, .ghost-btn, .ghost-link, .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 12px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: .2s ease;
}
.small { padding: 10px 14px; font-size: 13px; }
.primary-btn { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%); color: #001523; font-weight: 700; }
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 16px 40px rgba(0, 166, 255, 0.28); }
.site-nav a.header-cta-btn { color: #ffffff; }
.site-nav a.header-cta-btn:hover { color: #ffffff; }
.ghost-btn, .ghost-link { border-color: var(--border); color: var(--text); background: var(--control-bg); }
.ghost-link { padding: 0; border: 0; background: transparent; color: var(--primary); }
.theme-toggle {
  min-height: 42px;
  padding: 9px 12px;
  border-color: var(--border);
  color: var(--text);
  background: var(--control-bg);
  box-shadow: 0 10px 24px rgba(2, 10, 24, 0.08);
}
.theme-toggle:hover {
  border-color: var(--accent-border-strong);
  transform: translateY(-1px);
}
.theme-toggle-icon {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--track-bg);
  border: 1px solid var(--border);
}
.theme-toggle-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  transition: .2s ease;
}
.theme-toggle-mac .theme-toggle-icon::after {
  transform: translateX(12px);
}
html[data-theme="mac"] .primary-btn {
  color: #ffffff;
}
html[data-theme="mac"] .hero-panel,
html[data-theme="mac"] .feature-card,
html[data-theme="mac"] .metric-card,
html[data-theme="mac"] .notice-card,
html[data-theme="mac"] .mini-card,
html[data-theme="mac"] .empty-card,
html[data-theme="mac"] .prose-card,
html[data-theme="mac"] .status-card,
html[data-theme="mac"] .auth-panel,
html[data-theme="mac"] .sidebar,
html[data-theme="mac"] .topbar,
html[data-theme="mac"] .page-block,
html[data-theme="mac"] .panel-box,
html[data-theme="mac"] .site-header {
  backdrop-filter: blur(22px);
}

.hero-section, .page-hero, .section, .auth-section, .status-section { padding: 72px 0; }
.hero-grid, .split-layout, .contact-grid { display: grid; gap: 28px; }
.hero-grid { grid-template-columns: 1.2fr .8fr; align-items: center; min-height: 72vh; }
.hero-copy { color: var(--muted); max-width: 660px; line-height: 1.8; font-size: 18px; }
.hero-actions { display: flex; gap: 14px; margin: 28px 0 22px; flex-wrap: wrap; }
.trust-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.trust-strip span, .chip, .eyebrow {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--accent-border);
  background: var(--accent-bg);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
}
.eyebrow { margin-bottom: 16px; }
h1, h2, h3, h4, h5 { margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: clamp(34px, 4.8vw, 62px); letter-spacing: 0; }
h2 { font-size: clamp(24px, 3vw, 38px); }
p { margin: 0; color: var(--muted); line-height: 1.8; }

.hero-panel, .feature-card, .metric-card, .notice-card, .mini-card, .empty-card, .prose-card, .status-card, .auth-panel, .sidebar, .topbar, .page-block, .panel-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-panel { padding: 22px; }
.panel-grid, .card-grid, .footer-grid, .stats-grid, .form-grid, .shell-grid { display: grid; gap: 18px; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel-grid { grid-template-columns: repeat(2, 1fr); margin-top: 18px; }
.card-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card, .feature-card, .mini-card, .notice-card, .empty-card, .prose-card, .status-card, .auth-panel, .page-block, .panel-box { padding: 22px; }
.metric-card strong { display: block; font-size: 30px; margin-bottom: 8px; }
.metric-card.big strong { font-size: 48px; }
.section-heading { display: grid; gap: 12px; margin-bottom: 24px; }
.dark-panel { background: var(--dark-panel-bg); }
.stack-list { display: grid; gap: 14px; }
.result-detail p {
  white-space: pre-wrap;
  word-break: break-word;
}
.reference-list {
  margin: 8px 0 0 20px;
  display: grid;
  gap: 8px;
}
.reference-list .muted {
  display: block;
  word-break: break-all;
}
.reference-list p {
  margin-top: 4px;
}
.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.legal-meta span {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--control-bg);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
}
.legal-doc {
  color: var(--muted);
  line-height: 1.95;
  white-space: pre-wrap;
  word-break: break-word;
}
.contact-grid { grid-template-columns: .9fr 1.1fr; }
.qr-box { margin-top: 20px; width: 120px; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); }

.auth-section, .status-section { min-height: calc(100vh - 190px); display: grid; place-items: center; }
.auth-panel { width: min(840px, calc(100vw - 32px)); display: grid; gap: 26px; }
.auth-panel.wide { width: min(980px, calc(100vw - 32px)); }
.auth-form { display: grid; gap: 14px; }
.auth-form.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.auth-form.two-cols button { grid-column: 1 / -1; }

.dashboard-main form .primary-btn,
.dashboard-main form .ghost-btn {
  width: auto;
  min-width: 140px;
  justify-self: start;
  align-self: start;
}

.dashboard-main .toolbar .primary-btn,
.dashboard-main .toolbar .ghost-btn,
.dashboard-main .action-row .primary-btn,
.dashboard-main .action-row .ghost-btn,
.dashboard-main .date-field .primary-btn,
.dashboard-main .date-field .ghost-btn,
.dashboard-main .split-inline .primary-btn,
.dashboard-main .split-inline .ghost-btn {
  min-width: auto;
  justify-self: auto;
}

input, textarea, select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--focus-border); box-shadow: 0 0 0 4px var(--focus-ring); }

.site-footer { padding: 34px 0 26px; border-top: 1px solid var(--border); margin-top: 48px; }
.footer-grid { grid-template-columns: 1.2fr 1fr 1fr; }
.footer-bottom { padding-top: 22px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 24px; font-size: 13px; }

.dashboard-body { min-height: 100vh; }
.dashboard-shell { display: grid; grid-template-columns: 268px 1fr; min-height: 100vh; }
.sidebar { margin: 20px; padding: 22px; position: sticky; top: 20px; height: calc(100vh - 40px); }
.brand-side { margin-bottom: 26px; }
.sidebar-nav { display: grid; gap: 8px; }
.sidebar-nav a {
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--muted);
  border: 1px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--text);
}
.dashboard-main { padding: 20px 20px 20px 0; display: grid; gap: 18px; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; }
.topbar-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.page-content { display: grid; gap: 18px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.nav-toggle { display: none; margin-bottom: 10px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); color: var(--muted); vertical-align: top; }
th { color: var(--text); font-weight: 600; }
.table-shell { overflow-x: auto; }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.action-row.compact { margin-bottom: 0; gap: 8px; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar > * { flex: 1 1 180px; }
.toolbar button { flex: 0 0 auto; }
.bar-list { display: grid; gap: 12px; }
.bar-item { display: grid; grid-template-columns: 120px 1fr 70px; gap: 12px; align-items: center; }
.bar-track { height: 10px; border-radius: 999px; background: var(--track-bg); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #4dffca); }
.tag-success { color: var(--success); }
.tag-danger { color: var(--danger); }
.tag-warning { color: var(--warning); }
.empty-state { padding: 26px; border-radius: 16px; border: 1px dashed var(--border); color: var(--muted); text-align: center; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.split-inline { display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; }
.kpi-number { font-size: 36px; font-weight: 700; margin-bottom: 8px; }
.pagination-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.link-btn { color: var(--primary); }
.field-label { display: grid; gap: 8px; color: var(--muted); }
.upload-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--subtle-bg);
}
.upload-preview-shell {
  display: grid;
  gap: 10px;
}
.upload-preview-label {
  color: var(--text);
  font-weight: 600;
}
.upload-preview {
  min-height: 170px;
  border-radius: 16px;
  border: 1px dashed var(--accent-border);
  background: var(--dark-panel-bg);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.upload-preview img {
  width: 100%;
  height: 100%;
  max-height: 220px;
  object-fit: contain;
}
.invite-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
}
.invite-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(8px);
}
.invite-modal-card {
  position: relative;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}
.upload-path {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--subtle-bg);
  color: var(--accent-text);
  word-break: break-all;
}
.date-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 260px;
}
.date-field input {
  flex: 1 1 auto;
  min-width: 0;
}
.date-picker-btn {
  white-space: nowrap;
}
.date-shortcuts {
  margin-top: 12px;
}
.checkbox-group { display: flex; flex-wrap: wrap; gap: 12px 18px; }
.checkbox-line { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); }
.checkbox-line input { width: auto; }
.ghost-btn.active {
  background: var(--accent-bg-strong);
  border-color: var(--accent-border-strong);
  color: var(--text);
}
button[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.chart-shell { display: grid; gap: 10px; }
.chart-svg { width: 100%; height: 180px; overflow: visible; }
.chart-labels { display: grid; grid-template-columns: repeat(auto-fit, minmax(32px, 1fr)); gap: 8px; color: var(--muted); font-size: 12px; }
.donut-card { position: relative; display: grid; place-items: center; min-height: 240px; }
.donut-svg { width: 180px; height: 180px; }
.donut-content { position: absolute; display: grid; place-items: center; gap: 6px; text-align: center; }
.donut-content strong { font-size: 34px; }
.task-banner {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--accent-border);
  background: var(--accent-bg);
}
.task-banner strong { display: block; margin-bottom: 4px; }
.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(57, 208, 255, 0.7);
  animation: pulse 1.4s infinite;
}
.loading-block {
  min-height: 200px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 1px dashed var(--border);
  color: var(--muted);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(57, 208, 255, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(57, 208, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(57, 208, 255, 0); }
}

#toast { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 10px; z-index: 999; }
.toast-item {
  min-width: 260px;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--toast-bg);
  box-shadow: var(--shadow);
}
.toast-success {
  border-color: rgba(53, 211, 138, 0.28);
  background: var(--toast-success-bg);
}
.toast-warning {
  border-color: rgba(255, 184, 77, 0.28);
  background: var(--toast-warning-bg);
}
.toast-danger {
  border-color: rgba(255, 107, 107, 0.28);
  background: var(--toast-danger-bg);
}
.admin-dialog-shell {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
}
.admin-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: var(--dialog-backdrop);
  backdrop-filter: blur(10px);
}
.admin-dialog-card {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}
.admin-dialog-info {
  border-color: var(--accent-border);
}
.admin-dialog-danger {
  border-color: rgba(255, 107, 107, 0.3);
}
.admin-dialog-error {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 107, 107, 0.24);
  background: rgba(255, 107, 107, 0.08);
  color: var(--danger);
}

@media (max-width: 1080px) {
  .hero-grid, .contact-grid, .footer-grid, .card-grid.cols-3, .card-grid.cols-4, .stats-grid, .dashboard-shell { grid-template-columns: 1fr; }
  .dashboard-shell { padding-bottom: 40px; }
  .sidebar { position: static; height: auto; display: none; }
  .dashboard-body.nav-open .sidebar { display: block; margin-bottom: 0; }
  .dashboard-main { padding: 0 20px 20px; }
  .nav-toggle { display: inline-flex; }
}

@media (max-width: 720px) {
  .nav-shell, .topbar, .split-inline { flex-direction: column; align-items: stretch; }
  .site-nav { justify-content: center; }
  .auth-form.two-cols { grid-template-columns: 1fr; }
  .card-grid.cols-2 { grid-template-columns: 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .date-field { flex-direction: column; align-items: stretch; }
  .bar-item { grid-template-columns: 1fr; }
  h1 { font-size: 34px; }
}
