*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--surface-soft); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }

.page-state { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.state-card { width: min(520px, 100%); padding: 34px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.state-card h1 { margin: 8px 0; color: var(--navy); font-size: 1.65rem; }
.state-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.6; }
.state-card--loading { display: flex; align-items: center; gap: 18px; text-align: left; }
.state-card--loading p { margin: 0; }
.loading-mark { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; flex: 0 0 auto; }
.state-mark { width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 14px; display: grid; place-items: center; background: var(--navy); color: #fff; font-weight: 700; }
.state-mark--error { background: var(--red); }
.state-actions { display: flex; justify-content: center; gap: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { min-height: 100vh; height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column; background: var(--navy); }
.brand { padding: 26px 22px 22px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-logo { display: flex; align-items: center; gap: 11px; }
.brand-n { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--radius-sm); background: #fff; color: var(--navy); font-weight: 700; }
.brand-name { color: #fff; font-size: 12.5px; line-height: 1.2; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.brand-sub { color: rgba(255,255,255,.38); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; }
.brand-fsuss { margin: -4px; padding: 11px 13px; border-radius: var(--radius-sm); background: #fff; }
.brand-fsuss img { width: 100%; display: block; }
.sidebar nav { flex: 1; padding: 18px 13px; }
.nav-label { padding: 0 10px; margin: 18px 0 7px; color: rgba(255,255,255,.3); font-size: 9.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.nav-label:first-child { margin-top: 0; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 9px 12px; border: 0; border-radius: var(--radius-sm); color: rgba(255,255,255,.62); background: none; font-family: inherit; font-size: 13px; font-weight: 600; text-align: left; text-decoration: none; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.11); }
.nav-icon { width: 20px; text-align: center; font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.sidebar-bottom { padding: 16px; border-top: 1px solid rgba(255,255,255,.07); }
.user-info { display: flex; flex-direction: column; gap: 9px; }
.user-email { overflow: hidden; color: rgba(255,255,255,.45); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.btn-signout { width: 100%; padding: 8px; border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-sm); color: rgba(255,255,255,.66); background: rgba(255,255,255,.06); font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }

main { width: 100%; max-width: 1500px; padding: 40px 44px 64px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.eyebrow, .settings-section-title { margin: 0 0 8px; color: var(--blue); font-size: var(--text-2xs); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.page-title { margin: 0; color: var(--navy); font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1; letter-spacing: -.05em; }
.page-subtitle { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.admin-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(255,255,255,.9); box-shadow: 0 7px 22px rgba(26,39,68,.035); }
.admin-toolbar label { color: var(--navy); font-size: 12px; font-weight: 700; }
.admin-toolbar span { margin-left: auto; color: var(--muted); font-size: 12px; }

.settings-card { padding: 22px 24px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-grid .settings-card { min-width: 0; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.card-heading p, .card-copy { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 15px; margin-bottom: 18px; }
.stat-card { padding: 18px 20px; border: 1px solid var(--border); border-top: 3px solid var(--blue); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.stat-label { margin-bottom: 7px; color: var(--muted); font-size: var(--text-2xs); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.stat-value { color: var(--navy); font-size: 1.4rem; font-weight: 700; }
.stat-sub { margin-top: 5px; color: var(--muted); font-size: 11px; }

.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.form-field label { color: var(--navy); font-size: 11px; font-weight: 700; }
input, select { width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--ink); background: #fff; font-family: inherit; font-size: 12px; font-weight: 500; }
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,82,152,.1); }
.admin-toolbar select { width: auto; min-width: 170px; }
.btn-primary, .btn-secondary { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font-family: inherit; font-size: 12px; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn-primary { color: #fff; background: var(--navy); }
.btn-secondary { color: var(--navy); border-color: var(--border); background: #fff; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .5; cursor: default; }
.member-row, .company-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 12px; min-height: 52px; padding: 9px 0; border-top: 1px solid var(--border); }
.member-row:first-child, .company-row:first-child { border-top: 0; }
.member-name { overflow: hidden; color: var(--navy); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.member-email { color: var(--muted); font-size: 11px; font-weight: 400; }
.badge { display: inline-flex; align-items: center; width: fit-content; padding: 4px 9px; border-radius: 999px; color: var(--muted); background: var(--surface-blue); font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.rights { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 14px; padding: 2px 0 10px; color: var(--muted); font-size: 11px; }
.rights strong { color: var(--navy); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.rights label { display: flex; align-items: center; gap: 5px; }
.rights input { width: auto; min-height: auto; }
.section-label { margin: 18px 0 8px; color: var(--navy); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.empty { padding: 8px 0; color: var(--muted); font-size: 12px; }
.error-inline { padding: 12px 14px; border: 1px solid rgba(180,58,50,.25); border-radius: var(--radius-sm); color: var(--red); background: var(--red-soft); font-size: 12px; }
.notice { padding: 12px 14px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--navy); background: var(--surface); font-size: 12px; }
.notice.error { color: var(--red); border-color: rgba(180,58,50,.25); background: var(--red-soft); }
.company-group { margin-bottom: 18px; }
.company-group:last-child { margin-bottom: 0; }
.company-title { margin-bottom: 5px; color: var(--navy); font-size: 12px; font-weight: 700; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; min-height: 0; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-label { width: 100%; }
  .nav-item { width: auto; }
  main { padding: 28px 20px 48px; }
  .settings-grid { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 620px) {
  .page-header { align-items: flex-start; flex-direction: column; }
  .admin-toolbar { align-items: flex-start; flex-direction: column; }
  .admin-toolbar span { margin-left: 0; }
  .admin-toolbar select { width: 100%; }
  .member-row, .company-row { grid-template-columns: 1fr; align-items: start; }
}
