:root {
    color-scheme: light;
    --surface: #f5f5f7;
    --card: #ffffff;
    --ink: #1d1d1f;
    --muted: #6e6e73;
    --line: #d2d2d7;
    --accent: #007aff;
    --accent-dark: #0062cc;
    --success: #1b8a4b;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--surface); }
button, input { font: inherit; }

.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 10%, rgba(0, 122, 255, .14), transparent 34rem),
        var(--surface);
}

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.auth-card {
    width: min(100%, 460px);
    padding: clamp(28px, 6vw, 52px);
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(210, 210, 215, .8);
    border-radius: 28px;
    box-shadow: 0 24px 70px rgba(29, 29, 31, .10);
    backdrop-filter: blur(18px);
}

.brand-mark, .portal-brand span, .module-card__icon {
    display: grid;
    place-items: center;
    background: var(--ink);
    color: white;
    font-weight: 700;
}
.brand-mark { width: 52px; height: 52px; border-radius: 16px; margin-bottom: 30px; font-size: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(30px, 6vw, 42px); line-height: 1.05; letter-spacing: -.035em; }
.auth-intro { margin: 18px 0 30px; color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 10px; }
.auth-form label { margin-top: 8px; font-size: 14px; font-weight: 650; }
.auth-form input {
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    outline: none;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 122, 255, .13); }
.auth-form button {
    min-height: 52px;
    margin-top: 16px;
    border: 0;
    border-radius: 14px;
    background: var(--accent);
    color: white;
    font-weight: 700;
    cursor: pointer;
}
.auth-form button:hover { background: var(--accent-dark); }
.otp-input { text-align: center; font-size: 27px !important; font-weight: 700; letter-spacing: .35em; }
.field-error { margin: 0; color: #c9262e; font-size: 13px; }
.password-help { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.field-success { margin: 0 0 18px; padding: 12px 14px; color: #176d3d; background: #eaf8ef; border-radius: 12px; font-size: 13px; line-height: 1.45; }
.auth-secondary-form { margin-top: 12px; }
.secondary-button {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--accent);
    background: var(--card);
    font-weight: 700;
    cursor: pointer;
}
.secondary-button:hover { border-color: var(--accent); background: #f7fbff; }
.security-note { margin: 24px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.secondary-link { display: block; margin-top: 24px; color: var(--accent); text-align: center; text-decoration: none; }

.portal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px clamp(20px, 5vw, 72px);
    background: rgba(245, 245, 247, .86);
    border-bottom: 1px solid rgba(210, 210, 215, .8);
    backdrop-filter: blur(18px);
}
.portal-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 750; text-decoration: none; }
.portal-brand span { width: 34px; height: 34px; border-radius: 10px; }
.user-menu { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 14px; }
.user-menu a { color: var(--accent); text-decoration: none; }
.link-button { padding: 0; border: 0; color: var(--accent); background: transparent; cursor: pointer; }
.portal-main { width: min(100%, 1280px); margin: 0 auto; padding: clamp(28px, 5vw, 68px) clamp(20px, 5vw, 56px); }
.dashboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 34px; }
.dashboard-heading p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); }
.status-pill { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #eaf8ef; color: #176d3d; border-radius: 999px; font-size: 13px; font-weight: 650; white-space: nowrap; }
.status-pill span { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.module-card, .empty-state { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 12px 34px rgba(29, 29, 31, .05); }
.module-card { display: flex; align-items: center; gap: 16px; min-height: 132px; padding: 24px; transition: transform .2s ease, box-shadow .2s ease; }
.module-card:hover { transform: translateY(-3px); box-shadow: 0 18px 42px rgba(29, 29, 31, .09); }
.module-card__icon { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px; }
.module-card__access { margin: 0 0 5px; color: var(--accent); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.module-card h2, .empty-state h2 { margin: 0; font-size: 19px; }
.empty-state { padding: 36px; }
.empty-state p { max-width: 620px; margin: 10px 0 0; color: var(--muted); line-height: 1.55; }

.primary-action { min-height: 46px; padding: 0 18px; border: 0; border-radius: 13px; color: white; background: var(--accent); font-weight: 700; cursor: pointer; }
.primary-action:hover { background: var(--accent-dark); }
.configuration-note, .form-errors { margin: 0 0 22px; padding: 14px 16px; border-radius: 14px; line-height: 1.5; }
.configuration-note { color: #704c00; background: #fff6d8; border: 1px solid #f0d98d; }
.form-errors { color: #992129; background: #fff0f1; border: 1px solid #efc2c5; }
.form-errors p { margin: 0; }
.form-errors p + p { margin-top: 5px; }
.people-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.person-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%; padding: 18px; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--card); text-align: left; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.person-card:hover { transform: translateY(-2px); box-shadow: 0 15px 34px rgba(29, 29, 31, .08); }
.person-avatar { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: white; background: var(--ink); font-weight: 750; }
.person-summary { min-width: 0; }
.person-summary strong, .person-summary small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-summary small { margin-top: 4px; color: var(--muted); }
.access-state { padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.access-state--active { color: #176d3d; background: #eaf8ef; }
.access-state--invited { color: #704c00; background: #fff6d8; }
.access-state--suspended, .access-state--archived { color: #8b252b; background: #fff0f1; }
.portal-dialog { width: min(calc(100% - 28px), 680px); max-height: calc(100vh - 28px); padding: 26px; border: 1px solid var(--line); border-radius: 24px; color: var(--ink); background: var(--card); box-shadow: 0 30px 90px rgba(29, 29, 31, .28); }
.portal-dialog::backdrop { background: rgba(29, 29, 31, .44); backdrop-filter: blur(5px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.dialog-heading h2 { margin: 0; font-size: 26px; letter-spacing: -.025em; }
.dialog-close { width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: var(--surface); font-size: 24px; cursor: pointer; }
.settings-form { display: grid; gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label, .settings-form > label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 650; }
.form-grid__wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .settings-form > label select { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--card); }
.dialog-secondary-action { margin-top: 12px; }
.secondary-button:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 900px) {
    .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .people-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .auth-shell { align-items: start; padding: 18px 12px; }
    .auth-card { border-radius: 22px; }
    .portal-header { align-items: flex-start; }
    .user-menu { align-items: flex-end; flex-direction: column; gap: 5px; }
    .dashboard-heading { align-items: flex-start; flex-direction: column; }
    .module-grid { grid-template-columns: 1fr; }
    .admin-heading .primary-action { width: 100%; }
    .person-card { grid-template-columns: auto minmax(0, 1fr); }
    .access-state { grid-column: 2; justify-self: start; }
    .portal-dialog { padding: 20px; border-radius: 20px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid__wide { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
