:root {
    --bg: #f5eff5;
    --panel: rgba(255, 255, 255, 0.86);
    --panel-strong: #ffffff;
    --border: rgba(29, 38, 61, 0.12);
    --text: #1b2340;
    --muted: #67708d;
    --accent: #304a8c;
    --accent-soft: #e5ebff;
    --rose: #f4dfe9;
    --shadow: 0 18px 40px rgba(35, 44, 76, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Inter", system-ui, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255,255,255,0.95), transparent 36%),
        linear-gradient(160deg, #f8f1f6 0%, #f3f5fb 50%, #eef2f9 100%);
    color: var(--text);
}

body.login-page {
    min-height: 100vh;
}

.shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 28px 22px;
    background: linear-gradient(180deg, #1a2540 0%, #1f2d4b 100%);
    color: #f4f7ff;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

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

.brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #f3d8e7 0%, #dce5ff 100%);
    color: #21386f;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.brand h1 {
    margin: 0;
    font-size: 1.4rem;
}

.brand p {
    margin: 4px 0 0;
    color: rgba(244, 247, 255, 0.72);
    font-size: 0.94rem;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav a {
    color: #eff3ff;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    transition: 0.18s ease;
}

.nav a:hover,
.nav a.active {
    background: rgba(232, 239, 255, 0.14);
    border-color: rgba(232, 239, 255, 0.18);
}

.sidebar-card {
    margin-top: auto;
    padding: 18px;
    border-radius: 18px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
}

.sidebar-card h3 {
    margin: 0 0 12px;
}

.sidebar-card p {
    margin: 8px 0;
    color: rgba(244, 247, 255, 0.78);
}

.sidebar-card strong {
    display: block;
    margin-bottom: 6px;
}

.content {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.hero {
    padding: 28px 32px;
    border-radius: 28px;
    background: linear-gradient(145deg, rgba(255,255,255,0.92), rgba(245,247,255,0.85));
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.hero.compact {
    padding: 24px 28px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.82rem;
}

.hero h2 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.15;
}

.lede {
    margin: 14px 0 0;
    max-width: 780px;
    color: var(--muted);
    font-size: 1.02rem;
    line-height: 1.6;
}

.hero-badge {
    padding: 12px 16px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    white-space: nowrap;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stats-grid,
.module-grid,
.two-columns,
.family-grid,
.permission-grid {
    display: grid;
    gap: 18px;
}

.stats-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.module-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.family-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.permission-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card,
.panel,
.subpanel,
.permission-item,
.reference-item {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 18px 20px;
    border-radius: 22px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: 1.9rem;
}

.panel,
.subpanel {
    padding: 22px;
    border-radius: 24px;
}

.panel h3,
.subpanel h4 {
    margin: 0 0 10px;
}

.panel p,
.subpanel p,
.permission-item p,
.reference-item p {
    color: var(--muted);
    line-height: 1.55;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    padding: 10px 16px;
    border-radius: 14px;
    text-decoration: none;
    background: var(--accent);
    color: white;
    font-weight: 700;
}

.button.ghost {
    background: transparent;
    color: var(--accent);
    border: 1px solid rgba(48, 74, 140, 0.18);
}

.button.danger {
    background: #b44a4a;
    color: #fff;
}

.button.compact {
    margin-top: 0;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.92rem;
}

.button.logout {
    width: 100%;
    margin-top: 16px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.12);
    color: #f4f7ff;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-header a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.list,
.reference-list,
.timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-row,
.reference-item,
.timeline-item,
.table-row,
.table-head {
    display: grid;
    gap: 12px;
    align-items: center;
}

.list-row {
    grid-template-columns: 1fr auto;
    padding: 14px 0;
    border-top: 1px solid rgba(29, 38, 61, 0.08);
}

.list-row:first-child {
    border-top: 0;
}

.list-row span {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

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

.chip {
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.85rem;
}

.chip.subtle {
    background: rgba(35, 44, 76, 0.08);
    color: #46506f;
}

.empty-state {
    padding: 22px;
    border-radius: 20px;
    background: rgba(255,255,255,0.72);
    color: var(--muted);
    border: 1px dashed rgba(29, 38, 61, 0.16);
}

.reference-item,
.permission-item,
.timeline-item {
    padding: 16px 18px;
    border-radius: 18px;
}

.reference-item span,
.permission-item span {
    display: inline-block;
    margin-top: 6px;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.85rem;
}

.table-like {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.table-head,
.table-row {
    grid-template-columns: 2fr 1fr 1fr 2fr 1fr;
    padding: 14px 16px;
    border-radius: 16px;
}

.table-head {
    background: rgba(48, 74, 140, 0.08);
    font-weight: 700;
    color: var(--accent);
}

.table-row {
    background: rgba(255,255,255,0.72);
    border: 1px solid rgba(29, 38, 61, 0.08);
}

.bullet-list {
    padding-left: 20px;
    color: var(--muted);
    line-height: 1.7;
}

.alert {
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.alert.success {
    background: rgba(221, 247, 232, 0.9);
    border-color: rgba(61, 141, 88, 0.25);
    color: #1f5b32;
}

.alert.error,
.alert.warning {
    background: rgba(255, 243, 220, 0.92);
    border-color: rgba(184, 118, 16, 0.22);
    color: #8a5210;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field span {
    font-weight: 700;
    color: var(--text);
}

.field input,
.field textarea,
.field select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(29, 38, 61, 0.14);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font: inherit;
    resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: 2px solid rgba(48, 74, 140, 0.14);
    border-color: rgba(48, 74, 140, 0.35);
}

.field-error {
    margin: -4px 0 0;
    color: #b44a4a;
    font-size: 0.9rem;
    font-weight: 600;
}

.field-help {
    margin: -2px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.import-layout {
    align-items: start;
}

.activity-layout {
    align-items: start;
}

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

.form-actions-inline {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.preview-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.table-like.compact .table-row.detail {
    grid-template-columns: 1fr 1.3fr;
    background: rgba(255,255,255,0.72);
}

.table-row.detail strong {
    font-size: 0.98rem;
}

.rule-panel {
    margin-top: 18px;
    background: rgba(255,255,255,0.72);
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.login-card {
    width: min(920px, 100%);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.login-brand {
    padding: 10px 0;
}

.login-panel {
    background: rgba(255,255,255,0.92);
}

.login-button {
    margin-top: 18px;
    width: 100%;
}

.card-link {
    text-decoration: none;
    color: inherit;
    border-radius: 18px;
    border: 1px solid rgba(29, 38, 61, 0.08);
    background: rgba(255,255,255,0.72);
    padding: 16px 18px;
}

.card-link:hover {
    border-color: rgba(48, 74, 140, 0.18);
    background: rgba(255,255,255,0.92);
}

.list-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

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

.detail-card {
    padding: 18px;
    border-radius: 18px;
    background: rgba(255,255,255,0.72);
    border: 1px solid rgba(29, 38, 61, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-card span {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.detail-card strong {
    line-height: 1.45;
}

.toggle-field {
    gap: 14px;
}

.toggle-field input[type="checkbox"] {
    width: 22px;
    height: 22px;
    accent-color: var(--accent);
}

.detail-card small {
    color: var(--muted);
}

.detail-card-wide {
    grid-column: 1 / -1;
}

.pronote-table {
    grid-template-columns: 1.4fr 1.2fr 1fr 1fr 0.8fr;
}

.pronote-table-actions {
    grid-template-columns: 1.4fr 1.1fr 1fr 1fr 0.8fr 1.2fr;
}

.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.row-actions form {
    margin: 0;
}

.my-space-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.my-space-layout {
    align-items: start;
}

.my-space-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 1280px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (max-width: 980px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding-bottom: 18px;
    }

    .stats-grid,
    .my-space-stats,
    .module-grid,
    .module-grid.three,
    .two-columns,
    .family-grid,
    .permission-grid,
    .form-row,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        flex-direction: column;
    }

    .list-meta {
        align-items: flex-start;
    }

    .table-head,
    .table-row {
        grid-template-columns: 1fr;
    }

    .pronote-table {
        grid-template-columns: 1fr;
    }

    .pronote-table-actions {
        grid-template-columns: 1fr;
    }
}
