/* ЭПОТОС corporate fonts, as on epotos.ru: Montserrat for text, Jost for
   headings. Variable fonts (one file covers every weight), served from
   static/fonts rather than a font CDN — the site has to look the same on a
   LAN machine with no internet. Both are SIL OFL 1.1 (licences alongside). */
@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/montserrat-cyrillic.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/montserrat-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
        U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Jost";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/jost-cyrillic.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: "Jost";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/jost-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
        U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* ЭПОТОС corporate style, sampled from epotos.ru (2026-10-09): red
       rgb(202,55,55) for buttons/links, text rgb(51,51,51), headings and the
       dark footer rgb(25,25,25), light sections rgb(249,249,249) / search
       field rgb(239,239,239), cards rounded 16px, buttons square with
       uppercase letter-spaced captions. */
    --font-body: "Montserrat", Arial, sans-serif;
    --font-heading: "Jost", "Montserrat", Arial, sans-serif;
    --color-primary: #ca3737;
    --color-primary-dark: #a82e2e;
    --color-bg: #f4f4f4;
    --color-surface: #ffffff;
    --color-text: #333333;
    --color-heading: #191919;
    --color-muted: #7d7d7d;
    --color-border: #dcdcdc;
    --color-divider: #e8e8e8;
    --color-table-head: #efefef;
    --color-danger: #8f1d1d;
    --color-danger-bg: #fbeaea;
    --color-red: #ca3737;
    --color-success: #137333;
    --color-success-bg: #e6f4ea;
    --color-warning-bg: #fff8e1;
    --color-warning-text: #6d4c00;
    --color-warning-border: #f9ab00;
    --color-info-bg: #e8f1fd;
    --color-info-text: #1a5bb0;
    --color-info-border: #2f7fe0;
    --color-secondary: #555555;
    --color-sidebar: #191919;
    --color-sidebar-hover: #2b2b2b;
    --color-sidebar-text: #b5b5b5;
    --color-chart-blue: #2f7fe0;
    --color-chart-orange: #e08b2f;
    --color-chart-green: #2f9e57;
    --sidebar-width: 236px;
    --topbar-height: 68px;
    --shadow-card: 0 1px 3px rgba(25, 25, 25, .06), 0 1px 2px rgba(25, 25, 25, .04);
    --shadow-hover: 0 6px 18px rgba(25, 25, 25, .10);
    --shadow-login: 0 2px 12px rgba(0, 0, 0, .12);
    --radius: 6px;
    --radius-lg: 16px;
    /* Buttons on epotos.ru have square corners. */
    --radius-button: 0;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
}

h1,
h2 {
    margin-top: 0;
}

h1,
h2,
h3,
.stat-value,
.value,
.metric-value,
.donut-total,
.request-card-id,
.sidebar-brand,
.login-brand {
    font-family: var(--font-heading);
}

h1,
h3 {
    color: var(--color-heading);
}

h2 {
    color: var(--color-primary);
    font-size: 20px;
}

a {
    color: inherit;
}

hr {
    margin: 26px 0;
    border: 0;
    border-top: 1px solid var(--color-divider);
}

/* App shell: sidebar + topbar */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: var(--sidebar-width);
    padding: 20px 14px;
    background: var(--color-sidebar);
    color: #fff;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 14px;
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
    line-height: 1.25;
}

.sidebar-brand img {
    border-radius: 7px;
    flex-shrink: 0;
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0 0 14px 4px;
    border-radius: 7px;
    color: var(--color-sidebar-text);
    cursor: pointer;
}

.sidebar-collapse-btn:hover {
    background: var(--color-sidebar-hover);
    color: #fff;
}

.sidebar-collapse-btn .icon {
    width: 18px;
    height: 18px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 8px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 15px;
    white-space: nowrap;
}

.sidebar-nav a:hover {
    background: var(--color-sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
}

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    /* Some mobile browsers resolve a tap to the inline <svg> rather than to
       the button or link wrapping it, and drop the activation — the topbar's
       "Выйти" button was reported dead on a phone while never producing a
       single POST /logout in the access log. Making icons transparent to
       pointer events means a tap always lands on the control itself. Purely
       decorative markup, so nothing is lost. */
    pointer-events: none;
}

/* Desktop collapse-to-icons. Scoped to min-width so it can never fight with
   the mobile off-canvas drawer below — the two mechanisms share the sidebar
   but never apply at the same time. */
@media (min-width: 901px) {
    .sidebar {
        transition: width .15s ease;
    }

    .sidebar-collapse-toggle:checked ~ .app .sidebar {
        width: 76px;
    }

    .sidebar-collapse-toggle:checked ~ .app .sidebar-brand {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    .sidebar-collapse-toggle:checked ~ .app .sidebar-brand span,
    .sidebar-collapse-toggle:checked ~ .app .sidebar-nav a span {
        display: none;
    }

    .sidebar-collapse-toggle:checked ~ .app .sidebar-collapse-btn {
        margin-left: auto;
        margin-right: auto;
    }

    .sidebar-collapse-toggle:checked ~ .app .sidebar-nav a {
        justify-content: center;
        padding: 11px;
    }
}

.app-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--topbar-height);
    flex-shrink: 0;
    padding: 0 26px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-divider);
}

.topbar-menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
    color: var(--color-text);
    cursor: pointer;
}

.topbar-menu:hover {
    background: var(--color-bg);
}

.topbar-search {
    position: relative;
    flex: 1;
    max-width: 620px;
}

.topbar-search-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    color: var(--color-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.topbar-search input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    border: 1px solid var(--color-divider);
    border-radius: 22px;
    background: var(--color-bg);
}

.topbar-search input:focus {
    outline: 2px solid rgba(202, 55, 55, .25);
    background: var(--color-surface);
}

/* User menu — a <details>/<summary> pair, so the logout action lives behind
   a click on the name/avatar with no JS involved. */

.topbar-user-menu {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 10px;
    cursor: pointer;
    list-style: none;
}

.topbar-user::-webkit-details-marker {
    display: none;
}

.topbar-user:hover {
    background: var(--color-bg);
}

.topbar-user-menu[open] .topbar-user {
    background: var(--color-bg);
}

.topbar-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-weight: bold;
}

.topbar-user-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.topbar-user-name {
    font-size: 14px;
    font-weight: bold;
}

.topbar-user-role {
    color: var(--color-muted);
    font-size: 12px;
}

.topbar-chevron {
    display: flex;
    color: var(--color-muted);
}

.topbar-chevron .icon {
    width: 16px;
    height: 16px;
}

.topbar-user-menu[open] .topbar-chevron {
    transform: rotate(180deg);
}

.topbar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 40;
    width: 220px;
    padding: 8px;
    border-radius: 12px;
    background: var(--color-surface);
    box-shadow: var(--shadow-hover);
}

.topbar-dropdown-info {
    padding: 8px 10px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--color-divider);
}

.topbar-dropdown-info .topbar-user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-dropdown button,
.topbar-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text);
    font-size: 14px;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
}

.topbar-dropdown button:hover,
.topbar-dropdown a:hover {
    background: var(--color-bg);
}

.sidebar-backdrop {
    display: none;
}

/* Layout */

.app-body main {
    flex: 1;
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 26px;
}

.app-body main.main-sm {
    max-width: 840px;
}

.app-body main.main-xs {
    max-width: 780px;
}

.app-body main.main-md {
    max-width: 1140px;
}

.app-body main.main-lg {
    max-width: 1440px;
}

.page-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 22px;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.back-link {
    display: inline-block;
    margin-bottom: 18px;
    color: var(--color-primary);
    text-decoration: none;
}

/* Cards */

.card {
    margin-bottom: 20px;
    padding: 26px;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.card:last-child {
    margin-bottom: 0;
}

.cards {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.cards .card {
    min-width: 220px;
    padding: 24px;
    margin-bottom: 0;
}

.value {
    margin-top: 12px;
    color: var(--color-primary);
    font-size: 36px;
    font-weight: bold;
}

/* Tables */

.table-box {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    /* Montserrat runs ~10% wider than the Arial the tables were laid out
       for; one size down keeps the registry as wide as before. */
    font-size: 14px;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--color-divider);
    vertical-align: top;
    text-align: left;
}

th {
    background: var(--color-table-head);
    color: var(--color-heading);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

td a {
    color: var(--color-primary);
    font-weight: bold;
}

td a:hover,
.back-link:hover {
    text-decoration: underline;
}

.description {
    min-width: 250px;
    max-width: 420px;
    white-space: pre-wrap;
}

.status {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 5px;
    background: var(--color-table-head);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

/* A colour per status, so a list can be read at a glance: new — waits for
   an engineer, rework — went back, waiting — the master's turn, accepted —
   done. */
.status-new { background: #fff4d6; color: #8a5a00; }
.status-in_work { background: #e3f2f3; color: #1b6f7a; }
.status-waiting_accept { background: #f1ecfb; color: #5b3fb0; }
.status-rework { background: #fdf0e6; color: #b4561a; }
.status-accepted { background: var(--color-success-bg); color: var(--color-success); }
.status-canceled { background: var(--color-table-head); color: var(--color-muted); }

.priority-high {
    color: var(--color-red);
    font-weight: bold;
}

.priority-value {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.repair-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.repair-type-badge-emergency {
    background: #fdeaea;
    color: #b02f2f;
}

.repair-type-badge-current {
    background: var(--color-table-head);
    color: var(--color-text);
}

.repair-type-badge-modernization {
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.active {
    color: var(--color-success);
    font-weight: bold;
}

.inactive {
    color: var(--color-red);
    font-weight: bold;
}

.empty {
    padding: 24px;
}

/* Requests registry: table on wide screens, cards on narrow ones */

.request-cards {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.request-card {
    display: flex;
    flex-direction: column;
    padding: 16px 16px 14px 18px;
    border-left: 5px solid var(--color-warning-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s ease;
}

.request-card:hover {
    box-shadow: var(--shadow-hover);
}

.request-card-emergency {
    border-left-color: var(--color-red);
}

.request-card-modernization {
    border-left-color: var(--color-info-border);
}

.request-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.request-card-id {
    color: var(--color-primary);
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.request-card-equipment {
    margin-bottom: 3px;
    color: var(--color-heading);
    font-weight: 600;
    line-height: 1.3;
}

.request-card-location {
    margin-bottom: 10px;
    color: var(--color-muted);
    font-size: 13px;
}

/* At most three lines; the full text is one tap away on the card itself. */
.request-card-description {
    display: -webkit-box;
    margin-bottom: 12px;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.request-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.request-card-foot {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--color-divider);
    color: var(--color-muted);
    font-size: 12px;
}

.request-card-date {
    flex-shrink: 0;
}

/* Priority as a small pill with a dot, instead of the emoji circles. */
.priority-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 5px;
    background: var(--color-table-head);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.priority-pill::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-muted);
}

.priority-pill-high {
    background: #fdeaea;
    color: #b02f2f;
}

.priority-pill-high::before {
    background: var(--color-red);
}

.priority-pill-medium::before {
    background: var(--color-warning-border);
}

.priority-pill-low::before {
    background: var(--color-chart-green);
}

@media (max-width: 800px) {
    .requests-table-box {
        display: none;
    }

    .request-cards {
        display: flex;
    }

    /* Admin tables can't switch to the hand-written card markup the registry
       uses — their cells contain inline edit forms. Instead each row becomes a
       card and every cell prints its column name from data-label, so nothing
       needs a second copy of the markup. */
    .table-responsive,
    .table-responsive table,
    .table-responsive tbody,
    .table-responsive tr,
    .table-responsive td {
        display: block;
        width: 100%;
    }

    .table-responsive thead {
        display: none;
    }

    .table-responsive {
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    .table-responsive tr {
        margin-bottom: 12px;
        padding: 12px 14px;
        border-radius: var(--radius-lg);
        background: var(--color-surface);
        box-shadow: var(--shadow-card);
    }

    .table-responsive td {
        padding: 6px 0;
        border-bottom: 0;
    }

    .table-responsive td:not(:last-child) {
        border-bottom: 1px solid var(--color-divider);
    }

    .table-responsive td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 3px;
        color: var(--color-muted);
        font-size: 12px;
    }

    .table-responsive td:empty {
        display: none;
    }

    /* One pagination bar is enough on a phone — the top copy pushed the first
       row nearly a full screen down. */
    .pagination-top {
        display: none;
    }
}

/* Buttons / links */

.button,
.create-button,
.button-link,
.cancel,
a.button {
    display: inline-block;
    padding: 11px 16px;
    border-radius: var(--radius-button);
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

/* Action captions as on epotos.ru: uppercase, slightly spaced. Not on the
   small in-table buttons, the user menu or icon-only controls — there it
   only costs width. */
.button,
.create-button,
.button-link,
.cancel,
a.button,
.btn-primary,
button:not(.button-small):not(.modal-close) {
    font-size: 13px;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.topbar-dropdown button {
    font-size: 14px;
    letter-spacing: normal;
    text-transform: none;
}

.button-link,
.cancel {
    background: var(--color-secondary);
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 26px;
}

/* A row of one-button forms (type change, approve/reject): equal widths and
   heights side by side, one under another on a phone. Without this the
   uppercase captions wrapped to different line counts and the second button
   ran past the card's edge on an iPhone. */
.buttons > form {
    display: flex;
    flex: 1 1 240px;
    max-width: 380px;
}

.buttons > form > button {
    width: 100%;
}

button {
    padding: 12px 18px;
    border: 0;
    border-radius: var(--radius-button);
    background: var(--color-primary);
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
}

.button:hover,
.create-button:hover,
a.button:hover,
button:hover {
    background: var(--color-primary-dark);
}

.button-link:hover,
.cancel:hover {
    background: #3d3d3d;
}

.button-small {
    padding: 6px 10px;
    font-size: 13px;
}

.button-danger {
    background: var(--color-danger);
}

.button-danger:hover {
    background: #6e1616;
}

.inline-form {
    display: inline-block;
}

.row-form {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.row-form input,
.row-form select {
    width: auto;
    min-width: 90px;
    padding: 7px 8px;
}

/* Pagination */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 14px 0;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.page-size-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-label {
    font-size: 14px;
    color: var(--color-muted);
}

.page-size-picker select {
    width: auto;
    padding: 6px 8px;
}

.page-links {
    display: flex;
    align-items: center;
    gap: 14px;
}

.page-links a {
    color: var(--color-primary);
    font-weight: bold;
    text-decoration: none;
}

.page-status {
    color: var(--color-muted);
    font-size: 14px;
}

.page-link-disabled {
    color: var(--color-muted);
    opacity: .5;
}

/* Tab-style sub-navigation (admin sections, requests view toggle, ...) */

.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--color-divider);
    /* Four admin tabs don't fit a phone's width — scroll them instead of
       letting the row push the whole page sideways. */
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab-nav a {
    padding: 10px 16px;
    color: var(--color-muted);
    text-decoration: none;
    font-weight: bold;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}

.tab-nav a.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Forms */

label {
    display: block;
    margin: 16px 0 7px;
    font-weight: bold;
}

input,
select,
textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 11px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font: inherit;
}

/* Safari on iPhone draws date fields at its own intrinsic width and will not
   shrink them to width: 100%, so they ran past the filter card; an empty one
   also collapsed to a different height from the text fields next to it. */
input[type="date"] {
    display: block;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}

/* Text, date and select fields one height, so a filter row lines up. */
input:not([type="checkbox"]):not([type="radio"]),
select {
    min-height: 46px;
}

/* ...but not the deliberately compact ones. */
.topbar-search input,
.page-size-picker select,
.row-form input,
.row-form select {
    min-height: 0;
}

input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
}

/* A submit button sitting directly after the last field (no .buttons/.row-form
   wrapper) needs its own top margin — nothing else adds space below the last
   input. */
form > button[type="submit"] {
    margin-top: 8px;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

textarea.textarea-lg {
    min-height: 130px;
}

.hidden {
    display: none;
}

.hint {
    margin: 7px 0 0;
    color: var(--color-muted);
    font-size: 14px;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
}

.checkbox input {
    width: auto;
}

.info {
    margin-bottom: 24px;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--color-table-head);
}

/* Request detail */

.detail-top-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 20px;
    margin-bottom: 20px;
}

.detail-top-grid-single {
    grid-template-columns: 1fr;
}

.detail-top-grid > .card {
    margin-bottom: 0;
}

.detail-time-card {
    display: flex;
    flex-direction: column;
}

.time-summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex: 1;
}

.time-summary .donut-wrap {
    flex-shrink: 0;
    margin: 0;
}

.time-summary .donut-legend {
    align-self: stretch;
    width: 100%;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 30px;
}

.field-name {
    margin-bottom: 5px;
    color: var(--color-muted);
    font-size: 14px;
}

.field-value {
    font-weight: bold;
    white-space: pre-wrap;
}

.timeline-item {
    margin-top: 14px;
    padding-left: 16px;
    border-left: 4px solid var(--color-primary);
}

.timeline-date {
    color: var(--color-muted);
    font-size: 14px;
}

/* An edit lists one change per line. */
.timeline-comment {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* "Изменить заявку" under the status on the request card. */
.detail-edit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
}

.detail-edit .hint {
    margin: 0;
}

.type-pending {
    padding: 12px;
    border-left: 4px solid var(--color-warning-border);
    border-radius: 4px;
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    font-weight: bold;
}

/* Stats */

/* Wrapping flex, not a fixed grid: a grid with a column per field needed
   ~1550px for the registry's eight and pushed "Применить" off the card on an
   ordinary 1366px laptop. Fields now share the row and wrap as it runs out. */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

.filters > * {
    flex: 1 1 150px;
    min-width: 0;
}

.filters > button,
.filters > .cancel,
.filters > .filter-buttons {
    flex: 0 0 auto;
}

.filters .filter-search {
    flex: 2 1 260px;
}

.bulk-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.bulk-actions-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
}

.bulk-actions-controls label {
    margin: 0 0 5px;
    font-size: 13px;
}

.bulk-actions-controls select {
    width: auto;
    min-width: 160px;
}

/* Dashboard */

.dash-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 22px;
}

.dash-head h1 {
    margin: 0;
    font-size: 30px;
}

/* "Список изменений" above the greeting: a summary line that opens a
   popover (a <details>, so it works without the script). */
.changelog {
    position: relative;
    display: inline-block;
    margin-bottom: 8px;
}

.changelog summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    color: var(--color-text);
}

.changelog summary::-webkit-details-marker {
    display: none;
}

.changelog summary:hover .changelog-title {
    text-decoration: underline;
}

.changelog-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-red);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

.changelog-pop {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 50;
    /* On a phone the summary starts ~26px in; keep the same gap on the right. */
    width: min(460px, calc(100vw - 52px));
    max-height: 60vh;
    overflow-y: auto;
    padding: 14px 18px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-hover);
    font-size: 14px;
    line-height: 1.45;
}

/* Each date is its own card; the newest open, older ones folded. */
.changelog-entry {
    padding: 10px 12px;
    border: 1px solid var(--color-divider);
    border-radius: var(--radius);
}

.changelog-entry + .changelog-entry {
    margin-top: 10px;
}

.changelog-pop h3,
.changelog-entry-old summary {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-muted);
}

.changelog-entry-old summary {
    margin: 0;
    cursor: pointer;
}

.changelog-entry-old[open] summary {
    margin-bottom: 6px;
}

.changelog-pop ul {
    margin: 0;
    padding-left: 18px;
}

.changelog-pop li + li {
    margin-top: 6px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 22px;
    border: 0;
    border-radius: var(--radius-button);
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

/* Create-request modal */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(25, 25, 25, .55);
}

.modal {
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 26px;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-hover);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.modal-head h2 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--color-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

/* Stat cards */

.stat-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1 1 215px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    color: inherit;
    text-decoration: none;
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 12px;
}

.stat-icon .icon {
    width: 22px;
    height: 22px;
}

.stat-icon-red { background: #fbeaea; color: #b02f2f; }
.stat-icon-alert { background: #fdf0e6; color: #c2661d; }
.stat-icon-blue { background: #e9f1fc; color: #2f7fe0; }
.stat-icon-green { background: #e7f4ec; color: #2f9e57; }
.stat-icon-purple { background: #f1ecfb; color: #6d4fc2; }
.stat-icon-teal { background: #e3f2f3; color: #1b7a86; }
.stat-icon-gold { background: #fdf3df; color: #a9790a; }

.stat-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-name {
    color: var(--color-muted);
    font-size: 14px;
}

.stat-value {
    margin: 2px 0;
    font-size: 32px;
    font-weight: bold;
    line-height: 1.1;
}

.stat-value-alert {
    color: var(--color-primary);
}

.stat-delta {
    color: var(--color-chart-blue);
    font-size: 12px;
}

/* Chart row */

.chart-grid {
    display: grid;
    /* min(): on a 390px phone the card area is ~358px, and a hard 330px
       minimum plus padding pushed every chart card 11px past the edge. */
    grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

.chart-card {
    margin-bottom: 0;
    padding: 22px;
    border-radius: 14px;
}

.chart-card-wide {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 420px;
}

@media (max-width: 900px) {
    .chart-card-wide {
        grid-column: span 1;
    }
}

.chart-card h2 {
    margin: 0 0 18px;
    color: var(--color-text);
    font-size: 17px;
}

/* Line chart */

.line-chart {
    display: block;
    width: 100%;
    height: auto;
}

.chart-card-wide .line-chart {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.chart-line {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-dot {
    fill: var(--color-surface);
    stroke: var(--color-primary);
    stroke-width: 2;
}

.chart-gridline {
    stroke: var(--color-divider);
    stroke-width: 1;
}

.chart-axis {
    fill: var(--color-muted);
    font-size: 11px;
}

.chart-value-label {
    fill: var(--color-chart-blue);
    font-size: 11px;
    font-weight: bold;
}

.chart-line-blue {
    stroke: var(--color-chart-blue);
}

.chart-dot-blue {
    stroke: var(--color-chart-blue);
}

/* Donut ring */

.donut-wrap {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 20px;
}

.donut-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.donut-track,
.donut-segment {
    fill: none;
    stroke-width: 3.2;
}

.donut-track {
    stroke: var(--color-table-head);
}

.donut-segment {
    stroke-linecap: round;
}

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.donut-total {
    font-size: 30px;
    font-weight: bold;
    line-height: 1.1;
}

.donut-total-label {
    color: var(--color-muted);
    font-size: 12px;
}

.donut-total-text {
    font-size: 18px;
    font-weight: bold;
    line-height: 1.25;
    text-align: center;
    padding: 0 10px;
}

.donut-legend {
    display: grid;
    gap: 8px;
}

.donut-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.donut-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.donut-legend-label {
    flex: 1;
    color: var(--color-text);
}

.donut-legend-value {
    color: var(--color-muted);
    font-weight: bold;
}

/* Request card: working time leads, calendar time beside it in grey. */
.detail-time-card .donut-legend-value {
    color: var(--color-text);
    white-space: nowrap;
}

.donut-legend-running {
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    font-size: 12px;
    font-weight: 600;
}

.donut-legend-calendar {
    margin-left: 8px;
    color: var(--color-muted);
    font-weight: normal;
}

.donut-legend-calendar::before {
    content: "(";
}

.donut-legend-calendar::after {
    content: ")";
}

.time-summary-note {
    margin: 16px 0 0;
    color: var(--color-muted);
    font-size: 13px;
}

/* Calendar heatmap */

.calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.calendar-head h2 {
    margin: 0;
}

.calendar-nav {
    display: flex;
    gap: 6px;
}

.calendar-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--color-text);
}

.calendar-nav-btn .icon {
    width: 18px;
    height: 18px;
}

a.calendar-nav-btn:hover {
    background: var(--color-bg);
}

.calendar-nav-disabled {
    color: var(--color-muted);
    opacity: .4;
}

.calendar-nav-prev {
    transform: rotate(90deg);
}

.calendar-nav-next {
    transform: rotate(-90deg);
}

.heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.heatmap-weekday {
    padding-bottom: 6px;
    color: var(--color-muted);
    font-size: 13px;
    text-align: center;
}

.heatmap-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: 8px;
    color: var(--color-muted);
    font-size: 15px;
    text-decoration: none;
}

a.heatmap-cell:hover {
    filter: brightness(0.92);
}

.heatmap-blank {
    visibility: hidden;
}

.heatmap-today {
    /* The inset ring alone disappears on heat-3/heat-4 cells, whose own
       background is close to --color-primary — the outer black line stays
       visible no matter how busy (and how red) the day is. */
    box-shadow: inset 0 0 0 2px var(--color-primary), 0 0 0 1px #000;
    color: var(--color-text);
    font-weight: bold;
}

.heatmap-future {
    opacity: .45;
}

.heat-0 { background: var(--color-table-head); }
.heat-1 { background: #f6c9c9; color: #7a1f1f; }
.heat-2 { background: #ed9a9a; color: #5c1414; }
.heat-3 { background: #dd6363; color: #fff; }
.heat-4 { background: var(--color-primary); color: #fff; }

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    color: var(--color-muted);
    font-size: 12px;
}

.heatmap-legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.bar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dashboard: equipment in repair */

.in-repair {
    padding: 20px 22px;
}

.in-repair h2 {
    margin: 0 0 12px;
    color: var(--color-text);
    font-size: 17px;
}

.in-repair-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* A card per machine: what is down, why, and where its request stands —
   the same facts as a registry card on a phone, coloured by repair type. */
.in-repair-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--color-text);
    text-decoration: none;
    transition: box-shadow .15s ease;
}

/* Every tile the same size, every fact at the same height: the name always
   takes two lines (a longer one ends in "…", the whole name is the
   tooltip), the place one line, then status, priority and date in a row. */
.in-repair-item .in-repair-name {
    display: -webkit-box;
    min-height: calc(2 * 1.3em);
    overflow: hidden;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.in-repair-location {
    overflow: hidden;
    color: var(--color-muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.in-repair-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 4px;
}

.in-repair-tags > .status,
.in-repair-tags > .priority-pill {
    flex-shrink: 0;
}

/* Gives way first on a narrow phone, so the row never wraps and the tiles
   keep one height. */
.in-repair-date {
    min-width: 0;
    margin-left: auto;
    overflow: hidden;
    color: var(--color-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.in-repair-item:hover {
    box-shadow: var(--shadow-hover);
}

/* White like the registry cards, the repair type in the left edge: a tinted
   ground drowned the status colours. */
.in-repair-item {
    border: 1px solid var(--color-divider);
    border-left-width: 5px;
    background: var(--color-surface);
}

.in-repair-emergency {
    border-left-color: var(--color-red);
}

.in-repair-current {
    border-left-color: var(--color-warning-border);
}

.in-repair-modernization {
    border-left-color: var(--color-info-border);
}

.in-repair-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* Pinned to the bottom: tiles in a row share a height, and a name that
   wraps to three lines must not leave its neighbours' dates floating
   higher. */
.in-repair-since {
    margin-top: auto;
    padding-top: 4px;
    color: var(--color-muted);
    font-size: 12px;
}

.in-repair-legend {
    margin-left: 6px;
    color: var(--color-muted);
    font-size: 13px;
    font-weight: normal;
    white-space: nowrap;
}

.in-repair-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin: 0 4px 0 2px;
    border-radius: 50%;
    vertical-align: 0;
}

.in-repair-dot-current {
    background: var(--color-warning-border);
}

.in-repair-dot-emergency {
    background: var(--color-red);
}

.in-repair-dot-modernization {
    background: var(--color-info-border);
}

/* Registry filter bar */

.registry-filters {
    padding: 18px;
}

.filter-buttons {
    display: flex;
    gap: 8px;
}

.filter-buttons .button-link {
    padding: 11px 14px;
    white-space: nowrap;
}

/* Sortable table headers */

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.sort-link:hover {
    text-decoration: underline;
}

.sort-link.sorted {
    color: var(--color-primary);
}

.sort-arrow {
    font-size: 10px;
}

/* "Created by me" marker */

.mine-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--color-table-head);
    color: var(--color-primary);
    font-size: 11px;
    font-weight: bold;
    vertical-align: middle;
}

.row-mine td:first-child {
    box-shadow: inset 3px 0 0 var(--color-primary);
}

/* Whole-row click target: the id link's ::after is stretched to cover the
   row via the classic "stretched link" trick, so clicking anywhere in the
   row opens the request — not just the id itself. */
.request-row {
    position: relative;
    cursor: pointer;
}

.request-row:hover {
    background: var(--color-table-head);
}

.request-row-link::after {
    content: "";
    position: absolute;
    inset: 0;
}

.card-mine {
    border-left: 3px solid var(--color-primary);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.metric {
    display: block;
    padding: 18px;
    border-radius: 8px;
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    color: inherit;
    text-decoration: none;
}

a.metric:hover {
    box-shadow: 0 2px 14px rgba(0, 0, 0, .16);
}

.metric-value-alert {
    color: var(--color-danger);
}

.metric-name {
    color: var(--color-muted);
    font-size: 14px;
}

.metric-value {
    margin-top: 8px;
    color: var(--color-primary);
    font-size: 32px;
    font-weight: bold;
}

.bars {
    display: grid;
    gap: 10px;
}

.bar-row {
    display: grid;
    grid-template-columns: 180px 1fr 60px;
    gap: 10px;
    align-items: center;
}

.bar-bg {
    height: 20px;
    overflow: hidden;
    border-radius: 5px;
    background: var(--color-table-head);
}

.bar {
    height: 100%;
    background: var(--color-primary);
}

/* Login */

.login-box-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Layout after b2b.epotos.ru's sign-in: one flat white card, the logo and
   the title centred at its top, full-width controls, the help line centred
   under them. */
.login-box {
    width: min(420px, calc(100% - 32px));
    padding: 32px 30px 28px;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
}

.login-head {
    margin-bottom: 22px;
    text-align: center;
}

.login-head img {
    display: block;
    margin: 0 auto 12px;
}

.login-title {
    margin: 0;
    font-size: 24px;
}

.login-box label {
    font-weight: 500;
}

.login-box input {
    padding: 13px 14px;
}

.login-box button[type="submit"],
.login-box .bitrix24-button {
    display: block;
    width: 100%;
    padding: 15px 18px;
}

.login-box button[type="submit"] {
    margin-top: 22px;
}

.login-box .login-links {
    text-align: center;
}

.auth-tabs {
    margin: 0 0 18px;
}

.auth-tabs a {
    flex: 1;
    text-align: center;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--color-muted);
    font-size: 13px;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--color-divider);
}

.bitrix24-button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    background: #2fc7f7;
}

.bitrix24-button:hover {
    background: #1eb3e3;
}

.login-links {
    margin-top: 20px;
    line-height: 1.6;
}

.error {
    padding: 10px;
    border-radius: var(--radius);
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.success {
    padding: 10px;
    border-radius: var(--radius);
    background: var(--color-success-bg);
    color: var(--color-success);
}

/* Список мастеров участка: кандидатов может быть больше десятка, а ячейка
   таблицы узкая — поэтому компактный прокручиваемый список, где отмеченные
   видны с первого взгляда. */
.masters-picker {
    max-height: 168px;
    overflow-y: auto;
    overflow-x: hidden;
    width: 270px;
    max-width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.masters-picker-item {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    padding: 7px 10px;
    font-weight: normal;
    font-size: 0.92em;
    line-height: 1.25;
    cursor: pointer;
}

.masters-picker-item + .masters-picker-item {
    border-top: 1px solid var(--color-border);
}

/* Глобальное `input { width: 100%; padding: 11px }` иначе растягивает сам
   чекбокс на всю ячейку и отбрасывает фамилию к правому краю. */
.masters-picker-item input[type="checkbox"] {
    flex: none;
    width: 15px;
    height: 15px;
    margin: 0;
    padding: 0;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.masters-picker-item span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.masters-picker-item:hover {
    background: var(--color-bg);
}

.masters-picker-item:has(input:checked) {
    background: var(--color-table-head);
    font-weight: 600;
}

.masters-picker-actions {
    margin-top: 8px;
    width: 270px;
    max-width: 100%;
}

/* Подсказка — отдельной строкой под кнопкой: рядом она в узкой ячейке
   переносится на две строки и обтекает кнопку неряшливо. */
.masters-picker-actions .hint {
    display: block;
    margin: 6px 0 0;
}

.equipment-edit-status {
    font-size: 0.85em;
    color: var(--color-success);
    white-space: nowrap;
}

.equipment-edit-status.error {
    padding: 0;
    background: none;
    color: var(--color-danger);
}

/* Responsive */

@media (max-width: 900px) {
    /* Sidebar becomes an off-canvas drawer, opened by the checkbox hack in
       base.html so it works even if a page's own script fails. */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 30;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 20;
        display: none;
        background: rgba(0, 0, 0, .4);
    }

    .sidebar-toggle:checked ~ .app .sidebar {
        transform: translateX(0);
    }

    .sidebar-toggle:checked ~ .app .sidebar-backdrop {
        display: block;
    }

    /* The collapse-to-icons button only makes sense on desktop — mobile
       already has the full drawer via the hamburger button. */
    .sidebar-collapse-btn {
        display: none;
    }

    .topbar-menu {
        display: flex;
    }

    .topbar {
        padding: 0 16px;
        gap: 10px;
    }

    .topbar-user-text {
        display: none;
    }
}

@media (max-width: 700px) {
    /* `.app-body main` too: its own 26px rule is more specific than a bare
       `main` and silently kept the wide desktop gutter on phones. */
    main,
    .app-body main {
        padding: 16px;
    }

    .card {
        padding: 18px;
    }

    .dash-head h1 {
        font-size: 24px;
    }

    .stat-value {
        font-size: 26px;
    }

    .topbar-search input {
        padding-left: 38px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .detail-top-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .bar-row {
        grid-template-columns: 120px 1fr 40px;
    }

    /* One tile per row on a phone, so equal heights buy nothing there,
       while a cut-off machine name costs a tap: show it whole, and let the
       date drop under the status rather than be cut. */
    .in-repair-item .in-repair-name {
        display: block;
        min-height: 0;
    }

    .in-repair-tags {
        flex-wrap: wrap;
    }

    .in-repair-date {
        overflow: visible;
    }
}
