:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --primary: #155eef;
    --primary-dark: #0f49bd;
    --ink: #172033;
    --muted: #5c667a;
    --line: #dfe4ec;
    --surface: #ffffff;
    --background: #f3f6fb;
    --danger: #b42318;
    --warning: #8a4b08;
    --success: #067647;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(21, 94, 239, .12), transparent 34rem),
        var(--background);
}

body.portal-body {
    display: grid;
    place-items: center;
    padding: 20px;
}

a { color: var(--primary); }

.card {
    width: min(100%, 580px);
    background: var(--surface);
    border: 1px solid rgba(23, 32, 51, .08);
    border-radius: 24px;
    box-shadow: 0 24px 70px rgba(24, 39, 75, .13);
    overflow: hidden;
}

.card-head {
    padding: 30px 30px 22px;
    border-bottom: 1px solid var(--line);
}

.card-body { padding: 28px 30px 30px; }

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 15px;
    color: white;
    font-weight: 800;
    letter-spacing: -.04em;
    background: var(--primary);
}

h1, h2, h3 { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(1.55rem, 5vw, 2.1rem); }
h2 { margin-bottom: 12px; font-size: 1.1rem; }
p { line-height: 1.58; }
.muted { color: var(--muted); }
.compact { margin: 0; }

.notice,
.error-notice,
.warning-notice,
.success-notice {
    padding: 13px 15px;
    margin: 0 0 18px;
    border-radius: 12px;
    font-size: .94rem;
}

.notice { background: #eef4ff; color: #294b8d; }
.error-notice { background: #fff1f0; color: var(--danger); }
.warning-notice { background: #fff7e8; color: var(--warning); }
.success-notice { background: #ecfdf3; color: var(--success); }

.terms-box {
    max-height: 270px;
    overflow: auto;
    padding: 18px;
    margin: 18px 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfcfe;
}

.terms-text {
    margin: 0;
    white-space: pre-line;
    color: #354057;
    font-size: .93rem;
}

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

.privacy-item {
    padding: 13px;
    border-radius: 12px;
    background: #f6f8fb;
    font-size: .88rem;
    line-height: 1.45;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 50px;
    padding: 12px 18px;
    border: 0;
    border-radius: 13px;
    color: #fff;
    background: var(--primary);
    font: inherit;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
}

.button:hover { background: var(--primary-dark); }
.button.secondary { background: #334155; }
.button.inline { width: auto; min-height: 42px; }
.button.small { width: auto; min-height: 38px; padding: 8px 12px; font-size: .82rem; }

.fine-print {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: .78rem;
    text-align: center;
}

.spinner {
    width: 52px;
    height: 52px;
    margin: 4px auto 22px;
    border: 5px solid #dbe5f7;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.panel-body { background: #eef2f8; }

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

.panel-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 22px;
    background: #111827;
    color: #fff;
    border-radius: 18px;
}

.panel-topbar h1 { margin: 0; font-size: 1.25rem; }
.panel-topbar p { margin: 3px 0 0; color: #b8c1d1; font-size: .85rem; }

.panel-actions,
.button-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-actions form { margin: 0; }
.panel-notice { margin-top: 18px; }
.panel-section { margin-top: 20px; }
.narrow-panel { width: min(900px, calc(100% - 32px)); }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 22px 0;
}

.metric {
    padding: 22px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, .06);
}

.metric strong { display: block; font-size: 2rem; }
.metric span { color: var(--muted); font-size: .86rem; }

.panel-card {
    padding: 22px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, .06);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
td { vertical-align: top; }

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

.tenant-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfcfe;
}

.tenant-card h3 { margin-bottom: 3px; }

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-badge.active,
.status-badge.reviewed { background: #dcfae6; color: #067647; }
.status-badge.pending { background: #fff1cc; color: #8a4b08; }
.status-badge.draft { background: #eaf0ff; color: #294b8d; }
.status-badge.archived { background: #eef0f3; color: #475467; }

.action-stack { display: grid; gap: 10px; min-width: 250px; }

.inline-admin-form {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fafbfc;
}

.inline-admin-form label { font-size: .78rem; font-weight: 700; }
.inline-admin-form input[type="text"],
.inline-admin-form input:not([type]) {
    width: 100%;
    min-height: 38px;
    margin-top: 5px;
    padding: 8px 10px;
    border: 1px solid #cbd3df;
    border-radius: 8px;
    font: inherit;
}

.check-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}

.check-line input { margin-top: 3px; }

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(100%, 430px);
    padding: 30px;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .13);
}

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 7px; font-size: .88rem; font-weight: 700; }
.field input {
    width: 100%;
    min-height: 47px;
    padding: 10px 12px;
    border: 1px solid #cbd3df;
    border-radius: 10px;
    font: inherit;
}
.field textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd3df;
    border-radius: 10px;
    resize: vertical;
    font: inherit;
    line-height: 1.5;
}
.field small { display: block; margin-top: 6px; color: var(--muted); }
.field input:focus,
.field textarea:focus { outline: 3px solid rgba(21, 94, 239, .15); border-color: var(--primary); }

.form-grid { display: grid; gap: 16px; }
.form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.button-row .button { flex: 1; }

.terms-preview h2 { margin-top: 10px; font-size: 1.45rem; }
.terms-preview h3 { margin: 24px 0 8px; }
.detail-metadata {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.detail-metadata > div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fbfcfe;
    line-height: 1.5;
}
.preview-text {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfcfe;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.58;
}

@media (max-width: 760px) {
    .privacy-summary,
    .metric-grid,
    .tenant-grid,
    .detail-metadata,
    .form-grid.two-columns { grid-template-columns: 1fr; }
    .card-head, .card-body { padding-left: 21px; padding-right: 21px; }
    .panel-topbar { align-items: flex-start; flex-direction: column; }
    .panel-actions,
    .button-row { width: 100%; align-items: stretch; flex-direction: column; }
    .panel-actions .button,
    .panel-actions form,
    .panel-actions form .button { width: 100%; }
}
