:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #6b7280;
  --accent: #246bfd;
  --accent-soft: #eaf1ff;
  --line: #e7ebf2;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(23, 32, 51, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

a { color: inherit; }

.shell {
  width: min(760px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.topbar, .admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .1em;
}

h1 {
  margin: 8px 0 2px;
  font-size: clamp(28px, 6vw, 42px);
}

h2 { margin: 0; font-size: 18px; }

.muted { margin: 0; color: var(--muted); }

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: #2457c5;
  font-weight: 800;
}

.avatar-image { object-fit: cover; }

.hero {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  display: flex;
  gap: 12px;
  box-shadow: var(--shadow);
}

.hero p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--success);
  flex: 0 0 auto;
}

.warning-hero { background: #fffaf0; }
.warning-dot { background: var(--warning); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.card {
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.card span, .card small { color: var(--muted); }
.card strong { font-size: 30px; margin: 12px 0 auto; }
.card small { margin-top: 10px; }

.identity-card {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.identity-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.identity-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.text-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.company-switcher {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.company-chip {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.company-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 26px 2px 12px;
}

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

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.module-card {
  min-height: 78px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(23, 32, 51, .05);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.module-icon {
  font-size: 19px;
  line-height: 1;
  margin-bottom: 8px;
}

.module-card strong {
  font-size: 14px;
  line-height: 1.15;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 70% 12%, #e4ecff 0, transparent 32%),
    var(--bg);
}

.auth-shell {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 22px 60px rgba(23, 32, 51, .10);
}

.auth-logo {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 17px;
  background: var(--accent);
  color: white;
  font-size: 18px;
  font-weight: 800;
}

.auth-title { margin-top: 8px; }
.auth-copy { color: var(--muted); line-height: 1.7; }

.primary-button {
  display: block;
  margin-top: 24px;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
}

.setup-notice {
  margin-top: 24px;
  padding: 14px;
  border-radius: 14px;
  background: #fff7e8;
  color: #8a5a00;
  line-height: 1.6;
}

.auth-footnote {
  margin: 16px 0 0;
  color: #9aa2b1;
  font-size: 12px;
  text-align: center;
}

.back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.module-hero {
  display: flex;
  align-items: center;
  gap: 16px;
}

.module-hero-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 28px;
}

/* Admin */
.admin-shell {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 80px;
}

.admin-badge {
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.saved-banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #ecfdf3;
  color: #147a3f;
  font-weight: 700;
  font-size: 13px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 22px;
}

.admin-stats div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
}

.admin-stats strong { display: block; font-size: 26px; }
.admin-stats span { color: var(--muted); font-size: 12px; }

.admin-section {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.admin-list, .assignment-list { display: flex; flex-direction: column; }

.list-row, .assignment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child, .assignment-row:last-child { border-bottom: 0; }
.list-row div, .assignment-row div { display: flex; flex-direction: column; gap: 3px; }
.list-row span, .assignment-row span { color: var(--muted); font-size: 12px; }

.status-pill {
  padding: 6px 9px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #147a3f !important;
  font-weight: 700;
}

.inline-form, .assign-form {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  margin-top: 14px;
}

input, select, button {
  font: inherit;
}

input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--text);
}

button {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.role-panel {
  border-top: 1px solid var(--line);
}

.role-panel:first-child { border-top: 0; }

.role-panel summary {
  padding: 14px 0;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.role-panel summary div { display: flex; flex-direction: column; gap: 4px; }
.role-panel summary span { color: var(--muted); font-size: 12px; }
.add-panel { margin-top: 8px; }

.role-form {
  padding: 0 0 16px;
  display: grid;
  gap: 10px;
}

.role-form > label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.check-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 13px;
}

.check-card input { width: auto; }

.user-panel {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.user-panel:first-of-type { border-top: 0; }

.user-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.user-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-identity img, .mini-avatar {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  object-fit: cover;
}

.mini-avatar {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.user-identity div { display: flex; flex-direction: column; gap: 3px; }
.user-identity span { color: var(--muted); font-size: 12px; }

.secondary-button {
  background: #eef2f7;
  color: var(--text);
  padding: 8px 10px;
  font-size: 12px;
}

.assignment-list { margin-top: 10px; }

.danger-link {
  padding: 0;
  background: transparent;
  color: var(--danger);
  font-size: 12px;
}

.empty-small {
  padding: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 620px) {
  .shell, .admin-shell { padding-top: 20px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .card { min-height: 120px; padding: 15px; }
  .module-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .module-card { min-height: 74px; padding: 10px 11px; border-radius: 15px; }
  .module-icon { font-size: 18px; margin-bottom: 7px; }
  .module-card strong { font-size: 13px; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .inline-form, .assign-form { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-header { align-items: flex-start; }
  .admin-badge { display: none; }
}

@media (max-width: 380px) {
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .permission-grid { grid-template-columns: 1fr; }
}


.error-banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff1f2;
  color: #b42318;
  font-weight: 700;
  font-size: 13px;
}

.low-frequency-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.low-frequency-panel summary {
  padding: 14px 0 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.low-frequency-panel summary span {
  color: var(--muted);
  font-size: 12px;
}

.compact-admin-form {
  margin-top: 10px;
  padding-bottom: 4px;
}

.protected-admin-badge {
  padding: 8px 10px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #147a3f;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}


@media (min-width: 900px) {
  .shell {
    width: min(980px, calc(100% - 48px));
    padding-top: 34px;
  }

  .module-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
  }

  .module-card {
    min-height: 82px;
  }

  .grid {
    gap: 14px;
  }

  .card {
    min-height: 124px;
  }
}
