/* UI-DS-01: shared reading hierarchy. Module styles retain their own layouts. */
:root {
    /* Shared screen typography; standalone screens retain their own scale. */
    --ui-font-family: 'Poppins', system-ui, sans-serif;
    --ui-type-body: 14px;
    --ui-type-label: 13px;
    --ui-type-note: 12px;
    --ui-type-title: clamp(26px, 2.4vw, 34px);
    --ui-weight-semibold: 600;
    --ui-line-body: 1.65;
    --ui-text: #0f172a;
    --ui-supporting: #475569;
    --ui-border: #dce6f5;
    --ui-action: #1d4ed8;
    --ui-radius: 12px;
    --ui-space: clamp(18px, 2vw, 28px);
    color: var(--ui-text);
}

:where(.dashboard-page) .page-heading {
    align-items: flex-start;
    gap: 20px;
    margin-bottom: var(--ui-space);
}

:where(.dashboard-page) .page-heading > div {
    min-width: 0;
}

:where(.dashboard-page) .page-heading h1 {
    font-size: var(--ui-type-title);
    font-weight: var(--ui-weight-semibold);
    line-height: 1.3;
    letter-spacing: -.025em;
    overflow-wrap: anywhere;
}

:where(.dashboard-page) .page-heading p {
    max-width: 72ch;
    font-size: var(--ui-type-body);
    line-height: 1.75;
    color: var(--ui-supporting);
}

:where(.dashboard-page) .overline {
    font-size: var(--ui-type-note);
    line-height: 1.6;
    letter-spacing: .09em;
    font-weight: 700;
    color: var(--ui-action);
}

:where(.dashboard-page) .period-label {
    font-size: var(--ui-type-note);
    line-height: 1.6;
    max-width: 100%;
    white-space: normal;
}

:where(.dashboard-page) .panel-heading {
    gap: 16px;
    flex-wrap: wrap;
}

:where(.dashboard-page) .panel-heading > div {
    min-width: 0;
}

:where(.dashboard-page) .panel-heading h2 {
    font-size: 17px;
    line-height: 1.5;
    font-weight: var(--ui-weight-semibold);
    overflow-wrap: anywhere;
}

:where(.dashboard-page) .panel-heading p {
    font-size: var(--ui-type-label);
    line-height: 1.7;
    color: var(--ui-supporting);
}

:where(.dashboard-page) .empty-state h3 {
    font-size: 15px;
    line-height: 1.5;
    color: var(--ui-text);
}

:where(.dashboard-page) .empty-state p {
    max-width: 42ch;
    font-size: var(--ui-type-label);
    line-height: 1.75;
    color: var(--ui-supporting);
}

:where(.dashboard-content) :is(.primary-button, .secondary-button) {
    min-height: 44px;
    font-size: var(--ui-type-label);
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
}

:where(.dashboard-content) .secondary-button {
    border-color: #cbd7eb;
    font-weight: 600;
}

:where(.dashboard-content) .secondary-button:hover {
    background: #eff5ff;
    border-color: #93b4f5;
    color: #1d4ed8;
}

:where(.dashboard-content) .monitoring-filters label {
    font-size: var(--ui-type-label);
    line-height: 1.5;
}

/* Dashboard summary: numbers, labels, then supporting information. */
.dashboard-overview .summary-card {
    border-radius: var(--ui-radius);
    box-shadow: none;
    padding: var(--ui-space);
}

.dashboard-overview .summary-card h2 {
    font-size: var(--ui-type-label);
    line-height: 1.6;
    font-weight: 500;
    color: var(--ui-supporting);
}

.dashboard-overview .dashboard-metric {
    font-size: clamp(20px, 1.8vw, 24px);
    line-height: 1.3;
    font-weight: var(--ui-weight-semibold);
    letter-spacing: -.025em;
    font-variant-numeric: tabular-nums;
    margin-block: 12px;
}

.dashboard-overview .summary-card > p.muted {
    font-size: var(--ui-type-label);
    line-height: 1.7;
    color: var(--ui-supporting);
}

.dashboard-overview .summary-card > .table-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: var(--ui-type-label);
    color: var(--ui-action);
    text-underline-offset: 3px;
}

.dashboard-overview .dashboard-next-actions > h2 {
    font-size: 17px;
    font-weight: var(--ui-weight-semibold);
}

.dashboard-overview .dashboard-next-action {
    padding: var(--ui-space);
    box-shadow: none;
}

.dashboard-overview .dashboard-next-action p {
    max-width: 72ch;
    font-size: var(--ui-type-body);
    line-height: 1.75;
}

@media (max-width: 600px) {
    :where(.dashboard-page) .page-heading {
        flex-direction: column;
        gap: 12px;
    }

    .dashboard-overview .summary-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-overview .dashboard-action-links {
        width: 100%;
    }

    .dashboard-overview .dashboard-action-links > a {
        flex: 1 1 160px;
    }
}

/* UI-DS-02: navigation, list tables and standard forms share readable defaults. */
:root {
    --ui-field-border: #7888a0;
    --ui-error: #b32323;
}

:where(.dashboard-page) .sidebar .nav-group-items .nav-item {
    font-size: 12.5px;
    line-height: 1.35;
}

:where(.dashboard-page) .nav-label {
    font-size: 11px;
    color: #475569;
}

:where(.dashboard-page) .sidebar-note {
    font-size: 11.5px;
    line-height: 1.45;
}

:where(.dashboard-page) .user-caption strong {
    font-size: var(--ui-type-label);
}

:where(.dashboard-page) .user-caption small {
    font-size: var(--ui-type-note);
}

:where(.dashboard-content) :is(.list-filters, .account-form) label {
    font-size: var(--ui-type-label);
    line-height: 1.6;
}

:where(.dashboard-content) :is(.list-filters, .account-form) :is(input, select, textarea):not(:where([type="hidden"], [type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="button"], [type="submit"], [type="reset"])) {
    min-height: 44px;
    max-width: 100%;
    min-width: 0;
    border-color: var(--ui-field-border);
    font-size: var(--ui-type-body);
    line-height: 1.6;
}

:where(.dashboard-content) .account-form > textarea {
    display: block;
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--ui-field-border);
    border-radius: 10px;
    background: #ffffff;
    color: var(--ui-text);
    resize: vertical;
}

:where(.dashboard-content) :is(.list-filters, .account-form) :is(input, select, textarea):is([readonly], :disabled):not(:where([type="hidden"], [type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="button"], [type="submit"], [type="reset"])) {
    background: #f1f4f9;
    color: var(--ui-supporting);
}

:where(.dashboard-content) :is(.list-filters, .account-form) :is(input, select, textarea)[aria-invalid="true"] {
    border-color: var(--ui-error);
}

:where(.dashboard-content) .input-help {
    font-size: var(--ui-type-label);
    line-height: 1.75;
    color: var(--ui-supporting);
}

:where(.dashboard-content) .field-error {
    font-size: var(--ui-type-label);
    line-height: 1.7;
    color: var(--ui-error);
}

:where(.dashboard-content) .form-feedback {
    font-size: var(--ui-type-label);
    line-height: 1.7;
}

:where(.dashboard-content) .list-filters > .table-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: var(--ui-type-label);
}

:where(.dashboard-content) .accounts-panel th {
    font-size: var(--ui-type-note);
    line-height: 1.6;
}

:where(.dashboard-content) .accounts-panel td {
    font-size: var(--ui-type-label);
    line-height: 1.7;
}

:where(.dashboard-content) .table-sort-control {
    font-size: inherit;
    line-height: 1.6;
}

:where(.dashboard-content) .table-sort-caption {
    font-size: var(--ui-type-label);
    line-height: 1.7;
    color: var(--ui-supporting);
}

:where(.dashboard-content) :is(a, button, input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--ui-action);
    outline-offset: 3px;
}

:where(.dashboard-page) .sidebar :is(a, button, input, select, textarea, summary):focus-visible {
    outline: 2px solid #1d4ed8;
    outline-offset: 2px;
}

:where(.dashboard-page) .sidebar .sidebar-brand :is(a, button):focus-visible {
    outline: 2px solid var(--ui-action);
    outline-offset: 2px;
}

:where(.dashboard-content) .table-scroll:focus-visible {
    outline: 2px solid var(--ui-action);
    outline-offset: -3px;
}

@media (max-width: 600px) {
    :where(.dashboard-content) :is(.list-filters, .account-form) :is(input, select, textarea):not(:where([type="hidden"], [type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="button"], [type="submit"], [type="reset"])) {
        font-size: 16px;
    }
}

/* UI-DS-03/04/05: screen components across academic, family and office modules. */
:where(.dashboard-content) :is(.notice, .preview-notice) {
    font-size: var(--ui-type-label);
    line-height: 1.75;
}

:where(.dashboard-content) :is(.master-tabs, .student-portal-tabs) > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    max-width: 100%;
    font-size: var(--ui-type-label);
    line-height: 1.5;
    white-space: normal;
    text-align: center;
}

:where(.dashboard-content) :is(.finance-table, .report-ledger table, .report-value) {
    font-variant-numeric: tabular-nums;
}

:where(.dashboard-content) :is(.student-portal-table, .finance-table) :is(th, td) {
    line-height: 1.7;
}

/* These screens share the base layout without the authenticated dashboard. */
.login-card > p {
    font-size: var(--ui-type-body);
    line-height: 1.75;
}

.login-card label {
    font-size: var(--ui-type-label);
    line-height: 1.6;
}

.login-card :is(.primary-button, .secondary-button) {
    min-height: 44px;
    font-size: var(--ui-type-body);
    line-height: 1.5;
}

.login-card .input-wrap input {
    font-size: 16px;
}

.login-card :is(.notice, .form-feedback, .field-error, .input-help) {
    font-size: var(--ui-type-label);
    line-height: 1.7;
}

.login-footer {
    font-size: var(--ui-type-note);
    line-height: 1.7;
    flex-wrap: wrap;
}

.login-intro h1 {
    letter-spacing: -.025em;
}

.moodle-secret-input-wrap {
    display: flex;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
}

.moodle-secret-input-wrap input {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 !important;
}

.moodle-secret-toggle {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 14px !important;
    margin: 0 !important;
    white-space: nowrap;
}

.moodle-token-mask {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    padding: 1px 6px;
    border-radius: 6px;
    background: #eef2ff;
    color: #1e3a8a;
    border: 1px solid #c7d2fe;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .moodle-secret-input-wrap input {
        min-height: 44px;
        font-size: 16px;
    }
}

html[data-theme="dark"] .moodle-token-mask {
    background: rgba(37, 99, 235, 0.2);
    color: #bfdbfe;
    border-color: rgba(96, 165, 250, 0.4);
}
