:root {
    color-scheme: light;
    --brand-red: #cc1517;
    --brand-red-dark: #a90f12;
    --ink: #272020;
    --muted: #827878;
    --paper: #fff;
    --line: #eae5e1;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--paper);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; }
a { color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

/* Sign-in */
.login-page { display: grid; grid-template-columns: minmax(430px, 0.88fr) minmax(0, 1.12fr); min-height: 100vh; background: #fff; }
.login-panel { display: flex; flex-direction: column; padding: clamp(2rem, 5vw, 5.5rem) clamp(2rem, 7vw, 7rem); }
.login-brand { display: block; width: 204px; margin: 0 auto 2.5rem; }
.login-brand img, .sidebar-brand img { display: block; max-width: 100%; height: auto; }
.login-content { width: min(100%, 390px); margin: auto; padding: 3rem 0; }
.eyebrow { margin: 0 0 1rem; color: var(--brand-red); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.dashboard-heading h1 { margin: 0; font-size: clamp(2.1rem, 4vw, 2.75rem); font-weight: 600; line-height: 1.2; }
.login-form { display: grid; gap: 0.72rem; }
.login-form label { margin-top: 0.15rem; color: #403a38; font-size: 0.82rem; font-weight: 600; }
.login-form input:not([type="hidden"]) { width: 100%; height: 3.25rem; padding: 0 1rem; border: 1px solid #ded8d4; border-radius: 0.45rem; outline: none; background: #fff; color: var(--ink); transition: border-color 160ms ease, box-shadow 160ms ease; }
.login-form input:not([type="hidden"]):focus { border-color: var(--brand-red); box-shadow: 0 0 0 3px rgb(204 21 23 / 12%); }
.password-label-row { display: flex; justify-content: space-between; margin-top: 0.45rem; }
.login-submit { display: flex; justify-content: space-between; align-items: center; height: 3.35rem; margin-top: 0.85rem; padding: 0 1.2rem; border: 0; border-radius: 0.45rem; background: var(--brand-red); color: #fff; cursor: pointer; font-weight: 700; transition: background 160ms ease, transform 160ms ease; }
.login-submit:hover { background: var(--brand-red-dark); transform: translateY(-1px); }
.login-submit span { font-size: 1.25rem; }
.login-error { margin: -0.65rem 0 0.35rem; padding: 0.8rem 1rem; border: 1px solid #f0b8b8; border-radius: 0.4rem; background: #fff3f2; color: #a10d10; font-size: 0.84rem; }
.login-copyright { margin: 2rem 0 0; color: #a49b97; font-size: 0.75rem; }
.login-photo { position: relative; min-height: 100vh; overflow: hidden; background: #5b4941; }
.login-photo > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }

/* Authenticated portal */
.portal-layout { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: 100vh; }
.portal-sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 0.9rem 1.2rem 1.25rem; border-right: 1px solid var(--line); background: #fff; color: var(--ink); }
.sidebar-brand { display: block; width: 150px; margin: 0 auto 2rem; }
.sidebar-nav { display: grid; gap: 0.35rem; }
.sidebar-link { display: flex; align-items: center; gap: 0.8rem; min-height: 2.95rem; padding: 0 0.85rem; border-radius: 0.45rem; color: #625957; font-size: 0.88rem; text-decoration: none; }
.sidebar-link svg { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.sidebar-link.is-active { background: #fff1f0; color: var(--brand-red-dark); }
.sidebar-link.is-active svg { color: var(--brand-red); }
.sidebar-link.is-disabled { color: #aaa19e; cursor: default; }
.sidebar-link small { margin-left: auto; color: #9b8c89; font-size: 0.58rem; }
.user-avatar { display: grid; width: 2.2rem; height: 2.2rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #cc1517; color: #fff; font-size: 1rem; }
.user-details { display: grid; min-width: 0; gap: 0.2rem; }
.user-details strong { overflow: hidden; color: var(--ink); font-size: 0.75rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.user-details small { color: var(--muted); font-size: 0.68rem; }
.portal-main { min-width: 0; background: #fff; }
.portal-topbar { display: flex; align-items: center; justify-content: space-between; min-height: 3.9rem; padding: 0 1.5rem 0 3.2rem; border-bottom: 1px solid var(--line); background: #fff; color: #8a817d; font-size: 0.76rem; }
.breadcrumbs { display: flex; align-items: center; min-width: 0; gap: 0.15rem; white-space: nowrap; }
.breadcrumbs a { overflow: hidden; color: #625957; text-decoration: none; text-overflow: ellipsis; }
.breadcrumbs a:hover { color: var(--brand-red-dark); text-decoration: underline; }
.breadcrumbs [aria-current="page"] { overflow: hidden; color: var(--ink); font-weight: 600; text-overflow: ellipsis; }
.topbar-separator { margin: 0 0.7rem; color: #c5bbb7; }
.user-menu { position: relative; }
.user-menu-trigger { display: flex; align-items: center; gap: 0.65rem; padding: 0.35rem 0.5rem; border-radius: 0.5rem; cursor: pointer; list-style: none; }
.user-menu-trigger::-webkit-details-marker { display: none; }
.user-menu-trigger:hover, .user-menu[open] .user-menu-trigger { background: #f7f4f3; }
.user-menu-trigger:focus-visible { outline: 2px solid var(--brand-red); outline-offset: 2px; }
.user-menu-chevron { width: 1rem; height: 1rem; flex: 0 0 auto; fill: none; stroke: #827878; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; transition: transform 160ms ease; }
.user-menu[open] .user-menu-chevron { transform: rotate(180deg); }
.user-menu-dropdown { position: absolute; z-index: 20; top: calc(100% + 0.45rem); right: 0; min-width: 11rem; padding: 0.35rem; border: 1px solid var(--line); border-radius: 0.55rem; background: #fff; box-shadow: 0 0.75rem 2rem rgb(39 32 32 / 12%); }
.user-menu-dropdown form { margin: 0; }
.logout-button { width: 100%; padding: 0.7rem 0.75rem; border: 0; border-radius: 0.35rem; background: transparent; color: var(--ink); cursor: pointer; font-size: 0.82rem; text-align: left; }
.logout-button:hover { background: #fff1f0; color: var(--brand-red-dark); }
.portal-content { max-width: 1180px; margin: 0 auto; padding: clamp(2.3rem, 5vw, 4.6rem) clamp(1.5rem, 5vw, 4.6rem); }
.portal-welcome { margin: 0; color: var(--muted); font-size: 1rem; font-weight: 400; line-height: 1.5; }

@media (max-width: 900px) {
    .login-page { grid-template-columns: minmax(350px, 0.9fr) minmax(0, 1.1fr); }
    .login-panel { padding-right: 2.5rem; padding-left: 2.5rem; }
    .portal-layout { grid-template-columns: 220px minmax(0, 1fr); }
    .portal-topbar { padding-right: 1.5rem; padding-left: 1.7rem; }
}
@media (max-width: 700px) {
    .login-page { grid-template-columns: 1fr; grid-template-rows: minmax(190px, 26vh) 1fr; }
    .login-panel { grid-row: 2; min-height: auto; padding: 1.7rem 1.5rem 1.2rem; }
    .login-brand { width: 170px; margin-bottom: 2rem; }
    .login-content { padding: 3rem 0; }
    .login-photo { grid-row: 1; display: block; min-height: 190px; }
    .portal-layout { grid-template-columns: 1fr; }
    .portal-sidebar { position: static; height: auto; padding: 0.75rem 1.1rem 0.8rem; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidebar-brand { width: 124px; margin: 0 auto 0.75rem; }
    .sidebar-nav { display: flex; overflow-x: auto; gap: 0.2rem; margin: 0; }
    .sidebar-link { min-height: 2.55rem; flex: 0 0 auto; padding: 0 0.7rem; font-size: 0.77rem; }
    .sidebar-link small { display: none; }
    .user-avatar { width: 1.8rem; height: 1.8rem; font-size: 0.85rem; }
    .portal-topbar { min-height: 3.5rem; padding: 0 0.9rem; font-size: 0.7rem; }
    .breadcrumbs { flex: 1; overflow: hidden; }
    .user-menu-trigger { gap: 0.45rem; padding: 0.3rem; }
    .user-details strong { max-width: min(10rem, 28vw); }
    .user-details small { display: none; }
    .portal-content { padding: 2.2rem 1.2rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
