/* Shared interface refinements: accessibility, icons and responsive polish */
:root {
    --primary: #007a3f;
    --primary-strong: #006b37;
    --primary-soft: #e7f5ed;
    --focus-ring: rgba(0, 122, 63, 0.26);
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 200;
    padding: 10px 14px;
    border-radius: 6px;
    background: #ffffff;
    color: var(--primary-strong);
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
    transform: translateY(-150%);
    transition: transform 160ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

:where(input, select, textarea):focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: 0;
}

.ui-icon,
.nav-icon,
.metric-card-icon,
.portal-module-icon {
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
}

.nav-link {
    gap: 12px;
    margin-inline: 10px;
    border-radius: 8px;
    transition: color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.nav-link:hover {
    transform: translateX(2px);
}

.nav-link.active {
    box-shadow: 0 6px 16px rgba(0, 107, 55, 0.18);
}

.nav-group-toggle {
    min-height: 36px;
}

.sidebar {
    scrollbar-color: #b9c2bc transparent;
    scrollbar-width: thin;
}

.bell-icon.ui-icon {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 0;
}

.user-menu-panel a .ui-icon,
.user-menu-panel button .ui-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

.user-menu-panel a,
.user-menu-panel button {
    gap: 10px;
}

.topbar {
    background: var(--primary);
}

.panel,
.metric-card {
    border-color: #dfe5e1;
    box-shadow: var(--shadow);
}

.panel {
    border-radius: 10px;
}

.metric-card {
    position: relative;
    overflow: hidden;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

a.metric-card:hover {
    border-color: rgba(0, 122, 63, 0.42);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.11);
    transform: translateY(-2px);
}

.metric-card.has-icon {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto 1fr;
}

.metric-card.has-icon > :not(.metric-card-icon) {
    grid-column: 1;
}

.metric-card-icon {
    grid-column: 2;
    grid-row: 1 / -1;
    width: 38px;
    height: 38px;
    padding: 9px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.compact-metrics .metric-card-icon {
    width: 32px;
    height: 32px;
    padding: 7px;
}

.primary-button,
.secondary-button,
.danger-button,
.button-link,
.actions a,
.actions button {
    gap: 8px;
    transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.primary-button,
.button-link {
    background: var(--primary);
}

.primary-button:hover,
.button-link:hover {
    background: var(--primary-strong);
    box-shadow: 0 7px 16px rgba(0, 107, 55, 0.2);
}

.primary-button:active,
.secondary-button:active,
.danger-button:active,
.button-link:active {
    transform: translateY(1px);
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.advanced-filters input,
.advanced-filters select {
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.form-grid input:hover,
.form-grid select:hover,
.form-grid textarea:hover,
.advanced-filters input:hover,
.advanced-filters select:hover {
    border-color: #aebbb3;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 46px;
}

.password-toggle {
    position: absolute;
    right: 5px;
    bottom: 5px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    padding: 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.password-toggle:hover {
    background: var(--surface-muted);
    color: var(--primary-strong);
}

.password-toggle .ui-icon {
    width: 18px;
    height: 18px;
}

.alert {
    border: 1px solid currentColor;
    border-left-width: 4px;
}

.table-wrap {
    overscroll-behavior-inline: contain;
    scrollbar-color: #b8c2bc #edf1ef;
    scrollbar-width: thin;
}

.data-table tbody tr {
    transition: background-color 120ms ease;
}

.data-table tbody tr:hover {
    background: #f7faf8;
}

.portal-modules {
    gap: 32px;
}

.portal-modules-grid {
    grid-template-columns: repeat(5, minmax(132px, 158px));
    gap: 18px;
}

.portal-module-card {
    width: 100%;
    min-height: 132px;
    padding: 20px 14px 16px;
    border: 1px solid #dfe5e1;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 7px 18px rgba(15, 23, 42, 0.06);
}

.portal-module-card:hover {
    border-color: rgba(0, 122, 63, 0.42);
    box-shadow: 0 14px 28px rgba(0, 107, 55, 0.13);
}

.portal-module-icon {
    width: 52px;
    height: 52px;
    padding: 12px;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary);
}

.portal-module-card > span:last-child {
    color: #475149;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.auth-page {
    background:
        radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.12), transparent 28%),
        linear-gradient(145deg, #005d31, var(--primary));
}

.auth-shell {
    width: min(420px, calc(100vw - 32px));
}

.login-panel {
    border-radius: 16px;
}

.login-panel .primary-button,
.login-panel .secondary-button {
    width: 100%;
    min-height: 44px;
}

body.menu-open,
body.sidebar-expanded {
    overflow: hidden;
}

@media (max-width: 1000px) {
    .portal-modules-grid {
        grid-template-columns: repeat(3, minmax(132px, 158px));
    }
}

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

    .metric-card {
        min-height: 96px;
    }

    .portal-modules {
        padding-inline: 14px;
    }

    .portal-modules-grid {
        grid-template-columns: repeat(2, minmax(126px, 1fr));
        max-width: 360px;
    }
}

@media (max-width: 420px) {
    .portal-module-card {
        min-height: 120px;
    }

    .portal-module-icon {
        width: 48px;
        height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
