:root {
    --bg: #f5f7f9;
    --surface: #ffffff;
    --surface-soft: #f8fafb;
    --text: #17202a;
    --muted: #68727e;
    --line: #e4e8ec;
    --line-strong: #d6dce2;
    --accent: #246bfd;
    --accent-soft: #edf3ff;
    --green: #168a56;
    --red: #c9352b;
    --amber: #b76b00;
    --sidebar: 232px;
    --label: 252px;
    --day: 112px;
    --radius: 14px;
    --shadow: 0 14px 40px rgba(22, 35, 49, .10);
    color-scheme: light;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
select,
label,
summary {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

a {
    color: var(--accent);
}

.hidden {
    display: none !important;
}

.boot-screen {
    min-height: 100vh;
    display: grid;
    place-content: center;
    gap: 24px;
    background: #fff;
}

.boot-dot {
    width: 7px;
    height: 7px;
    margin: auto;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.2s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: .28; transform: scale(.8); }
    50% { opacity: 1; transform: scale(1.15); }
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    letter-spacing: -.04em;
    white-space: nowrap;
}

.brand span {
    font-size: 20px;
    font-weight: 720;
}

.brand small {
    font-size: 14px;
    font-weight: 540;
    color: var(--muted);
}

.brand--center span {
    font-size: 29px;
}

.brand--center small {
    font-size: 18px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(300px, 440px) 1fr;
    background: var(--surface);
}

.login-panel {
    padding: clamp(30px, 7vw, 84px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 1px solid var(--line);
}

.login-copy {
    background:
        radial-gradient(circle at 70% 20%, rgba(36, 107, 253, .12), transparent 28%),
        linear-gradient(145deg, #f7faff, #f4f6f8 65%, #eef3f8);
    display: flex;
    align-items: flex-end;
    padding: 8vw;
}

.login-copy p {
    max-width: 520px;
    font-size: clamp(24px, 3vw, 48px);
    font-weight: 380;
    line-height: 1.12;
    letter-spacing: -.035em;
    margin: 0;
}

.login-card {
    margin-top: 68px;
}

.login-card h1 {
    font-size: 26px;
    font-weight: 560;
    letter-spacing: -.025em;
    margin: 0 0 8px;
}

.login-card > p {
    color: var(--muted);
    margin: 0 0 28px;
}

.security-notice {
    background: #fff7e8;
    border: 1px solid #f3d292;
    border-radius: 10px;
    color: #74520e;
    font-size: 13px;
    line-height: 1.45;
    margin: -12px 0 22px;
    padding: 11px 13px;
}

.form-stack {
    display: grid;
    gap: 17px;
}

.field {
    display: grid;
    gap: 7px;
}

.field > span,
.field-label {
    color: #4d5965;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 43px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    padding: 9px 11px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.textarea {
    min-height: 92px;
    resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: #8cb0ff;
    box-shadow: 0 0 0 3px rgba(36, 107, 253, .11);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    background: #f4f6f8;
    color: var(--muted);
}

.check {
    display: flex;
    gap: 9px;
    align-items: center;
    color: #4e5964;
    cursor: pointer;
}

.check input {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--accent);
}

.btn {
    border: 1px solid transparent;
    border-radius: 9px;
    min-height: 40px;
    padding: 8px 14px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 570;
    cursor: pointer;
    transition: transform .1s, background .15s, border-color .15s;
}

.btn:hover {
    background: #155be3;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn--secondary {
    background: #fff;
    border-color: var(--line-strong);
    color: var(--text);
}

.btn--secondary:hover {
    background: var(--surface-soft);
}

.btn--ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}

.btn--ghost:hover {
    background: #edf0f3;
    color: var(--text);
}

.btn--danger {
    background: #fff3f2;
    color: var(--red);
    border-color: #ffd5d2;
}

.btn--compact {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 13px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    display: inline-grid;
    place-items: center;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.icon-btn:hover {
    background: #edf0f3;
    color: var(--text);
}

.icon {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.form-error {
    min-height: 18px;
    color: var(--red);
    font-size: 13px;
}

.shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar);
    padding: 24px 15px 18px;
    display: flex;
    flex-direction: column;
    background: #fbfcfd;
    border-right: 1px solid var(--line);
}

.sidebar-head {
    padding: 0 9px 22px;
}

.company-picker {
    position: relative;
    margin-top: 16px;
}

.company-picker select {
    width: 100%;
    appearance: none;
    border: 0;
    border-radius: 8px;
    background: #f0f3f6;
    padding: 9px 29px 9px 10px;
    font-size: 12px;
    color: #3e4852;
    outline: none;
    cursor: pointer;
}

.company-picker::after {
    content: "⌄";
    position: absolute;
    right: 10px;
    top: 6px;
    color: var(--muted);
    pointer-events: none;
}

.nav {
    display: grid;
    gap: 4px;
}

.nav-item {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #65707b;
    font-weight: 510;
    text-align: left;
    cursor: pointer;
}

.nav-item:hover {
    background: #f0f3f6;
    color: var(--text);
}

.nav-item.is-active {
    background: #eaf1ff;
    color: #145adc;
}

.sidebar-bottom {
    margin-top: auto;
    display: grid;
    gap: 9px;
}

.admin-mode {
    padding: 10px 11px;
    border: 1px solid #d5e3ff;
    border-radius: 10px;
    background: #f1f6ff;
    color: #345a9b;
    font-size: 12px;
}

.main {
    margin-left: var(--sidebar);
    min-width: 0;
}

.topbar {
    min-height: 72px;
    padding: 14px 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, .88);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 35;
}

.topbar-title {
    min-width: 0;
}

.topbar-title h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 610;
    letter-spacing: -.015em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.topbar-title p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 7px;
}

.user-chip {
    max-width: 250px;
    padding: 6px 8px 6px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 9px;
}

.user-chip-text {
    min-width: 0;
}

.user-chip strong,
.user-chip small {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-chip strong {
    font-size: 12px;
    font-weight: 610;
}

.user-chip small {
    font-size: 10px;
    color: var(--muted);
}

.avatar {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #eaf1ff;
    color: #155bd8;
    font-size: 11px;
    font-weight: 700;
}

.mobile-menu {
    display: none;
}

.content {
    padding: 24px 25px 48px;
}

.page-head {
    margin-bottom: 18px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.page-head h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 610;
    letter-spacing: -.025em;
}

.page-head p {
    margin: 5px 0 0;
    color: var(--muted);
}

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

.notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #d8e4ff;
    border-radius: 10px;
    background: #f4f7ff;
    color: #35568d;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
}

.table-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 1px 0 rgba(20, 32, 43, .02);
}

.table-layout {
    display: block;
}

.table-toolbar {
    min-height: 56px;
    padding: 8px 11px 8px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--line);
}

.table-toolbar-label {
    margin-right: auto;
}

.table-toolbar-label strong {
    display: block;
    font-size: 13px;
    font-weight: 610;
}

.table-toolbar-label small {
    color: var(--muted);
    font-size: 11px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-color: #cbd2d9 transparent;
    scrollbar-width: thin;
}

.metrics-table {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    min-width: calc(var(--label) + var(--day) * 8);
    width: max-content;
    font-variant-numeric: tabular-nums;
}

.metrics-table th,
.metrics-table td {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.metrics-table tr > *:last-child {
    border-right: 0;
}

.metrics-table thead th {
    position: sticky;
    top: 72px;
    z-index: 15;
    height: 50px;
    background: #fafbfc;
}

.metrics-table .label-head,
.metrics-table .row-label {
    position: sticky;
    left: 0;
    z-index: 13;
    width: var(--label);
    min-width: var(--label);
    max-width: var(--label);
    background: #fff;
    box-shadow: 1px 0 0 var(--line);
}

.metrics-table .label-head {
    z-index: 22;
    padding: 10px 14px;
    color: var(--muted);
    text-align: left;
    font-size: 11px;
    font-weight: 570;
    letter-spacing: .03em;
    text-transform: uppercase;
    background: #fafbfc;
}

.date-head {
    width: var(--day);
    min-width: var(--day);
    padding: 5px 6px;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.date-head:hover,
.date-head.is-selected {
    background: #f0f5ff !important;
}

.date-head.is-today {
    box-shadow: inset 0 3px 0 var(--accent);
}

.date-weekday {
    color: var(--muted);
    font-size: 9px;
    font-weight: 650;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.date-number {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 590;
}

.date-head.is-bold .date-number,
.metrics-table tr.is-bold .metric-title {
    font-weight: 780;
}

.group-row th,
.group-row td {
    height: 34px;
    background: #f3f5f7;
}

.group-row .row-label {
    z-index: 14;
    background: #f3f5f7;
}

.group-cell {
    padding: 0;
}

.group-toggle {
    width: 100%;
    min-height: 33px;
    padding: 5px 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-weight: 650;
}

.group-toggle .chevron,
.metric-toggle .chevron {
    width: 15px;
    color: var(--muted);
    transition: transform .15s;
}

.group-toggle.is-collapsed .chevron,
.metric-toggle.is-collapsed .chevron {
    transform: rotate(-90deg);
}

.metric-row td,
.metric-row th {
    height: 42px;
}

.metric-row .row-label {
    padding: 0;
}

.metric-label-wrap {
    min-height: 41px;
    padding: 5px 8px;
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
}

.metric-label-wrap:hover {
    background: #fafbfc;
}

.metric-toggle {
    width: 22px;
    height: 26px;
    flex: 0 0 22px;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.metric-copy {
    min-width: 0;
}

.metric-title {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 580;
}

.metric-description {
    color: var(--muted);
    font-size: 9px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.scope-tag {
    padding: 1px 5px;
    border-radius: 999px;
    background: #eef1f4;
    color: #66717b;
    font-size: 9px;
    font-weight: 620;
}

.drag-handle {
    margin-left: auto;
    color: #a7afb7;
    cursor: grab;
    opacity: 0;
}

.edit-order .drag-handle,
.sortable-list .drag-handle {
    opacity: 1;
}

.branch-row th,
.branch-row td {
    height: 36px;
    background: #fff;
}

.branch-row .row-label {
    padding: 4px 10px 4px 36px;
    color: #56616c;
    font-size: 11px;
    font-weight: 450;
}

.branch-short {
    display: inline-flex;
    min-width: 29px;
    color: #87919b;
    font-size: 9px;
    font-weight: 650;
}

.value-td {
    position: relative;
    width: var(--day);
    min-width: var(--day);
    max-width: var(--day);
    padding: 0;
    background: #fff;
}

.is-selected-column {
    box-shadow: inset 2px 0 0 rgba(36, 107, 253, .18), inset -2px 0 0 rgba(36, 107, 253, .18);
}

.cell {
    position: relative;
    width: 100%;
    min-height: 35px;
    padding: 4px 15px 4px 6px;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    text-align: right;
    cursor: pointer;
}

.metric-row .cell {
    min-height: 41px;
}

.cell:hover {
    box-shadow: inset 0 0 0 2px #b8ccfb;
}

.cell.is-empty {
    color: #a4adb6;
}

.cell.is-aggregate {
    cursor: default;
    font-weight: 620;
}

.cell.is-aggregate:hover {
    box-shadow: none;
}

.cell.is-out-of-range {
    background: #d9352b !important;
    color: #fff !important;
}

.cell.trend-good-1 { background: rgba(31, 157, 98, .07); color: #155b3d; }
.cell.trend-good-2 { background: rgba(31, 157, 98, .12); color: #124f36; }
.cell.trend-good-3 { background: rgba(31, 157, 98, .18); color: #0f472f; }
.cell.trend-good-4 { background: rgba(31, 157, 98, .25); color: #0d3e2a; }
.cell.trend-good-5 { background: rgba(31, 157, 98, .34); color: #093722; }
.cell.trend-bad-1 { background: rgba(210, 58, 48, .07); color: #71302c; }
.cell.trend-bad-2 { background: rgba(210, 58, 48, .12); color: #702a26; }
.cell.trend-bad-3 { background: rgba(210, 58, 48, .18); color: #68231f; }
.cell.trend-bad-4 { background: rgba(210, 58, 48, .25); color: #5f1e1a; }
.cell.trend-bad-5 { background: rgba(210, 58, 48, .34); color: #551713; }

.cell.is-saving::after {
    content: "";
    position: absolute;
    inset: 4px 4px auto auto;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1s infinite;
}

.cell-value {
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 11px;
}

.cell-unit {
    margin-left: 3px;
    color: currentColor;
    opacity: .58;
    font-size: 8px;
}

.cell-meta {
    color: currentColor;
    opacity: .66;
    font-size: 8px;
}

.comment-mark {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #5b7dc4;
    cursor: pointer;
}

.comment-mark::before {
    content: "";
    position: absolute;
    top: -4px;
    right: -4px;
    border-style: solid;
    border-width: 0 7px 7px 0;
    border-color: transparent #5c84db transparent transparent;
}

.cell-editor {
    width: 100%;
    min-height: 35px;
    padding: 3px;
    display: flex;
    align-items: center;
}

.cell-input {
    width: 100%;
    min-width: 0;
    height: 29px;
    padding: 3px 5px;
    border: 2px solid var(--accent);
    border-radius: 6px;
    outline: none;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.footer-row th,
.footer-row td {
    height: 40px;
    background: #fafbfc;
}

.footer-row .row-label {
    z-index: 14;
    padding: 8px 14px;
    background: #fafbfc;
    color: var(--muted);
    font-size: 11px;
    font-weight: 580;
}

.missing-count {
    padding: 3px;
    text-align: center;
    color: var(--muted);
    font-size: 9px;
}

.missing-count strong {
    display: block;
    color: var(--text);
    font-size: 12px;
}

.missing-count.is-overdue strong,
.missing-count.is-overdue {
    color: var(--red);
}

.empty-state {
    padding: 70px 24px;
    text-align: center;
    color: var(--muted);
}

.cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    padding: 17px;
}

.card h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 620;
}

.card p {
    color: var(--muted);
}

.settings-layout {
    display: grid;
    grid-template-columns: 195px minmax(0, 1fr);
    gap: 18px;
}

.settings-tabs {
    display: grid;
    align-content: start;
    gap: 3px;
    position: sticky;
    top: 96px;
}

.settings-tab {
    min-height: 39px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    text-align: left;
    cursor: pointer;
}

.settings-tab:hover,
.settings-tab.is-active {
    background: #eaf1ff;
    color: #145adc;
}

.settings-panel {
    min-width: 0;
}

.panel-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    padding: 20px;
}

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

.panel-head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 610;
}

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

.form-grid .span-2 {
    grid-column: 1 / -1;
}

.weekday-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.weekday-checks .check {
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.settings-logo {
    max-width: 150px;
    max-height: 44px;
    object-fit: contain;
}

.advanced-grid {
    margin-top: 14px;
}

.entity-list {
    display: grid;
    gap: 8px;
}

.entity-row {
    min-height: 60px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
}

.entity-row[draggable="true"] {
    cursor: grab;
}

.entity-row.is-dragging {
    opacity: .42;
}

.entity-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #f0f3f6;
    color: #66717d;
    font-size: 11px;
    font-weight: 700;
}

.entity-main {
    min-width: 0;
    flex: 1;
}

.entity-main strong,
.entity-main small {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.entity-main strong {
    font-size: 13px;
    font-weight: 600;
}

.entity-main small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.badge {
    padding: 3px 7px;
    border-radius: 999px;
    background: #edf0f3;
    color: #66717b;
    font-size: 10px;
    font-weight: 610;
    white-space: nowrap;
}

.badge--active {
    background: #e9f7f0;
    color: #137449;
}

.badge--inactive {
    background: #f2f3f4;
    color: #77808a;
}

.badge--archived {
    background: #fff0ef;
    color: #ad3028;
}

.audit-list {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.audit-row {
    padding: 13px 15px;
    display: grid;
    grid-template-columns: 145px minmax(150px, .7fr) minmax(240px, 1.6fr);
    gap: 14px;
    border-bottom: 1px solid var(--line);
    align-items: start;
}

.audit-row:last-child {
    border-bottom: 0;
}

.audit-time,
.audit-user,
.audit-detail {
    min-width: 0;
}

.audit-time {
    color: var(--muted);
    font-size: 11px;
}

.audit-user strong,
.audit-user small {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.audit-user small {
    color: var(--muted);
    font-size: 10px;
}

.audit-detail strong {
    display: block;
    font-size: 12px;
}

.audit-change {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    word-break: break-word;
}

.modal-layer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(19, 29, 40, .36);
    backdrop-filter: blur(3px);
}

.modal {
    width: min(650px, 100%);
    max-height: min(850px, calc(100vh - 40px));
    overflow: auto;
    border-radius: 15px;
    background: #fff;
    box-shadow: var(--shadow);
}

.modal--wide {
    width: min(820px, 100%);
}

.modal-head {
    padding: 17px 19px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(10px);
}

.modal-head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 620;
}

.modal-head .icon-btn {
    margin-left: auto;
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    padding: 13px 19px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--line);
    position: sticky;
    bottom: 0;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(10px);
}

.section-title {
    margin: 20px 0 10px;
    color: #3f4a55;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.section-title:first-child {
    margin-top: 0;
}

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

.choice-grid .check {
    min-height: 40px;
    padding: 8px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.help {
    color: var(--muted);
    font-size: 11px;
}

details.advanced {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 13px;
}

details.advanced summary {
    color: #46525e;
    cursor: pointer;
    font-weight: 570;
}

.history-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.history-row {
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    font-size: 11px;
}

.history-row strong {
    display: block;
    margin-bottom: 3px;
}

.toast-root {
    position: fixed;
    z-index: 200;
    right: 18px;
    bottom: 18px;
    width: min(380px, calc(100vw - 36px));
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 14px;
    border: 1px solid #dce1e6;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 30px rgba(22, 34, 46, .16);
    animation: toast-in .18s ease-out;
    pointer-events: auto;
    font-size: 13px;
}

.toast--error {
    border-color: #ffc9c5;
    color: #9b2d26;
}

.toast--success {
    border-color: #bce6d2;
    color: #126b43;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(7px); }
}

.fullscreen-table .sidebar,
.fullscreen-table .topbar {
    display: none;
}

.fullscreen-table .main {
    margin: 0;
}

.fullscreen-table .content {
    padding: 0;
}

.fullscreen-table .page-head,
.fullscreen-table .notice {
    display: none;
}

.fullscreen-table .table-card {
    border: 0;
    border-radius: 0;
}

.fullscreen-table .table-toolbar {
    position: sticky;
    top: 0;
    z-index: 36;
    background: #fff;
}

.fullscreen-table .metrics-table thead th {
    top: 56px;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 1100px) {
    :root {
        --sidebar: 210px;
        --label: 228px;
        --day: 108px;
    }

    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}

@media (max-width: 760px) {
    :root {
        --label: 164px;
        --day: 104px;
    }

    .login-page {
        display: block;
    }

    .login-panel {
        min-height: 100vh;
        border: 0;
        padding: 34px 24px;
    }

    .login-card {
        margin-top: 62px;
    }

    .login-copy {
        display: none;
    }

    .sidebar {
        width: min(280px, 86vw);
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: var(--shadow);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 39;
        background: rgba(20, 30, 40, .32);
    }

    .sidebar-backdrop.is-open {
        display: block;
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        min-height: 62px;
        padding: 10px 12px;
    }

    .mobile-menu {
        display: inline-grid;
        flex: 0 0 38px;
    }

    .topbar-title h1 {
        font-size: 16px;
    }

    .topbar-title p,
    .user-chip-text {
        display: none;
    }

    .user-chip {
        padding: 4px;
        border: 0;
    }

    .content {
        padding: 17px 12px 36px;
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-head h2 {
        font-size: 20px;
    }

    .table-card {
        margin-inline: -12px;
        border-radius: 0;
        border-inline: 0;
    }

    .table-layout {
        display: block;
    }

    .table-toolbar {
        padding-inline: 11px;
    }

    .table-toolbar .btn span {
        display: none;
    }

    .metrics-table thead th {
        top: 62px;
    }

    .metric-label-wrap {
        padding-left: 6px;
    }

    .metric-description {
        display: none;
    }

    .branch-row .row-label {
        padding-left: 34px;
    }

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

    .settings-layout {
        display: block;
    }

    .settings-tabs {
        position: static;
        margin-bottom: 13px;
        display: flex;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .settings-tab {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .panel-card {
        padding: 15px;
    }

    .form-grid,
    .choice-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2 {
        grid-column: auto;
    }

    .entity-row {
        flex-wrap: wrap;
    }

    .audit-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .modal-layer {
        align-items: end;
        padding: 0;
    }

    .modal,
    .modal--wide {
        width: 100%;
        max-height: 92vh;
        border-radius: 15px 15px 0 0;
    }

    .fullscreen-table .metrics-table thead th {
        top: 56px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .001ms !important;
    }
}
