/* ============================================================================
Warm Paper / Ink — application shell: sidebar, topbar, page furniture.
Spec §4 (Sidebar, Topbar) verbatim in colour; reference form for density.
========================================================================= */
.shell {
    display: flex;
    min-height: 100vh;
}
/* ---------------------------------------------------------------------------
Sidebar — the active item is a solid ink block. Never soften it to a tint.
------------------------------------------------------------------------ */
.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--chrome);
    border-right: 1px solid var(--chrome-line);
    padding: var(--s3);
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--s2);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -.03em;
    color: var(--chrome-text);
    padding: var(--s2) var(--s2) var(--s4);
}
.sidebar__mark {
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: var(--on-accent);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
}
.sidebar__label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--chrome-dim);
    padding: var(--s4) var(--s2) var(--s1);
}
.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r);
    color: var(--chrome-text);
    opacity: .78;
    font-size: 13px;
    transition: background var(--tr), opacity var(--tr);
}
.sidebar__link:hover {
    opacity: 1;
    background: var(--accent-soft);
}
.sidebar__link.is-active {
    opacity: 1;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}
.sidebar__link svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    flex: none;
}
.sidebar__count {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.sidebar__foot {
    margin-top: auto;
    padding-top: var(--s4);
}
.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: var(--s1);
}
.sidebar__heading {
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    opacity: 1;
}
.sidebar__heading::-webkit-details-marker {
    display: none;
}
.sidebar__link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.sidebar__heading .sidebar__chevron {
    width: 12px;
    height: 12px;
    margin-left: auto;
}
.sidebar__group[open] > summary .sidebar__chevron {
    transform: rotate(90deg);
}
.sidebar__submenu {
    list-style: none;
    padding: 0 0 0 var(--s3);
    margin: var(--s1) 0 var(--s2) var(--s4);
    border-left: 1px solid var(--chrome-line);
}
/* A dropdown inside a menu (Reports: "Attendance Report" opens to its reports). */
.sidebar__subgroup-toggle {
    cursor: pointer;
    list-style: none;
    font-size: 12px;
    line-height: 1.45;
    margin-block: 2px;
}
.sidebar__subgroup-toggle::-webkit-details-marker {
    display: none;
}
.sidebar__subgroup-toggle .sidebar__chevron {
    width: 11px;
    height: 11px;
    margin-left: auto;
}
.sidebar__subgroup[open] > summary .sidebar__chevron {
    transform: rotate(90deg);
}
.sidebar__submenu--nested {
    margin: 0 0 var(--s1) var(--s2);
}
.sidebar__child {
    font-size: 12px;
    line-height: 1.45;
    margin-block: 2px;
    opacity: 1;
}
.navigation-toggle,
.navigation-close {
    display: none;
}
.page [id] {
    scroll-margin-top: calc(var(--topbar-h) + var(--s5)); /* below the sticky topbar */
}
.nav-button {
    border:0;
    background:transparent;
    width:100%;
    font-family:inherit;
    cursor:pointer;
    text-align:left;
}
/* ---------------------------------------------------------------------------
Topbar — one shade lighter than the sidebar so the two do not merge.
Hairline only; a shadow here makes it feel heavy.
------------------------------------------------------------------------ */
.main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    background: var(--topbar);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--s4);
    display: flex;
    align-items: center;
    gap: var(--s3);
}
.topbar__search {
    display: flex;
    align-items: center;
    gap: var(--s2);
    background: var(--search);
    border: 1px solid transparent;
    border-radius: var(--r-lg);
    padding: 0 11px;
    width: 320px;
    max-width: 40vw;
    transition: border-color var(--tr), box-shadow var(--tr), background var(--tr);
}
.topbar__search:focus-within {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 var(--ring-width) var(--ring);
}
.topbar__search svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
    color: var(--muted);
    flex: none;
}
.topbar__search input {
    border: 0;
    background: transparent;
    outline: 0;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    padding: 8px 0;
    width: 100%;
}
.topbar__search input::placeholder {
    color: var(--faint);
}
.topbar__user {
    display: flex;
    align-items: center;
    gap: var(--s2);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    padding: 4px 10px 4px 4px;
    cursor: pointer;
    font: inherit;
    transition: background var(--tr);
}
.topbar__user:hover {
    background: var(--surface-sunken);
}
.topbar__avatar {
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
}
.topbar__name {
    font-size: 12px;
    font-weight: 600;
}
.topbar__org  {
    font-size: 10px;
    color: var(--muted);
}
/* Company switcher lives in the topbar; it is what makes tenancy visible. */
.switcher select {
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    cursor: pointer;
}
/* ---------------------------------------------------------------------------
Page furniture
------------------------------------------------------------------------ */
.page {
    width: 100%;
    max-width: 1440px;
    margin-inline: auto;
    min-width: 0;
    padding: var(--s5);
    display: flex;
    flex-direction: column;
    gap: var(--s5);
}
.page__head {
    display: flex;
    align-items: flex-start;
    gap: var(--s3);
    flex-wrap: wrap;
}
.page__title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.25;
}
.page__sub {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}
.page__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--s2);
    /* Wraps rather than overflowing. A page with several main actions — the
       device page has six — pushed the last one past the right edge and gave
       the whole document a horizontal scrollbar on a phone. */
    flex-wrap: wrap;
    justify-content: flex-end;
}
.crumbs {
    display: flex;
    align-items: center;
    gap: var(--s2);
    font-size: 11.5px;
    color: var(--muted);
}
.crumbs a:hover {
    color: var(--text);
}
.crumbs__sep {
    color: var(--faint);
}
/* Toolbar above a table: filters left, actions right. */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.toolbar__grow {
    flex: 1 1 220px;
    min-width: 0;
}
/* Filters size to their content. In a form a select fills its field
   (width: 100%), which inside a wrapping toolbar gave every filter a whole row
   of its own. The custom select and Select2 are direct children here because
   each wraps the <select> where it stood; Select2 writes its width inline,
   hence !important. */
.toolbar > .cs,
.toolbar > .select2-container {
    flex: 0 0 auto;
    width: auto !important;
    min-width: 150px;
}
.toolbar > .select2-container {
    min-width: 220px;
}
/* A date picker is width:100% so it fills a form field; in a filter row that
   made "Any day" and "From – To" each take a whole line of their own. Here
   they size like the selects beside them. The From – To picker holds two
   inputs and needs room for two dates. */
.toolbar > .dp {
    flex: 0 0 auto;
    width: auto;
    min-width: 160px;
}
.toolbar > .dp:has(.dp__native ~ .dp__native) {
    min-width: 230px;
}
/* A filter row with many controls (the attendance Daily list: month, year,
   branch, employee, status, a day, a range, Apply) sized to its contents so
   it fits one row on a 1440px screen; on a narrower one it wraps as usual.
   The 150px floor above suits two or three filters, not eight - a year does
   not need 150px. */
.toolbar--fit > .cs {
    min-width: 0;
}
.toolbar--fit > .select2-container {
    min-width: 180px;
    width: 180px !important;
}
.toolbar--fit > .dp {
    min-width: 140px;
}
.toolbar--fit > .dp:has(.dp__native ~ .dp__native) {
    min-width: 210px;
}
/* Empty state — sunken well, never a bare white void. */
.empty {
    padding: var(--s8) var(--s5);
    text-align: center;
    background: var(--surface-sunken);
}
.empty__icon {
    width: 40px;
    height: 40px;
    margin: 0 auto var(--s3);
    border-radius: var(--r-lg);
    background: var(--accent-soft);
    display: grid;
    place-items: center;
    color: var(--accent-ink);
}
.empty__icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}
.empty__title {
    font-size: 13px;
    font-weight: 700;
}
.empty__text {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: var(--s1);
}
/* Flash messages */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--s2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s3) var(--s4);
    font-size: 13px;
    background: var(--surface);
}
.alert--success {
    background: var(--success-soft);
    border-color: transparent;
    color: var(--success-ink);
}
.alert--warning {
    background: var(--warning-soft);
    border-color: transparent;
    color: var(--warning-ink);
}
.alert--danger  {
    background: var(--danger-soft);
    border-color: transparent;
    color: var(--danger-ink);
}
.alert--info    {
    background: var(--info-soft);
    border-color: transparent;
    color: var(--info-ink);
}
/* ---------------------------------------------------------------------------
Auth screen — a single centred card on paper.
------------------------------------------------------------------------ */
.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--s5);
    background: var(--chrome);
}
.auth__card {
    width: 100%;
    max-width: 380px;
}
.auth__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    font-weight: 700;
    letter-spacing: -.03em;
    margin-bottom: var(--s5);
}
/* ---------------------------------------------------------------------------
Responsive — full labelled navigation in a drawer on tablets and phones.
------------------------------------------------------------------------ */
@media (max-width: 1024px) {
    html:not(.navigation-ready) .shell {
        flex-direction: column;
    }
    html:not(.navigation-ready) .sidebar {
        width: 100%;
        height: auto;
        position: static;
    }
    .navigation-ready .sidebar {
        display: none;
    }
    .navigation-ready .sidebar.is-open {
        display: flex;
        position: fixed;
        inset: 0 auto 0 0;
        width: min(280px, calc(100vw - 48px));
        height: 100dvh;
        z-index: 101;
        box-shadow: var(--shadow-lg);
        overscroll-behavior: contain;
    }
    .navigation-ready .navigation-toggle,
    .navigation-ready .navigation-close {
        display: inline-flex;
        flex: none;
    }
    .navigation-close {
        margin-left: auto;
    }
    .navigation-backdrop {
        position: fixed;
        inset: 0;
        background: var(--ring);
        z-index: 100;
    }
    body.navigation-open {
        overflow: hidden;
    }
    .topbar__search {
        width: 200px;
    }
}
@media (max-width: 680px) {
    .page {
        width: 100%;
        max-width: 1440px;
        margin-inline: auto;
        min-width: 0;
        padding: var(--s4) var(--s3);
    }
    .topbar {
        padding: 0 var(--s3);
    }
    .topbar__search {
        max-width: none;
        flex: 1 1 auto;
        width: auto;
    }
    .topbar__name, .topbar__org {
        display: none;
    }
    .page__actions {
        margin-left: 0;
        width: 100%;
        /* Full width on a phone, so the buttons line up under the title
           instead of hanging off the right edge in a ragged block. */
        justify-content: flex-start;
    }
}
.crumbs {
    flex-wrap: wrap;
    overflow-wrap: anywhere;
}

/* The company's logo, whatever its size: scaled to fit, never stretched, and
   never able to push the sidebar around (a 1000x800 upload becomes 28px tall). */
.sidebar__logo {
    width: auto;
    height: auto;
    max-width: 120px;
    max-height: 28px;
    flex: none;
    object-fit: contain;
    border-radius: var(--r-sm);
}
.sidebar__brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* ---------------------------------------------------------------------------
   Page footer. `.main` is a full-height flex column, so `margin-top: auto`
   holds the footer against the bottom of the window on a short page instead
   of letting it ride up under the content. (platform.css carried these rules
   before, and only the platform screens load that file.)
   ------------------------------------------------------------------------ */

.site-footer {
    margin-top: auto;
    padding: var(--s4) var(--s5);
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--s3);
}
.site-footer a {
    color: inherit;
    text-decoration: underline;
}
.site-footer a:hover {
    color: var(--ink);
}
.site-footer__credit {
    margin-left: auto;
}
