/*
 * Dashboard tokens — kept here so module panels keep their form even if
 * /theme.css fails to load (e.g. restrictive file mode → 403 on the host).
 */
:root {
    --es-bg: #f4f6f9;
    --es-surface: #ffffff;
    --es-surface-muted: #eef1f6;
    --es-border: #d8dee6;
    --es-border-strong: #c5cdd8;
    --es-text: #1a2332;
    --es-text-secondary: #394956;
    --es-text-muted: #4f5d6b;
    --es-accent: #1e4d7b;
    --es-accent-hover: #163a5e;
    --es-accent-soft: #e8f0f8;
    --es-success: #2d6a4f;
    --es-radius: 10px;
    --es-radius-sm: 8px;
    --es-shadow: 0 1px 3px rgba(26, 35, 50, 0.06), 0 8px 24px rgba(26, 35, 50, 0.06);
    --es-font-heading: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

body.es-app header.dashboard-page-header {
    text-align: center;
}

body.es-app header.dashboard-page-header h1 {
    color: #000;
}

body.es-app .dashboard-header-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
    overflow: visible;
}

body.es-app .dashboard-header-top .es-logo {
    grid-column: 2;
    justify-self: center;
    align-self: center;
    margin: 0;
    width: 220px;
    max-width: min(100%, 220px);
    height: auto !important;
    max-height: none;
    aspect-ratio: auto;
    object-fit: contain;
    object-position: center;
}

body.es-app .dashboard-header-top .dashboard-header-actions {
    grid-column: 3;
    justify-self: end;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

body.es-app .dashboard-header-top .btn-recent-cases {
    grid-column: 3;
    justify-self: end;
}

body.es-app .dashboard-header-top .dashboard-header-actions .btn-recent-cases {
    grid-column: auto;
    justify-self: auto;
}

@media (max-width: 640px) {
    body.es-app .dashboard-header-top {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    body.es-app .dashboard-header-top .es-logo,
    body.es-app .dashboard-header-top .btn-recent-cases,
    body.es-app .dashboard-header-top .dashboard-header-actions {
        grid-column: auto;
        justify-self: auto;
    }

    body.es-app .dashboard-header-top .dashboard-header-actions {
        justify-content: center;
        width: 100%;
    }
}

body.es-app header.dashboard-page-header h1 {
    margin-top: 4px;
}

.dashboard-intro {
    margin: 0 auto 28px;
    color: var(--es-text-secondary);
    max-width: 720px;
    text-align: center;
}

.dashboard-intro p {
    margin: 0 0 12px;
}

.dashboard-legal-notice {
    margin-top: 8px;
    font-size: 0.9375rem;
    color: var(--es-text-secondary);
    line-height: 1.55;
}

.overall-progress-card {
    background: var(--es-surface, #ffffff);
    border: 1px solid var(--es-border, #d8dee6);
    border-radius: var(--es-radius, 10px);
    padding: 20px 24px;
    margin-bottom: 32px;
    box-shadow: var(--es-shadow);
}

.overall-progress-card h3 {
    margin: 0 0 8px;
    font-family: var(--es-font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--es-text);
}

.overall-progress-text {
    margin: 0 0 14px;
    color: var(--es-text-secondary);
    font-size: 1rem;
}

.progress-bar-track {
    height: 10px;
    background: var(--es-surface-muted);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--es-border);
}

.progress-bar-fill {
    height: 100%;
    background: var(--es-success);
    border-radius: 999px;
    transition: width 0.4s ease;
}

.overall-progress-percent {
    margin: 10px 0 0;
    font-size: 0.9375rem;
    color: var(--es-text-secondary);
    text-align: right;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.module-card {
    background: var(--es-surface, #ffffff);
    border: 1px solid var(--es-border, #d8dee6);
    border-radius: var(--es-radius, 10px);
    padding: 20px 18px;
    box-shadow: var(--es-shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    text-align: left;
}

.module-card:hover {
    border-color: var(--es-border-strong);
    box-shadow: 0 2px 6px rgba(26, 35, 50, 0.08), 0 12px 28px rgba(26, 35, 50, 0.08);
}

.module-card h3 {
    margin: 0 0 6px;
    font-family: var(--es-font-heading);
    font-size: 1.1rem;
    line-height: 1.35;
    color: var(--es-text);
}

.module-sections {
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--es-border);
    font-size: 0.9375rem;
    color: var(--es-text-secondary);
    line-height: 1.5;
}

.module-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.btn-module,
.btn-training,
.btn-review {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 10px 14px;
    border-radius: var(--es-radius-sm);
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

a.btn-module,
a.btn-training,
a.btn-review {
    text-decoration: none;
}

a.btn-module *,
a.btn-training *,
a.btn-review * {
    pointer-events: none;
}

a.btn-training em,
a.btn-module em {
    color: inherit;
    font-style: italic;
}

.btn-module {
    background: var(--es-accent);
    color: #fff;
    border: 1px solid var(--es-accent);
}

.btn-module:hover {
    background: var(--es-accent-hover);
    border-color: var(--es-accent-hover);
}

.btn-module.btn-module-disabled {
    background: var(--es-text-muted);
    border-color: var(--es-text-muted);
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.7;
}

.btn-training,
.btn-review {
    background: var(--es-surface);
    color: var(--es-accent);
    border: 1px solid var(--es-border);
}

.btn-training:hover,
.btn-review:hover {
    background: var(--es-accent-soft);
    border-color: var(--es-border-strong);
}

.recent-cases-card {
    background: var(--es-surface);
    border: 1px solid var(--es-border);
    border-radius: var(--es-radius);
    padding: 20px 24px;
    margin-bottom: 32px;
    box-shadow: var(--es-shadow);
}

.recent-cases-card--error {
    color: var(--es-text-secondary);
}

.recent-cases-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.recent-cases-header h3 {
    margin: 0 0 6px;
    font-family: var(--es-font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--es-text);
}

.recent-cases-subtitle,
.recent-cases-updated,
.recent-cases-loading,
.recent-cases-empty {
    margin: 0;
    color: var(--es-text-secondary);
    font-size: 0.9375rem;
    line-height: 1.55;
}

.recent-cases-updated {
    flex-shrink: 0;
    text-align: right;
    font-size: 0.875rem;
}

.recent-cases-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.recent-case-item {
    padding: 12px 0;
    border-top: 1px solid var(--es-border);
}

.recent-case-item:first-child {
    border-top: none;
    padding-top: 0;
}

.recent-case-title {
    color: var(--es-accent);
    font-weight: 600;
    font-style: normal;
    text-decoration: none;
}

.recent-case-title em,
.recent-case-catchwords em,
.recent-case-legislation em,
.recent-cases-module-group h4 em {
    font-style: italic;
}

.case-citation,
.recent-case-title .case-citation,
.recent-case-catchwords .case-citation,
.recent-case-legislation .case-citation {
    font-style: normal;
}

.recent-case-title:hover {
    text-decoration: underline;
}

.recent-case-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 4px;
    font-size: 0.875rem;
    color: var(--es-text-secondary);
}

.recent-case-court {
    font-weight: 600;
}

.recent-case-details {
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--es-text-secondary);
    line-height: 1.5;
}

.recent-case-details p {
    margin: 0 0 6px;
}

.recent-case-modules a {
    color: var(--es-accent);
    text-decoration: none;
    font-weight: 600;
}

.recent-case-modules a:hover {
    text-decoration: underline;
}

.recent-cases-actions {
    margin-top: 16px;
}

.btn-recent-cases,
a.btn-recent-cases {
    display: inline-block;
    padding: 10px 16px;
    border-radius: var(--es-radius-sm);
    background: var(--es-accent);
    color: #fff;
    border: 1px solid var(--es-accent);
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-recent-cases:hover,
a.btn-recent-cases:hover {
    background: var(--es-accent-hover);
    border-color: var(--es-accent-hover);
    color: #fff;
}

.btn-recent-cases-secondary,
a.btn-recent-cases-secondary {
    background: var(--es-surface);
    color: var(--es-accent);
    border-color: var(--es-border);
}

.btn-recent-cases-secondary:hover,
a.btn-recent-cases-secondary:hover {
    background: var(--es-accent-soft);
    border-color: var(--es-border-strong);
    color: var(--es-accent);
}

.recent-cases-nav {
    margin-bottom: 20px;
}

.recent-cases-page-content {
    margin-bottom: 32px;
}

.recent-cases-page-intro {
    margin-bottom: 28px;
    color: var(--es-text-secondary);
    line-height: 1.6;
}

.recent-cases-page-section {
    margin-bottom: 32px;
}

.recent-cases-page-section h3,
.recent-cases-module-group h4 {
    margin: 0 0 12px;
    font-family: var(--es-font-heading);
    color: var(--es-text);
}

.recent-cases-module-group {
    margin-bottom: 24px;
    padding: 16px 18px;
    background: var(--es-surface);
    border: 1px solid var(--es-border);
    border-radius: var(--es-radius);
}

.recent-cases-module-group h4 a {
    color: var(--es-accent);
    text-decoration: none;
}

.recent-cases-module-group h4 a:hover {
    text-decoration: underline;
}

.recent-cases-list--detailed .recent-case-item {
    padding: 14px 0;
}

@media (max-width: 720px) {
    .recent-cases-header {
        flex-direction: column;
    }

    .recent-cases-updated {
        text-align: left;
    }
}

.dashboard-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--es-border);
    font-size: 0.9375rem;
    color: var(--es-text-secondary);
    line-height: 1.6;
    text-align: center;
}

.dashboard-footer p {
    margin: 0 0 10px;
}

.dashboard-footer a {
    color: var(--es-accent);
    font-weight: 600;
    text-decoration: none;
}

.dashboard-footer a:hover {
    text-decoration: underline;
}

.dashboard-content-version {
    margin-top: 12px;
    font-size: 0.875rem;
    color: var(--es-text-secondary);
}

.user-profile-card {
    background: var(--es-surface);
    border: 1px solid var(--es-border);
    border-radius: var(--es-radius);
    padding: 0;
    margin: 40px 0 8px;
    overflow: hidden;
    box-shadow: var(--es-shadow);
}

.user-profile-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--es-border);
}

.user-profile-header-text h3 {
    margin: 0 0 4px;
    font-family: var(--es-font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--es-text);
}

.user-profile-subtitle {
    margin: 0;
    color: var(--es-text-secondary);
    font-size: 0.9375rem;
}

.user-profile-status {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.user-profile-status.active {
    background: var(--es-success-soft);
    color: var(--es-success);
    border: 1px solid rgba(45, 106, 79, 0.25);
}

.user-profile-status.inactive {
    background: #fdecec;
    color: var(--es-danger);
    border: 1px solid rgba(180, 35, 24, 0.2);
}

.user-profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--es-border);
    border-bottom: 1px solid var(--es-border);
}

.user-profile-stat {
    background: var(--es-surface-muted);
    padding: 16px 18px;
    text-align: center;
}

.user-profile-stat-value {
    display: block;
    color: var(--es-accent);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}

.user-profile-stat-label {
    display: block;
    margin-top: 4px;
    color: var(--es-text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-profile-body {
    padding: 20px 24px 24px;
}

.user-profile-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.user-profile-panel,
.user-profile-modules {
    background: var(--es-surface-muted);
    border: 1px solid var(--es-border);
    border-radius: var(--es-radius-sm);
    padding: 16px 18px;
}

.user-profile-panel-title {
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--es-border);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--es-text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.user-profile-field {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--es-border);
    font-size: 0.9375rem;
}

.user-profile-field:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.user-profile-field dt {
    margin: 0;
    color: var(--es-text-secondary);
    font-weight: 600;
    font-size: 0.9375rem;
}

.user-profile-field dd {
    margin: 0;
    color: var(--es-text);
    word-break: break-word;
}

.user-profile-empty {
    color: var(--es-text-muted);
    font-style: italic;
}

.user-profile-module-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--es-border);
}

.user-profile-module-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.user-profile-module-name {
    color: var(--es-text);
    font-size: 0.9375rem;
}

.user-profile-module-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.user-profile-module-chip.complete {
    background: var(--es-success-soft);
    color: var(--es-success);
}

.user-profile-module-chip.in-progress {
    background: var(--es-info-soft);
    color: var(--es-accent);
}

.user-profile-module-chip.pending {
    background: var(--es-surface-muted);
    color: var(--es-text-muted);
    border: 1px solid var(--es-border);
}

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

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

    .user-profile-stats {
        grid-template-columns: 1fr;
    }

    .user-profile-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-profile-field {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .user-profile-module-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

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


/* Modules search + progress clarity (training UI 20260803k) */
.modules-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 0 0 18px;
}

.modules-search-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--es-text-secondary, #394956);
}

.modules-search {
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 420px;
    padding: 9px 12px;
    border: 1px solid var(--es-border-strong, #c5cdd8);
    border-radius: 8px;
    background: var(--es-surface, #fff);
    color: var(--es-text, #1a2332);
    font: inherit;
}

.modules-search:focus {
    outline: 2px solid color-mix(in srgb, var(--es-accent, #1e4d7b) 45%, transparent);
    outline-offset: 1px;
    border-color: var(--es-accent, #1e4d7b);
}

.modules-search-empty {
    margin: 0 0 18px;
    color: var(--es-text-muted, #4f5d6b);
    font-size: 0.95rem;
}

.module-card.modules-search-hidden,
.landing-panel.modules-search-hidden {
    display: none !important;
}

.module-progress .progress-last-visited,
.module-progress .progress-detail {
    display: block;
    margin-top: 4px;
    font-size: 0.875rem;
    color: var(--es-text-muted, #4f5d6b);
}

.overall-progress-last {
    margin: 8px 0 0;
    font-size: 0.9375rem;
    color: var(--es-text-secondary, #394956);
}

.dashboard-support {
    margin: 10px 0 0;
    font-size: 0.85rem;
}

.dashboard-support a {
    color: var(--es-text-muted, #4f5d6b);
    text-decoration: none;
}

.dashboard-support a:hover {
    color: var(--es-accent, #1e4d7b);
    text-decoration: underline;
}

.modules-toolbar--landing {
    justify-content: center;
    margin-top: 10px;
}

.modules-toolbar--landing .modules-search {
    max-width: 360px;
}
