:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-strong: #f9fafb;
    --ink: #121820;
    --muted: #5d6876;
    --line: #d8dee7;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --blue: #1d4ed8;
    --green: #15803d;
    --shadow: 0 18px 48px rgba(18, 24, 32, 0.12);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: linear-gradient(180deg, rgba(180, 35, 24, 0.06), transparent 260px), var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
}

.portal-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 76px;
    padding: 14px max(20px, env(safe-area-inset-left)) 14px max(20px, env(safe-area-inset-right));
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    text-decoration: none;
}

.brand img {
    flex: 0 0 auto;
    border-radius: var(--radius);
    box-shadow: 0 8px 22px rgba(180, 35, 24, 0.18);
}

.brand span {
    display: grid;
    gap: 2px;
}

.brand strong {
    font-size: 18px;
    line-height: 1.2;
}

.brand small,
.hero-panel p,
.dashboard-head p,
.panel p,
.row small,
.muted {
    color: var(--muted);
}

.top-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.top-actions a,
.top-actions button,
.primary-action,
.danger-action,
.password-form button,
.inline-form button,
.invite-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-size: 14px;
    font-weight: 900;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
}

.primary-action {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

.danger-action {
    min-height: 36px;
    border-color: rgba(180, 35, 24, 0.28);
    background: var(--danger-soft);
    color: var(--danger);
}

.portal-layout {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 48px;
}

.notice,
.panel,
.hero-panel,
.dashboard-head,
.group-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.notice {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-color: rgba(21, 128, 61, 0.28);
    color: var(--green);
    background: #f0fdf4;
    overflow-wrap: anywhere;
}

.notice.error {
    border-color: rgba(180, 35, 24, 0.28);
    color: var(--danger);
    background: var(--danger-soft);
}

.welcome-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.7fr);
    gap: 16px;
    align-items: start;
}

.hero-panel,
.panel,
.dashboard-head,
.group-card {
    padding: 22px;
}

.hero-panel {
    min-height: 320px;
    display: grid;
    align-content: center;
}

.panel.narrow {
    max-width: 640px;
    margin: 48px auto;
}

.auth-panel {
    width: min(460px, 100%);
    margin: 56px auto;
}

.auth-panel h1 {
    margin-bottom: 18px;
    font-size: 30px;
}

.auth-footer {
    margin: 14px 0 0;
    text-align: center;
}

.auth-footer a {
    color: var(--blue);
    font-weight: 900;
}

.code-input {
    min-height: 64px;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 0.26em;
    padding-left: 0.26em;
}

.verify-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.verify-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-size: 14px;
    font-weight: 900;
}

.priority-panel {
    margin-bottom: 16px;
    border-color: rgba(29, 78, 216, 0.22);
}

.eyebrow {
    display: inline-flex;
    width: fit-content;
    margin-bottom: 10px;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    font-weight: 900;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(30px, 5vw, 48px);
    line-height: 1.05;
}

h2 {
    font-size: 22px;
    line-height: 1.2;
}

h3 {
    margin: 18px 0 10px;
    font-size: 16px;
}

.stack {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 900;
}

input,
select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    color: var(--ink);
}

.dashboard-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.password-form,
.inline-form,
.invite-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 10px;
    align-items: end;
}

.password-form {
    width: min(560px, 100%);
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
}

.selected-group {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    color: var(--muted);
    font-weight: 900;
}

.panel + .group-card,
.group-card + .group-card,
.panel + .panel {
    margin-top: 16px;
}

.group-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.code {
    max-width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(18px, 4vw, 28px);
    overflow-wrap: anywhere;
}

.link-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.link-grid a {
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    font-weight: 900;
    text-align: center;
    text-decoration: none;
}

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

.table-list {
    display: grid;
    gap: 8px;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
}

.row span {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.row strong,
.row small {
    overflow-wrap: anywhere;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 900px) {
    .portal-topbar,
    .dashboard-head,
    .group-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .welcome-grid,
    .columns,
    .link-grid,
    .verify-actions,
    .password-form,
    .inline-form,
    .invite-form {
        grid-template-columns: 1fr;
    }
}
