:root {
  --bg: #f3efe7;
  --bg-panel: #fffdf8;
  --bg-soft: #ece6da;
  --text: #1f1f19;
  --text-soft: #676459;
  --line: rgba(31, 31, 25, 0.12);
  --brand: #2d6a4f;
  --brand-soft: #dcefe4;
  --accent: #c97b2b;
  --accent-soft: #f7e6d4;
  --danger: #a63a32;
  --danger-soft: #f7e0de;
  --shadow: 0 18px 40px rgba(31, 31, 25, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(201, 123, 43, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(45, 106, 79, 0.16), transparent 28%),
    linear-gradient(180deg, #f8f5ef 0%, var(--bg) 100%);
}

.shell {
  min-height: 100vh;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.mobile-shell {
  width: min(100%, 520px);
  padding: 14px 0 30px;
}

.hero {
  padding: 28px;
  border-radius: 32px;
  background: rgba(255, 253, 248, 0.78);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero h1 {
  margin: 18px 0 10px;
  font-size: clamp(32px, 6vw, 52px);
  line-height: 1.02;
}

.hero p {
  max-width: 720px;
  margin: 0;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.7;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 22px;
  margin-top: 24px;
}

.mobile-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
}

.mobile-login-card {
  width: 100%;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.mobile-brand h1 {
  margin: 14px 0 8px;
  font-size: 42px;
}

.mobile-brand p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.mobile-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.login-switch {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.switch-btn {
  border: none;
  border-radius: 16px;
  padding: 13px 10px;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.switch-btn.active {
  background: var(--brand);
  color: #fff;
}

.mobile-note {
  margin-top: 16px;
}

.login-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
  margin-top: 24px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.role-grid.single-column {
  grid-template-columns: 1fr;
}

.role-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 18px;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.role-card:hover {
  transform: translateY(-2px);
  border-color: rgba(45, 106, 79, 0.25);
  box-shadow: 0 12px 22px rgba(31, 31, 25, 0.08);
}

.role-card.active {
  background: linear-gradient(180deg, #f8fff9 0%, #edf7f0 100%);
  border-color: rgba(45, 106, 79, 0.38);
}

.role-card.compact p {
  font-size: 14px;
  line-height: 1.6;
}

.role-card h3,
.mini-card h3,
.section-head h2,
.stat-card h3,
.list-card h3 {
  margin: 0;
}

.role-card p,
.mini-card p,
.hint,
.stat-meta,
.scope-note,
.list-subtitle {
  margin: 8px 0 0;
  color: var(--text-soft);
}

.message {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
}

.message.info {
  background: var(--brand-soft);
  color: var(--brand);
}

.message.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.auth-box,
.family-form {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fffefb 0%, #fffaf3 100%);
}

.field-block {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.field-block:first-child {
  margin-top: 0;
}

.field-block label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}

.field-block input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.field-block select,
.rule-row select,
.rule-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.field-block input:focus {
  outline: 2px solid rgba(45, 106, 79, 0.18);
  border-color: rgba(45, 106, 79, 0.35);
}

.field-block select:focus,
.rule-row select:focus,
.rule-row input:focus {
  outline: 2px solid rgba(45, 106, 79, 0.18);
  border-color: rgba(45, 106, 79, 0.35);
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-soft);
  color: var(--text);
}

.btn.small {
  padding: 10px 14px;
  font-size: 13px;
}

.mini-grid {
  display: grid;
  gap: 12px;
}

.mini-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffaf1 0%, #fffdf9 100%);
  border: 1px solid var(--line);
}

.app-shell {
  display: none;
}

.app-shell.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin-top: 18px;
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar-title strong {
  font-size: 18px;
}

.topbar-title span {
  color: var(--text-soft);
  font-size: 13px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.badge.brand {
  background: var(--brand-soft);
  color: var(--brand);
}

.dashboard {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.dashboard.single {
  grid-template-columns: 1fr;
}

.sidebar {
  display: grid;
  gap: 16px;
  align-self: start;
}

.avatar-card,
.permissions-card,
.links-card {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: var(--shadow);
}

.avatar {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 30px;
  font-weight: 700;
}

.avatar-card h2 {
  margin: 14px 0 6px;
}

.avatar-card p {
  margin: 0;
  color: var(--text-soft);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--text-soft);
}

.content {
  display: grid;
  gap: 18px;
}

.content.stacked {
  grid-template-columns: 1fr;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--text-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stats-grid.compact-top {
  margin-top: 18px;
}

.stat-card {
  border-radius: 18px;
  padding: 18px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stat-value {
  margin-top: 10px;
  font-size: 32px;
  font-weight: 800;
}

.stat-meta {
  font-size: 12px;
}

.split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}

.account-grid,
.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.config-card,
.permission-card {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fffefb 0%, #fff9f0 100%);
  padding: 18px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.sync-meta {
  font-size: 12px;
  color: var(--text-soft);
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  font-size: 14px;
}

.rule-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.rule-row {
  display: grid;
  grid-template-columns: 1.6fr 0.8fr 0.7fr auto;
  gap: 12px;
}

.permission-block {
  margin-top: 18px;
}

.permission-block strong {
  display: block;
  margin-bottom: 10px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(45, 106, 79, 0.05);
  color: var(--text-soft);
}

.check-item input {
  width: 16px;
  height: 16px;
}

.viewer-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.app-mobile {
  margin-top: 14px;
}

.mobile-topbar {
  position: sticky;
  top: 8px;
  z-index: 10;
}

.list-card,
.chart-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.list-item {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  background: #fffcf5;
  border: 1px solid rgba(31, 31, 25, 0.06);
}

.list-item strong {
  display: block;
}

.list-item span {
  display: block;
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 13px;
}

.pill {
  min-width: 72px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill.brand {
  background: var(--brand-soft);
  color: var(--brand);
}

.pill.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.bars {
  display: flex;
  align-items: end;
  gap: 10px;
  height: 180px;
  margin-top: 18px;
}

.bar-col {
  flex: 1;
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.bar-value {
  font-size: 12px;
  color: var(--text-soft);
}

.bar-track {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: end;
}

.bar-fill {
  width: 100%;
  border-radius: 14px 14px 6px 6px;
  background: linear-gradient(180deg, #dda35f 0%, #c97b2b 100%);
}

.bar-label {
  font-size: 12px;
  color: var(--text-soft);
}

.footer-note {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.88);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
}

.setup-panel {
  margin-bottom: 2px;
}

@media (max-width: 980px) {
  .hero-grid,
  .login-layout,
  .dashboard,
  .split {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .account-grid,
  .permission-grid,
  .viewer-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rule-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100%, calc(100% - 20px));
    padding-top: 12px;
  }

  .mobile-shell {
    width: min(100%, calc(100% - 18px));
  }

  .hero,
  .panel,
  .topbar,
  .avatar-card,
  .permissions-card,
  .links-card,
  .stat-card,
  .list-card,
  .chart-card {
    border-radius: 20px;
  }

  .mobile-brand h1 {
    font-size: 34px;
  }

  .login-switch {
    grid-template-columns: 1fr;
  }

  .role-grid,
  .stats-grid,
  .account-grid,
  .permission-grid,
  .viewer-summary,
  .check-grid,
  .rule-row {
    grid-template-columns: 1fr;
  }
}
