:root {
    --page: #fafafa;
    --card: #ffffff;
    --ink: #101010;
    --muted: #747474;
    --line: #e0e0e0;
    --accent: #E9204F;
    --accent-hover: #d51542;
    --accent-press: #c7143e;
    --dark: #101010;
    --danger-bg: #fde8ee;
    --font: "Roboto Condensed", "Trade Gothic", sans-serif;
    --display: "Poppins", "Avant Grade", sans-serif;
}

* { box-sizing: border-box; }

html { font-size: 15px; }
html[data-text="14"] { font-size: 14px; }
html[data-text="15"] { font-size: 15px; }
html[data-text="17"] { font-size: 17px; }
html[data-text="19"] { font-size: 19px; }

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font);
    font-size: 1rem;
    color: var(--muted);
    background: var(--page);
    letter-spacing: -0.01em;
}

.login-body {
    font-size: 17px;
    min-height: 100vh;
    background: #0c0c0e;
    color: #d0d0d0;
}

h1, .primary, .secondary, .eyebrow, .text-button, .text-toggle, .safety strong {
    font-family: var(--display);
}

.wordmark {
    font-family: var(--display);
    font-weight: 800;
    font-size: 42px;
    line-height: 1;
    letter-spacing: -0.045em;
    color: var(--ink);
}

.wordmark .accent { color: var(--accent); }

.brand-panel .wordmark { color: #fff; }

.login-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 18% 80%, rgba(233, 32, 79, 0.16), transparent 46%),
        #0c0c0e;
}

.login-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: radial-gradient(ellipse at 28% 45%, #000 10%, transparent 68%);
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(18px);
    background: radial-gradient(circle, rgba(233, 32, 79, 0.72), rgba(233, 32, 79, 0) 68%);
}

.orb-a {
    width: 460px;
    height: 460px;
    left: -120px;
    top: 8%;
    animation: drift-a 16s ease-in-out infinite;
}

.orb-b {
    width: 560px;
    height: 560px;
    left: 12%;
    bottom: -220px;
    opacity: 0.75;
    animation: drift-b 20s ease-in-out infinite;
}

.orb-c {
    width: 280px;
    height: 280px;
    right: 6%;
    top: 12%;
    opacity: 0.45;
    animation: drift-c 18s ease-in-out infinite;
}

.login-layout {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(280px, 1.05fr) minmax(320px, 0.95fr);
    align-items: center;
}

.brand-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 28px;
    padding: 64px 72px;
    color: #fff;
}

.brand-badge {
    width: 104px;
    height: 104px;
    display: grid;
    place-items: center;
    border-radius: 26px;
    background: var(--accent);
    box-shadow: 0 18px 50px rgba(233, 32, 79, 0.38);
}

.brand-badge img {
    display: block;
    width: 68px;
    height: 68px;
}

.brand-copy { position: relative; }

.rule {
    display: block;
    width: 70px;
    height: 3px;
    margin: 22px 0 16px;
    background: var(--accent);
}

.brand-copy p {
    margin: 0;
    color: #fff;
    font-family: var(--display);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: -0.03em;
}

.login-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 48px 40px 12px;
}

.login-card {
    width: min(440px, 100%);
    padding: 36px 32px 28px;
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

.oauth-note {
    margin: -12px 0 22px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.45;
}

.oauth-meta {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.login-body .field input,
.login-body .primary,
.login-body .secondary {
    border-radius: 10px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 28px;
    color: var(--ink);
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.05;
}

.alert {
    margin: -8px 0 18px;
    padding: 12px 14px;
    background: var(--danger-bg);
    color: var(--accent);
    border-left: 3px solid var(--accent);
    font-size: 15px;
}

.field {
    display: block;
    margin-bottom: 16px;
}

.field > span:not(.field-head) {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
}

.field-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.field-head label {
    margin: 0;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
}

.field input {
    width: 100%;
    height: 50px;
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 0 14px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

.field input:focus {
    border-color: var(--accent);
}

.field input[aria-invalid="true"] {
    border-color: var(--accent);
}

.text-toggle,
.text-button {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
    padding: 0;
    white-space: nowrap;
    cursor: pointer;
}

.text-toggle:hover,
.text-button:hover { color: var(--accent-hover); }

.field-error {
    display: block;
    margin-top: 6px;
    color: var(--accent);
    font-size: 14px;
}

.safety {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin: 8px 0 22px;
    padding: 14px 0 0;
    border-top: 1px solid var(--line);
}

.safety.is-invalid strong,
.safety.is-invalid small.field-error { color: var(--accent); }

.safety input {
    width: 18px;
    height: 18px;
    margin-top: 3px;
    accent-color: var(--accent);
}

.safety strong {
    display: block;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
}

.safety small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    line-height: 1.35;
    font-size: 14px;
}

.primary,
.secondary {
    display: flex;
    width: 100%;
    height: 52px;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    text-decoration: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.primary {
    border: 2px solid var(--accent);
    background: var(--accent);
    color: #fff;
}

.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary:focus { background: var(--accent-press); border-color: var(--accent-press); }
.primary:disabled { opacity: 0.7; cursor: progress; }

.secondary {
    border: 2px solid var(--accent);
    background: transparent;
    color: var(--ink);
}

.secondary:hover {
    background: var(--accent);
    color: #fff;
}

.split {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 26px 0 14px;
    color: #acacac;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.split::before,
.split::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

.app-body { background: var(--page); }

.topbar {
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar .wordmark { font-size: 26px; }

.home {
    width: min(760px, calc(100% - 40px));
    margin: 48px auto;
}

.home h1 { margin-bottom: 12px; }

@keyframes drift-a {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(10%, -8%, 0) scale(1.12); }
}

@keyframes drift-b {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(6%, 8%, 0) scale(1.08); }
}

@keyframes drift-c {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(-12%, 10%, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .orb { animation: none; }
}

@media (max-width: 860px) {
    .login-layout {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    .brand-panel {
        flex-direction: row;
        align-items: center;
        gap: 16px;
        padding: 28px 20px 0;
    }
    .brand-badge {
        width: 64px;
        height: 64px;
        border-radius: 16px;
        flex: none;
    }
    .brand-badge img { width: 42px; height: 42px; }
    .brand-panel .wordmark { font-size: 26px; }
    .rule { width: 42px; margin: 10px 0 8px; }
    .brand-copy p { font-size: 16px; }
    .login-main { padding: 22px 16px 36px; align-items: flex-start; }
    .login-card { padding: 26px 20px 22px; border-radius: 18px; }
    .login-body h1 { font-size: 32px; }
}

.shell {
    display: flex;
    min-height: 100vh;
    background: var(--page);
    color: var(--muted);
}

.sidebar {
    width: 268px;
    flex: none;
    background: #fff;
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    padding: 22px 14px 36px;
}

.sidebar .wordmark {
    display: inline-block;
    margin: 4px 12px 22px;
    font-size: calc(26 / 17 * 1rem);
    text-decoration: none;
}

.side-nav { display: flex; flex-direction: column; }

.nav-label {
    margin: 18px 12px 4px;
    color: var(--muted);
    font-size: calc(12 / 17 * 1rem);
    font-weight: 400;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.nav-link,
.nav-sub a {
    display: block;
    text-decoration: none;
}

.nav-link {
    padding: 8px 12px;
    color: var(--ink);
    font-weight: 400;
    font-size: calc(16 / 17 * 1rem);
}

.nav-link:hover,
.nav-sub a:hover { color: var(--accent); }

.nav-link.is-active {
    background: var(--danger-bg);
    color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-row {
    display: flex;
    align-items: stretch;
}

.nav-row .nav-link { flex: 1; min-width: 0; }

.nav-row.is-active {
    background: var(--danger-bg);
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-row.is-active .nav-link {
    background: transparent;
    box-shadow: none;
}

.nav-toggle {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(34 / 17 * 1rem);
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: var(--font);
}

.nav-toggle svg {
    display: block;
    width: 10px;
    height: 10px;
    transition: transform 0.15s ease;
}

.nav-group.is-open .nav-toggle svg { transform: rotate(90deg); }

.nav-toggle:hover,
.nav-row.is-active .nav-toggle { color: var(--accent); }

.nav-toggle:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}

.nav-group:not(.is-open) .nav-sub { display: none; }

.nav-sub {
    list-style: none;
    margin: 4px 0 12px;
    padding: 0;
}

.nav-sub a {
    padding: 9px 12px 9px 24px;
    color: var(--muted);
    font-size: calc(15 / 17 * 1rem);
}

.nav-sub a::before {
    content: "–";
    margin-right: 8px;
}

.nav-sub a.is-active { color: var(--accent); }

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

.shell .topbar { height: 68px; }

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

.user-link {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-decoration: none;
    line-height: 1.15;
}

.user-name {
    max-width: 220px;
    overflow: hidden;
    color: var(--ink);
    font-weight: 400;
    font-size: calc(15 / 17 * 1rem);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role { color: var(--muted); font-size: calc(13 / 17 * 1rem); }

.user-duty { flex: none; }

.duty-toggle {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.duty-toggle:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}

.duty {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: calc(12 / 17 * 1rem);
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}

.duty-working { color: #146c36; border-color: #b7e0c6; background: #eef8f2; }
.duty-idle { color: #8a5a00; border-color: #f0ddb0; background: #fff8e8; }
.duty-offline { color: var(--muted); background: var(--page); }
.duty.is-unset { border-style: dashed; }

.duty-who {
    margin: -4px 0 14px;
    color: var(--ink);
    font-weight: 700;
}

.col-duty { width: 220px; }

.duty-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    max-width: 240px;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--line);
    background: #fff;
    color: inherit;
    font: inherit;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
}

.duty-row:hover,
.duty-row:focus-visible {
    border-color: var(--ink);
    outline: none;
}

.duty-row-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: calc(13 / 17 * 1rem);
}

.duty-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bdbdbd;
}

.duty-row-working .duty-row-main { color: #146c36; }
.duty-row-working .duty-dot { background: #1f9d55; }
.duty-row-idle .duty-row-main { color: #8a5a00; }
.duty-row-idle .duty-dot { background: #e0a106; }
.duty-row-offline .duty-row-main { color: var(--muted); font-weight: 400; }

.duty-row-note {
    display: block;
    max-width: 220px;
    overflow: hidden;
    color: var(--muted);
    font-size: calc(13 / 17 * 1rem);
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.duty-history-message {
    color: var(--ink);
    overflow-wrap: anywhere;
}

.duty-board {
    margin: 18px 0;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
}

.usage-board {
    margin: 18px 0;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
}

.usage-board > .hint { margin: -4px 0 14px; }

.usage-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 0 0 16px;
}

.usage-stats div {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: var(--page);
}

.usage-stats dt {
    margin: 0;
    font-size: calc(11 / 17 * 1rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.usage-stats dd {
    margin: 4px 0 0;
    color: var(--ink);
    font-size: calc(20 / 17 * 1rem);
    font-weight: 700;
}

.usage-heat-scroll { overflow-x: auto; }

.usage-heat {
    display: grid;
    grid-template-columns: 2.1rem repeat(24, minmax(0, 1fr));
    gap: 2px;
    align-items: center;
}

.usage-heat-hour,
.usage-heat-day {
    color: var(--muted);
    font-size: calc(10 / 17 * 1rem);
    font-weight: 700;
    line-height: 1;
}

.usage-heat-hour { text-align: center; }

.usage-cell {
    height: 14px;
    border: 1px solid #f2f2f2;
    border-radius: 2px;
    background: #fff;
}

.usage-cell.is-1 { background: rgba(233, 32, 79, 0.18); }
.usage-cell.is-2 { background: rgba(233, 32, 79, 0.38); }
.usage-cell.is-3 { background: rgba(233, 32, 79, 0.58); }
.usage-cell.is-4 { background: rgba(233, 32, 79, 0.78); }
.usage-cell.is-5 { background: #E9204F; }

.usage-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 12px;
    font-size: calc(11 / 17 * 1rem);
}

.usage-legend .usage-cell { width: 14px; }

.duty-now {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 12px;
}

.duty-history {
    list-style: none;
    margin: 0;
    padding: 0;
}

.duty-history li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.duty-history .hint {
    flex-basis: 100%;
    margin: 0;
}

.text-size {
    display: inline-flex;
    flex: none;
    border: 1px solid var(--line);
}

.text-size button {
    height: 32px;
    min-width: 34px;
    padding: 0 8px;
    border: 0;
    border-right: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-family: var(--display);
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.text-size button:last-child { border-right: 0; }
.text-size button[data-text-step="down"] { font-size: 12px; }
.text-size button[data-text-step="up"] { font-size: 16px; }
.text-size button:hover { background: var(--danger-bg); color: var(--accent); }
.text-size button:disabled {
    background: #fff;
    color: #bdbdbd;
    cursor: default;
}
.text-size button:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}

.menu-toggle {
    display: none;
    height: calc(40 / 17 * 1rem);
    padding: 0 12px;
    border: 2px solid var(--ink);
    background: #fff;
    color: var(--ink);
    font-family: var(--font);
    font-size: calc(14 / 17 * 1rem);
    font-weight: 400;
    cursor: pointer;
}

.backdrop { display: none; }

body.is-loading::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    z-index: 70;
}

.content { padding: 28px 32px 72px; }
.content:focus { outline: none; }
.content.is-loading { opacity: 0.55; }

.content h1 {
    margin: 0 0 6px;
    font-size: calc(32 / 17 * 1rem);
}

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

.lead { margin: 0; max-width: 46rem; }
.lead code { word-break: break-all; }

.list-toggle { margin: -8px 0 14px; }
.list-toggle a { color: var(--accent); text-decoration: none; }
.list-toggle a:hover { text-decoration: underline; }

.crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: calc(14 / 17 * 1rem);
}

.crumbs a { color: var(--ink); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.alert-ok {
    background: #eef8f1;
    color: #146c36;
    border-left-color: #146c36;
}

.note {
    margin: 0;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-top: 28px;
    border-bottom: 1px solid var(--line);
}

.tabs a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin-bottom: -1px;
    padding: 0 16px;
    border-top: 3px solid transparent;
    border-right: 1px solid transparent;
    border-left: 1px solid transparent;
    border-bottom: 0;
    color: var(--muted);
    text-decoration: none;
}

.tabs a:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}

.tabs a:hover { color: var(--ink); }

.tabs a[aria-current="page"] {
    background: #fff;
    border-color: var(--line);
    border-top: 3px solid var(--accent);
    color: var(--ink);
}

.tab-count {
    color: var(--muted);
    font-size: calc(13 / 17 * 1rem);
}

.tabs a[aria-current="page"] .tab-count { color: var(--accent); }

.tab-panel {
    margin-top: 0;
    padding: 16px 16px 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-top: 0;
}

.tab-panel .lead { margin-bottom: 14px; }

.block { margin-top: 28px; }

.tab-panel.block { margin-top: 0; }

.block h2 {
    margin: 0 0 12px;
    color: var(--ink);
    font-family: var(--display);
    font-size: calc(18 / 17 * 1rem);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.card {
    display: block;
    min-height: 112px;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    text-decoration: none;
}

.card:hover { border-color: var(--accent); }

.card strong {
    display: block;
    margin-bottom: 8px;
    color: var(--ink);
    font-family: var(--display);
    font-size: calc(18 / 17 * 1rem);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.card span { color: var(--muted); font-size: calc(15 / 17 * 1rem); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: calc(46 / 17 * 1rem);
    padding: 0 calc(16 / 17 * 1rem);
    border: 2px solid var(--accent);
    border-radius: 0;
    background: var(--accent);
    color: #fff;
    font-family: var(--display);
    font-size: calc(15 / 17 * 1rem);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn:focus { background: var(--accent-press); border-color: var(--accent-press); }

.btn-ghost {
    background: #fff;
    color: var(--ink);
}

.btn-ghost:hover { background: var(--danger-bg); color: var(--accent); }

.btn-danger {
    background: #fff;
    color: var(--accent);
}

.btn-small { height: calc(36 / 17 * 1rem); padding: 0 calc(10 / 17 * 1rem); font-size: calc(14 / 17 * 1rem); }

.table-wrap {
    background: #fff;
    border: 1px solid var(--line);
    overflow: visible;
}

.data {
    width: 100%;
    border-collapse: collapse;
}

.data th,
.data td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    color: var(--ink);
}

.data th {
    color: var(--muted);
    font-size: calc(11 / 17 * 1rem);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.data tr:last-child td { border-bottom: 0; }

.col-dot { width: 34px; text-align: center; }
.col-actions { width: 1%; text-align: right; white-space: nowrap; }

.menu-drop { position: relative; display: inline-block; }

.menu-drop > .btn {
    height: calc(30 / 17 * 1rem);
    border-color: var(--line);
    background: #fff;
    color: var(--ink);
    font-family: var(--font);
    font-weight: 400;
}

.menu-drop > .btn::after {
    content: "";
    width: 0;
    height: 0;
    margin-left: 8px;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 4px solid currentColor;
}

.menu-drop > .btn:hover,
.menu-drop > .btn:focus,
.menu-drop.is-open > .btn {
    border-color: var(--ink);
    background: #fff;
    color: var(--ink);
}

.menu-drop-panel {
    position: fixed;
    z-index: 20;
    min-width: 148px;
    margin: 0;
    padding: 4px 0;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 12px 28px rgba(16, 16, 16, 0.12);
}

.menu-drop-panel[hidden] { display: none; }

.menu-drop-panel form { margin: 0; }

.menu-drop-panel a,
.menu-drop-panel button {
    display: block;
    width: 100%;
    padding: 7px 12px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: calc(14 / 17 * 1rem);
    font-weight: 400;
    line-height: 1.3;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menu-drop-panel a:hover,
.menu-drop-panel button:hover,
.menu-drop-panel a:focus,
.menu-drop-panel button:focus {
    background: var(--page);
    outline: none;
}

.menu-drop-panel .is-danger { color: var(--accent); }
.menu-drop-panel .is-danger:hover,
.menu-drop-panel .is-danger:focus { background: var(--danger-bg); }

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c8c8c8;
}

.dot-online { background: #1f9d55; }
.dot-away { background: #d4a017; }
.dot-offline { background: var(--accent); }
.dot-none { background: #c8c8c8; }

.status {
    display: inline-block;
    padding: 2px 8px;
    font-size: calc(14 / 17 * 1rem);
    font-weight: 400;
}

.status-ok { color: #146c36; }
.status-warn { color: #8a5a00; }
.status-off { color: var(--accent); }

.form-card {
    max-width: 640px;
    padding: 22px 22px 8px;
    background: #fff;
    border: 1px solid var(--line);
}

.field select {
    width: 100%;
    height: 50px;
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 0 14px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

.field select:focus { border-color: var(--accent); }
.field input[readonly] { background: #f6f6f6; color: var(--muted); }

.field-head > span {
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
}

.shell .eyebrow,
.dialog .eyebrow {
    font-family: var(--font);
    font-size: calc(13 / 17 * 1rem);
    font-weight: 400;
}

.shell .alert { font-size: calc(15 / 17 * 1rem); }

.shell .field > span:not(.field-head),
.shell .field-head label,
.shell .field-head > span {
    font-size: calc(15 / 17 * 1rem);
    font-weight: 400;
}

.shell .field input,
.shell .field select {
    height: calc(50 / 17 * 1rem);
    padding: 0 calc(14 / 17 * 1rem);
}

.shell .text-toggle,
.shell .text-button,
.shell .field-error,
.shell .hint {
    font-family: var(--font);
    font-size: calc(14 / 17 * 1rem);
    font-weight: 400;
}

.hint {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 0 18px;
}

.facts {
    max-width: 720px;
    margin: 0;
    background: #fff;
    border: 1px solid var(--line);
}

.facts > div {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.facts > div:last-child { border-bottom: 0; }

.facts dt {
    margin: 0;
    color: var(--muted);
    font-weight: 400;
}

.facts dd {
    margin: 0;
    color: var(--ink);
}

.perm-tree {
    background: #fff;
    border: 1px solid var(--line);
}

.perm-branch-bar {
    display: grid;
    grid-template-columns: 28px minmax(0, 1.4fr) auto auto auto;
    align-items: center;
    gap: 8px 14px;
    min-height: 48px;
    padding: 8px 12px 8px 8px;
    border-bottom: 1px solid var(--line);
}

.perm-branch-bar:hover { background: var(--page); }

.perm-branch:last-child:not(.is-open) > .perm-branch-bar,
.perm-branch:last-child:not(:has(.perm-children)) > .perm-branch-bar {
    border-bottom: 0;
}

.perm-children {
    margin-left: 22px;
    border-left: 1px solid var(--line);
}

.perm-branch:not(.is-open) > .perm-children { display: none; }

.perm-tree-toggle,
.perm-tree-spacer {
    width: 28px;
    height: 28px;
    flex: none;
}

.perm-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.perm-tree-toggle svg {
    display: block;
    width: 10px;
    height: 10px;
    transition: transform 0.15s ease;
}

.perm-branch.is-open > .perm-branch-bar .perm-tree-toggle svg { transform: rotate(90deg); }

.perm-tree-toggle:hover {
    border-color: var(--line);
    background: #fff;
    color: var(--accent);
}

.perm-tree-toggle:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}

.perm-tree-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.perm-tree-name {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: calc(16 / 17 * 1rem);
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}

.perm-tree-name:hover { color: var(--accent); }

.perm-tree-kids {
    display: none;
    flex: none;
    color: var(--muted);
    font-size: calc(13 / 17 * 1rem);
}

.perm-branch:not(.is-open) > .perm-branch-bar .perm-tree-kids { display: inline; }

.perm-tree-meta,
.perm-tree-status {
    margin: 0;
    font-size: calc(14 / 17 * 1rem);
    white-space: nowrap;
}

.perm-tree-meta { color: var(--muted); }

.perm-tree-status { color: var(--ink); }

.perm-tree-status.is-off { color: var(--muted); }

.perm-grid {
    display: grid;
    grid-template-columns: minmax(0, 720px);
    gap: 14px;
    align-items: start;
}

.perm-card {
    min-width: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-top: 3px solid var(--ink);
}

.perm-card-head {
    border-bottom: 1px solid var(--line);
}

.perm-card:not(.is-open) .perm-card-head { border-bottom: 0; }

.perm-card-head h2,
.perm-card-head h3 {
    width: 100%;
    margin: 0;
    color: var(--ink);
    font-family: var(--display);
    font-size: calc(18 / 17 * 1rem);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.perm-card-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 14px 16px 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-align: left;
    cursor: pointer;
}

.perm-card-toggle:hover { background: var(--page); }

.perm-card-toggle:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}

.perm-card-toggle svg {
    display: block;
    flex: none;
    width: 10px;
    height: 10px;
    color: var(--muted);
    transition: transform 0.15s ease;
}

.perm-card.is-open .perm-card-toggle svg { transform: rotate(90deg); }

.perm-card-toggle:hover svg { color: var(--accent); }

.perm-card-heading {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.perm-card-name { overflow-wrap: anywhere; }

.perm-card-mount {
    margin-top: 4px;
    color: var(--muted);
    font-family: var(--font);
    font-size: calc(14 / 17 * 1rem);
    font-weight: 400;
    letter-spacing: 0;
}

.perm-card-body[hidden] { display: none; }

.perm-count {
    margin: 0 0 0 auto;
    color: var(--muted);
    font-family: var(--font);
    font-size: calc(14 / 17 * 1rem);
    font-weight: 400;
    letter-spacing: 0;
    white-space: nowrap;
}

.perm-card:has(.perm-check input:checked) {
    border-top-color: var(--accent);
}

.perm-card:has(.perm-check input:checked) .perm-count {
    color: var(--accent);
}

.perm-check {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    font-weight: 400;
    cursor: pointer;
}

.perm-card .perm-check:last-child { border-bottom: 0; }

.perm-check:hover { background: var(--page); }

.perm-check:has(input:checked) {
    background: var(--danger-bg);
    box-shadow: inset 3px 0 0 var(--accent);
}

.perm-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
}

.perm-all {
    background: var(--page);
}

.perm-keys {
    list-style: none;
    margin: 0;
    padding: 0;
}

.perm-keys li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}

.perm-keys li:last-child { border-bottom: 0; }

.perm-keys small {
    color: var(--muted);
    font-size: calc(13 / 17 * 1rem);
}

.perm-add {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    max-width: 720px;
    margin: 0 0 14px;
}

.perm-add .field {
    flex: 1 1 240px;
    min-width: 0;
    margin: 0;
}

.perm-add .btn { flex: 0 0 auto; }

.member-open { margin-bottom: 14px; }

.member-picker .dialog-panel {
    width: min(480px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
}

.member-picker .field { margin-top: 16px; }

.user-quick .dialog-panel {
    width: min(480px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
}

.user-quick form .field:first-of-type { margin-top: 16px; }

.member-results {
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--line);
}

.member-result {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 12px 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.member-result:last-of-type { border-bottom: 0; }

.member-result[hidden] { display: none; }

.member-result span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.member-result small {
    flex: none;
    color: var(--muted);
    font-size: calc(13 / 17 * 1rem);
}

.member-result:hover,
.member-result[aria-selected="true"] {
    background: var(--danger-bg);
    box-shadow: inset 3px 0 0 var(--accent);
}

.member-result:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}

.member-empty {
    margin: 0;
    padding: 14px;
    color: var(--muted);
}

.member-picker .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.detail-list {
    list-style: none;
    max-width: 720px;
    margin: 0;
    padding: 0;
    background: #fff;
    border: 1px solid var(--line);
}

.detail-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.detail-list li:last-child { border-bottom: 0; }

.detail-list strong {
    font-weight: 400;
    color: var(--ink);
}

.detail-list span { color: var(--muted); }

.pager {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-top: 14px;
}

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

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 860px) {
    .table-wrap { overflow: visible; }
    .data { min-width: 0; }
    .data thead { display: none; }
    .data tbody tr {
        display: grid;
        grid-template-columns: 16px 1fr;
        grid-template-areas:
            "dot name"
            "dot type"
            "dot status"
            "actions actions";
        gap: 2px 10px;
        padding: 8px 10px;
        border-bottom: 1px solid var(--line);
    }
    .data td {
        display: block;
        width: auto;
        border: 0;
        padding: 0;
    }
    .data.data-users tbody tr {
        grid-template-areas:
            "dot name"
            "dot duty"
            "dot type"
            "dot status"
            "actions actions";
    }
    .data td:nth-child(1) { grid-area: dot; align-self: center; }
    .data td:nth-child(2) { grid-area: name; }
    .data td:nth-child(3) { grid-area: type; color: var(--muted); }
    .data td:nth-child(4) { grid-area: status; }
    .data td:nth-child(5) { grid-area: actions; margin-top: 6px; text-align: left; }
    .data.data-users td:nth-child(2) { grid-area: name; color: var(--ink); }
    .data.data-users td:nth-child(3) { grid-area: duty; color: var(--ink); }
    .data.data-users td:nth-child(4) { grid-area: type; color: var(--muted); }
    .data.data-users td:nth-child(5) { grid-area: status; }
    .data.data-users td:nth-child(6) { grid-area: actions; margin-top: 6px; text-align: left; }

    .menu-toggle { display: inline-flex; }
    .sidebar {
        position: fixed;
        z-index: 30;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }
    .shell.is-open .sidebar { transform: none; }
    .backdrop {
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(16, 16, 16, 0.45);
    }
    .shell.is-open .backdrop { display: block; }
    .content { padding: 20px 16px 48px; }
    .usage-heat { min-width: 520px; }
    .content h1 { font-size: calc(28 / 17 * 1rem); }
    .page-head { flex-direction: column; align-items: flex-start; }
    .facts > div { grid-template-columns: 1fr; gap: 4px; }
    .detail-list li { flex-direction: column; align-items: flex-start; gap: 4px; }
    .shell .topbar { padding: 0 12px; }
    .user-role { display: none; }
    .topbar-user { gap: 8px; min-width: 0; }
    .user-link { min-width: 0; }
    .user-name { max-width: 96px; }
    .topbar .duty { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
    .text-size button { min-width: 30px; padding: 0 6px; }
}

body.dialog-open { overflow: hidden; }

.dialog[hidden],
.dialog [hidden] { display: none; }

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

.page-actions form { margin: 0; }

.search-line {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
}

.search-line input[type="search"] {
    flex: 1 1 220px;
    min-width: 0;
    height: calc(50 / 17 * 1rem);
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 0 calc(14 / 17 * 1rem);
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

.search-line input[type="search"]:focus { border-color: var(--accent); }

.search-line select {
    flex: 1 1 220px;
    min-width: 0;
    height: calc(50 / 17 * 1rem);
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 0 calc(14 / 17 * 1rem);
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

.search-line select:focus { border-color: var(--accent); }

.user-filters {
    margin: 0 0 14px;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--line);
}

.user-filters .search-line {
    align-items: center;
    margin: 0;
}

.user-filters .search-line a {
    color: var(--accent);
    text-decoration: none;
}

.user-filters .search-line a:hover { text-decoration: underline; }

.user-filters .list-toggle { margin: 10px 0 0; }

.user-filters + .tabs { margin-top: 0; }

.tabs + .table-wrap { margin-top: 14px; }

.assign-block { margin-top: 28px; }

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

.assign-head h2,
.assign-block h2 {
    margin: 0;
    color: var(--ink);
    font-family: var(--display);
    font-size: calc(20 / 17 * 1rem);
    font-weight: 800;
}

.link-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.link-card {
    display: flex;
    flex-direction: column;
    min-height: 112px;
    background: #fff;
    border: 1px solid var(--line);
}

.link-card:hover { border-color: var(--accent); }

.link-card-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    padding: 16px 16px 14px;
    color: inherit;
    text-decoration: none;
}

.link-card-main strong {
    color: var(--ink);
    font-family: var(--display);
    font-size: calc(18 / 17 * 1rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    overflow-wrap: anywhere;
}

.link-card-main span { color: var(--muted); }

.link-card-main .pill { color: var(--ink); }

.link-card-foot {
    display: flex;
    justify-content: flex-end;
    padding: 0 12px 12px;
}

.link-card-foot form { margin: 0; }

.pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: calc(12 / 17 * 1rem);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.facts a {
    color: var(--accent);
    overflow-wrap: anywhere;
}

@media (max-width: 860px) {
    .link-cards { grid-template-columns: 1fr; }
}

.shell .field textarea {
    width: 100%;
    min-height: calc(120 / 17 * 1rem);
    border: 1px solid var(--line);
    border-radius: 0;
    padding: calc(12 / 17 * 1rem);
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
    resize: vertical;
}

.shell .field textarea:focus,
.shell .field textarea[aria-invalid="true"] { border-color: var(--accent); }

.facts dd.pre { white-space: pre-wrap; }

.task-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}

.task-line-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--line);
}

.task-line-row form { margin: 0; }

.task-line-row > form:first-child,
.task-line-row > .task-check { flex: 1; min-width: 0; }

.task-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

span.task-check { cursor: default; }

.task-check::before {
    content: "";
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    border: 1px solid var(--line);
    background: #fff;
}

.task-check[aria-pressed="true"] {
    color: var(--muted);
    text-decoration: line-through;
}

.task-check[aria-pressed="true"]::before {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: inset 0 0 0 3px #fff;
}

.task-add {
    align-items: center;
    margin: 0;
}

.task-add input[type="text"] {
    flex: 1 1 220px;
    min-width: 0;
    height: calc(50 / 17 * 1rem);
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 0 calc(14 / 17 * 1rem);
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

.task-add input[type="text"]:focus { border-color: var(--accent); }

.task-time { margin-top: 14px; }

.task-line-row .hint { margin-top: 2px; }

.task-title { overflow-wrap: anywhere; }

.task-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 0;
}

.task-meta {
    margin: 8px 0 0;
    color: var(--muted);
}

.task-relations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin: 0 0 16px;
}

.task-relations .assign-block {
    margin: 0;
    padding: 14px 14px 12px;
    background: #fff;
    border: 1px solid var(--line);
}

.task-relations .assign-head { margin-bottom: 10px; }

.task-relations .assign-head h2 {
    font-size: calc(16 / 17 * 1rem);
}

.task-relations .hint { margin: 0; }

.task-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.task-chip {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 6px 8px 6px 12px;
    background: var(--page);
    border: 1px solid var(--line);
}

.task-chip strong,
.task-chip a {
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.task-chip a:hover { color: var(--accent); }

.task-chip > span:not(.pill) { color: var(--muted); }

.task-chip form { margin: 0; }

.task-workspace {
    background: #fff;
    border: 1px solid var(--line);
}

.task-tabs {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0 8px;
    border-bottom: 1px solid var(--line);
}

.task-tab {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 0 calc(16 / 17 * 1rem);
    min-height: calc(46 / 17 * 1rem);
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--muted);
    font: inherit;
    white-space: nowrap;
    cursor: pointer;
}

.task-tab[aria-selected="true"] {
    border-bottom-color: var(--accent);
    color: var(--ink);
}

.task-tab:hover { color: var(--ink); }

.task-tab:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}

.task-tab[aria-selected="true"] .tab-count { color: var(--accent); }

.task-panel { padding: 16px; }

.task-panel[hidden] { display: none; }

.task-panel .hint { margin: 0; }

.task-notes {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.task-panel .task-line-row { background: var(--page); }

.task-panel .task-time {
    max-width: none;
    margin: 14px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.task-time-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.task-time-grid .field,
.task-time-submit { margin: 0; }

.task-time-submit .btn { height: calc(50 / 17 * 1rem); }

.task-form { max-width: 760px; }

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

.task-form-grid .field { margin-bottom: 0; }

@media (max-width: 860px) {
    .task-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .task-tab { flex: 0 0 auto; }

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

    .task-form-grid .field { margin-bottom: 16px; }

    .task-form-grid .field:last-child { margin-bottom: 0; }

    .task-time-submit .btn { width: 100%; }
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.row-actions form { margin: 0; }

.mcp-note { margin-bottom: 18px; }

.mcp-key-dialog .dialog-panel {
    width: min(480px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
}

.mcp-key-dialog form .field:first-of-type { margin-top: 16px; }

.mcp-key-dialog .alert { margin-top: 16px; }

.mcp-key {
    margin: 0 0 18px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
}

.mcp-key p { margin: 0 0 10px; }

.mcp-key code {
    display: block;
    margin: 0 0 12px;
    overflow-wrap: anywhere;
    word-break: break-all;
    font-size: calc(14 / 17 * 1rem);
}

.mcp-notes {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.mcp-limit {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0;
}

.mcp-limit input {
    width: 8.5rem;
    height: calc(36 / 17 * 1rem);
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 0 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
}

.mcp-limit input:focus { border-color: var(--accent); }

.mcp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.mcp-actions form { margin: 0; }

.data-mcp td { vertical-align: top; }
.data-mcp th:last-child,
.data-mcp td:last-child { text-align: right; }

.data-mcp-catalog td,
.data-mcp-resources td {
    vertical-align: top;
    overflow-wrap: anywhere;
}

.public-body { background: var(--page); }

.public-bar {
    padding: 22px 28px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.public-bar .wordmark {
    font-size: calc(26 / 17 * 1rem);
    text-decoration: none;
}

@media (max-width: 860px) {
    .data-clients tbody tr,
    .data-apps tbody tr {
        grid-template-columns: 1fr;
        grid-template-areas:
            "name"
            "meta"
            "extra"
            "status"
            "actions";
    }

    .data-clients td:nth-child(1),
    .data-apps td:nth-child(1) { grid-area: name; color: var(--ink); }

    .data-clients td:nth-child(2),
    .data-apps td:nth-child(2) { grid-area: meta; color: var(--muted); }

    .data-clients td:nth-child(3) { grid-area: extra; color: var(--muted); }

    .data-apps td:nth-child(3) { grid-area: status; color: var(--ink); }

    .data-clients td:nth-child(4) { grid-area: status; color: var(--muted); }

    .data-clients td:nth-child(5),
    .data-apps td:nth-child(4) {
        grid-area: actions;
        margin-top: 6px;
        text-align: left;
    }

    .data-projects tbody tr {
        grid-template-columns: 1fr;
        grid-template-areas:
            "name"
            "meta"
            "status"
            "extra"
            "actions";
    }

    .data-projects td:nth-child(1) { grid-area: name; color: var(--ink); }

    .data-projects td:nth-child(2) { grid-area: meta; color: var(--muted); }

    .data-projects td:nth-child(3) { grid-area: status; color: var(--ink); }

    .data-projects td:nth-child(4) { grid-area: extra; color: var(--muted); }

    .data-projects td:nth-child(5),
    .data-tasks td:nth-child(5) {
        grid-area: actions;
        margin-top: 6px;
        text-align: left;
    }

    .data-tasks tbody tr {
        grid-template-columns: 1fr;
        grid-template-areas:
            "name"
            "status"
            "meta"
            "extra"
            "actions";
    }

    .data-tasks td:nth-child(1) { grid-area: name; color: var(--ink); }
    .data-tasks td:nth-child(2) { grid-area: status; color: var(--ink); }
    .data-tasks td:nth-child(3) { grid-area: meta; color: var(--muted); }
    .data-tasks td:nth-child(4) { grid-area: extra; color: var(--muted); }

    .data-mcp tbody tr {
        grid-template-columns: 1fr;
        grid-template-areas:
            "name"
            "meta"
            "extra"
            "status"
            "actions";
    }

    .data-mcp td:nth-child(1) { grid-area: name; color: var(--ink); text-align: left; }
    .data-mcp td:nth-child(2) { grid-area: meta; color: var(--muted); text-align: left; }
    .data-mcp td:nth-child(3) { grid-area: extra; color: var(--ink); text-align: left; }
    .data-mcp td:nth-child(4) { grid-area: status; color: var(--ink); text-align: left; }
    .data-mcp td:nth-child(5) {
        grid-area: actions;
        margin-top: 6px;
        text-align: left;
    }
    .data-mcp .mcp-actions { justify-content: flex-start; }
    .data-mcp .mcp-limit input { width: 100%; }

    .data-mcp-catalog tbody tr,
    .data-mcp-resources tbody tr {
        grid-template-columns: 1fr;
        grid-template-areas:
            "name"
            "meta"
            "extra"
            "status";
    }

    .data-mcp-catalog td:nth-child(1),
    .data-mcp-resources td:nth-child(1) { grid-area: name; color: var(--ink); text-align: left; }

    .data-mcp-catalog td:nth-child(2),
    .data-mcp-resources td:nth-child(2) { grid-area: meta; color: var(--muted); text-align: left; }

    .data-mcp-resources td:nth-child(3) { grid-area: extra; color: var(--muted); text-align: left; }

    .data-mcp-catalog td:nth-child(3),
    .data-mcp-resources td:nth-child(4) { grid-area: status; color: var(--ink); text-align: left; }

    .data-perm-users tbody tr,
    .data-members tbody tr {
        grid-template-columns: 1fr;
    }

    .perm-branch-bar {
        grid-template-columns: 28px minmax(0, 1fr) auto;
        grid-template-areas:
            "toggle title actions"
            "toggle meta status";
        align-items: center;
    }

    .perm-tree-toggle,
    .perm-tree-spacer { grid-area: toggle; align-self: center; }
    .perm-tree-title { grid-area: title; }
    .perm-tree-meta { grid-area: meta; }
    .perm-tree-status { grid-area: status; justify-self: start; }
    .perm-branch-bar .menu-drop { grid-area: actions; align-self: start; }
    .perm-children { margin-left: 14px; }

    .data-perm-users tbody tr {
        grid-template-areas:
            "name"
            "type"
            "status"
            "actions";
    }

    .data-perm-users td:nth-child(1) { grid-area: name; color: var(--ink); }
    .data-perm-users td:nth-child(2) { grid-area: type; color: var(--muted); }
    .data-perm-users td:nth-child(3) { grid-area: status; color: var(--ink); }
    .data-perm-users td:nth-child(4) {
        grid-area: actions;
        margin-top: 6px;
        text-align: left;
    }

    .data-members tbody tr {
        grid-template-areas:
            "name"
            "type"
            "actions";
    }

    .data-members td:nth-child(1) { grid-area: name; color: var(--ink); }
    .data-members td:nth-child(2) { grid-area: type; color: var(--muted); }
    .data-members td:nth-child(3) {
        grid-area: actions;
        margin-top: 6px;
        text-align: left;
    }

    .row-actions { justify-content: flex-start; }

    .data-bills tbody tr {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "number actions"
            "client client"
            "type status"
            "sum paid"
            "date date";
    }

    .data-bills.is-all tbody tr {
        grid-template-areas:
            "number actions"
            "client client"
            "seller seller"
            "type status"
            "sum paid"
            "date date";
    }

    .data-bills td.bill-num { grid-area: number; color: var(--ink); }
    .data-bills td.bill-client { grid-area: client; }
    .data-bills td.bill-seller { grid-area: seller; color: var(--muted); }
    .data-bills td.bill-type { grid-area: type; color: var(--muted); }
    .data-bills td.bill-status { grid-area: status; }
    .data-bills td.bill-sum { grid-area: sum; color: var(--ink); }
    .data-bills td.bill-paid { grid-area: paid; color: var(--muted); }
    .data-bills td.bill-date { grid-area: date; color: var(--muted); }
    .data-bills td.bill-actions {
        grid-area: actions;
        margin-top: 0;
        text-align: right;
    }

    .bill-grid,
    .bill-split,
    .bill-stats { grid-template-columns: 1fr; }
}

.bill-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 0 0 18px;
}

.bill-stat,
.bill-chart,
.bill-repeat {
    background: #fff;
    border: 1px solid var(--line);
}

.bill-stat { padding: 14px 16px; }

.bill-stat p,
.bill-stat span,
.bill-chart-head p {
    margin: 0;
    color: var(--muted);
}

.bill-stat strong {
    display: block;
    margin: 4px 0;
    color: var(--ink);
    font-family: var(--display);
    font-size: calc(22 / 17 * 1rem);
    font-weight: 700;
}

.bill-chart { margin: 0 0 18px; padding: 14px 16px 8px; }

.bill-chart h2 {
    margin: 0;
    font-size: calc(18 / 17 * 1rem);
}

.bill-chart-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
}

.bill-years { margin: 4px 0 18px; }

.bill-years fieldset {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    margin: 0;
    padding: 0;
    border: 0;
}

.bill-years legend {
    padding: 0;
    color: var(--muted);
}

.bill-years label {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    color: var(--ink);
    cursor: pointer;
}

.bill-years a { color: var(--accent); }

.bill-year-chart {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 0 8px;
}

.bill-year {
    flex: 0 0 92px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 92px;
}

.bill-year-sum,
.bill-year-label { color: var(--ink); text-align: center; }

.bill-year-sum {
    font-size: calc(13 / 17 * 1rem);
    white-space: nowrap;
}

.bill-year-label {
    font-family: var(--display);
    font-weight: 700;
}

.bill-year-track {
    display: flex;
    align-items: flex-end;
    width: 28px;
    height: 160px;
    background: var(--page);
    border: 1px solid var(--line);
}

.bill-year-track .bill-bar {
    display: block;
    width: 100%;
    height: 0;
    background: var(--ink);
}

.bill-year-track .bill-bar.is-now { background: var(--accent); }
.bill-year-track .bill-bar[data-level="0"] { height: 0; }
.bill-year-track .bill-bar[data-level="1"] { height: 5%; }
.bill-year-track .bill-bar[data-level="2"] { height: 10%; }
.bill-year-track .bill-bar[data-level="3"] { height: 15%; }
.bill-year-track .bill-bar[data-level="4"] { height: 20%; }
.bill-year-track .bill-bar[data-level="5"] { height: 25%; }
.bill-year-track .bill-bar[data-level="6"] { height: 30%; }
.bill-year-track .bill-bar[data-level="7"] { height: 35%; }
.bill-year-track .bill-bar[data-level="8"] { height: 40%; }
.bill-year-track .bill-bar[data-level="9"] { height: 45%; }
.bill-year-track .bill-bar[data-level="10"] { height: 50%; }
.bill-year-track .bill-bar[data-level="11"] { height: 55%; }
.bill-year-track .bill-bar[data-level="12"] { height: 60%; }
.bill-year-track .bill-bar[data-level="13"] { height: 65%; }
.bill-year-track .bill-bar[data-level="14"] { height: 70%; }
.bill-year-track .bill-bar[data-level="15"] { height: 75%; }
.bill-year-track .bill-bar[data-level="16"] { height: 80%; }
.bill-year-track .bill-bar[data-level="17"] { height: 85%; }
.bill-year-track .bill-bar[data-level="18"] { height: 90%; }
.bill-year-track .bill-bar[data-level="19"] { height: 95%; }
.bill-year-track .bill-bar[data-level="20"] { height: 100%; }

.bill-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0 0 14px;
}

.bill-filters input,
.bill-filters select {
    height: calc(50 / 17 * 1rem);
    border: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

.bill-filters input[type="search"] {
    flex: 1 1 220px;
    min-width: 0;
    padding: 0 calc(14 / 17 * 1rem);
}

.bill-filters select,
.bill-filters input[type="date"] { padding: 0 10px; }

.bill-filters a { color: var(--accent); }

.bill-editor.form-card { max-width: 1100px; }

.bill-tabs {
    display: flex;
    flex-wrap: wrap;
    margin: -22px -22px 18px;
    padding: 0 8px;
    border-bottom: 1px solid var(--line);
}

.bill-tab {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 0 calc(16 / 17 * 1rem);
    min-height: calc(46 / 17 * 1rem);
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}

.bill-tab[aria-selected="true"] {
    border-bottom-color: var(--accent);
    color: var(--ink);
}

.bill-tab:hover { color: var(--ink); }

.bill-tab:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
}

.bill-tab[aria-selected="true"] .tab-count { color: var(--accent); }

.bill-tabs .tab-count[hidden],
.bill-editor [data-bill-panel][hidden],
.bill-editor form[hidden],
.bill-files[hidden],
.bill-upload .field-error[hidden] { display: none; }

.bill-files {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    border: 1px solid var(--line);
}

.bill-files li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
}

.bill-files li:last-child { border-bottom: 0; }

.bill-files a {
    color: var(--ink);
    text-decoration: none;
}

.bill-files a:hover { color: var(--accent); }

.bill-file-meta {
    color: var(--muted);
    font-size: calc(14 / 17 * 1rem);
}

.bill-file-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px 12px;
    margin-left: auto;
}

.bill-file-flag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: calc(14 / 17 * 1rem);
}

.bill-file-flag input {
    width: 18px;
    height: 18px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
}

.bill-files .btn { margin-left: 0; }

.bill-upload {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 12px;
}

.bill-upload .field {
    flex: 1 1 240px;
    margin: 0;
}

.bill-upload .hint,
.bill-upload .field-error { flex: 1 1 100%; }

.shell .bill-upload input[type="file"] {
    height: auto;
    padding: calc(12 / 17 * 1rem) calc(14 / 17 * 1rem);
}

.bill-grid,
.bill-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.bill-party {
    margin: 0;
    padding: 12px 14px 4px;
    border: 1px solid var(--line);
}

.bill-party legend {
    padding: 0 6px;
    color: var(--ink);
    font-family: var(--display);
    font-weight: 700;
}

.bill-view.form-card { max-width: 960px; }

.invoice-sheet {
    color: var(--ink);
    padding: 6px 6px 8px;
}

.invoice-mark {
    margin: 0 0 16px;
    font-family: var(--display);
    font-weight: 800;
    font-size: calc(22 / 17 * 1rem);
    letter-spacing: -0.04em;
    line-height: 1;
}

.invoice-mark .accent { color: var(--accent); }

.invoice-sheet h2 {
    margin: 0;
    color: var(--ink);
    font-family: var(--display);
    font-size: calc(26 / 17 * 1rem);
    font-weight: 800;
    line-height: 1.15;
}

.invoice-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin: 12px 0 0;
}

.invoice-meta div { display: flex; gap: 6px; }

.invoice-meta dt,
.invoice-meta dd { margin: 0; }

.invoice-meta dt { color: var(--muted); font-weight: 400; }

.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px 28px;
    margin: 8px 0 6px;
}

.invoice-band {
    display: grid;
    grid-template-columns: 1fr minmax(0, auto) 1fr;
    align-items: center;
    gap: 8px 16px;
    margin: 22px 0 18px;
}

.invoice-mid {
    grid-column: 2;
    margin: 0;
    text-align: center;
}

.invoice-mid h2 { margin: 0 0 8px; }

.invoice-mid p,
.invoice-pay p {
    margin: 0;
    color: var(--muted);
}

.invoice-pay {
    grid-column: 3;
    justify-self: end;
    text-align: right;
}

.invoice-pay .invoice-status {
    color: var(--ink);
    font-weight: 700;
}

.invoice-parties h3,
.invoice-notes h3 {
    margin: 0 0 6px;
    color: var(--ink);
    font-family: var(--display);
    font-size: calc(15 / 17 * 1rem);
    font-weight: 700;
}

.invoice-parties p,
.invoice-notes p { margin: 0 0 2px; }

.invoice-empty { color: var(--muted); }

.invoice-scroll {
    width: 100%;
    overflow-x: auto;
}

.invoice-lines {
    width: 100%;
    min-width: 520px;
    border: 1px solid #d0d0d0;
    border-collapse: collapse;
}

.invoice-lines th,
.invoice-lines td {
    padding: 8px 10px;
    border: 1px solid #d0d0d0;
    text-align: left;
    vertical-align: top;
}

.invoice-lines thead th {
    background: #f2f2f2;
    color: var(--ink);
    font-weight: 700;
}

.invoice-lines tbody tr:nth-child(even) td { background: #fafafa; }

.invoice-sum td {
    background: #f2f2f2;
    color: var(--ink);
    font-weight: 700;
}

.invoice-sum td:first-child { text-align: right; }

.invoice-lines .is-num { text-align: right; white-space: nowrap; }

.invoice-lines .invoice-unit { text-align: center; }

/* The unit column is hidden on a phone, so the wide total span would add an empty column. */
.invoice-sum-compact,
.invoice-empty-compact { display: none; }

.invoice-measure { display: none; }

.invoice-lines small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.invoice-notes { margin-top: 20px; }

.invoice-notes p { white-space: pre-wrap; }

.bill-view .facts { max-width: none; margin-bottom: 8px; }

.bill-view .form-actions { margin-top: 4px; }

.bill-line-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin: 8px 0 12px;
}

.bill-line-tools .field { flex: 1 1 240px; margin: 0; }

.bill-scroll {
    display: block;
    width: 0;
    min-width: 100%;
    overflow-x: auto;
}

.bill-lines {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: #fff;
}

.bill-lines th,
.bill-lines td {
    padding: 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.bill-lines th {
    color: var(--muted);
    font-weight: 400;
}

.bill-lines input,
.bill-lines select {
    width: 100%;
    min-width: 0;
    height: calc(40 / 17 * 1rem);
    border: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

.bill-lines td:first-child input { margin-top: 6px; }
.bill-lines td[data-bill-sum] { white-space: nowrap; min-width: 96px; }

.bill-grand {
    margin: 14px 0 4px;
    color: var(--ink);
    text-align: right;
    font-size: calc(18 / 17 * 1rem);
}

.bill-grand strong { font-weight: 700; }

.bill-lines-block { margin-top: 8px; }

.bill-lines-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px;
}

.bill-lines-head h2 {
    margin: 0;
    font-size: calc(18 / 17 * 1rem);
}

.shell .field > span.bill-name-wrap {
    position: relative;
    display: block;
    margin: 0;
    color: inherit;
    font-size: inherit;
    font-weight: 400;
}

.bill-name-wrap.has-search input { padding-right: calc(40 / 17 * 1rem); }

.bill-name-wrap input[data-project-label] {
    background: #fff;
    color: var(--ink);
    cursor: default;
}

.bill-client-search {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(40 / 17 * 1rem);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.bill-client-search svg {
    width: 16px;
    height: 16px;
}

.bill-client-search:hover,
.bill-client-search:focus-visible { color: var(--accent); }

.bill-client-search:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: -4px;
}

.bill-grid > .field,
.bill-party .field { min-width: 0; }

.bill-sheet-wrap {
    width: 0;
    min-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    background: #fff;
}

.bill-sheet {
    --bill-cols: 112px minmax(120px, 1fr) 68px 78px 88px 76px 92px 120px;
    min-width: 820px;
}

.bill-sheet-head,
.bill-row-main {
    display: grid;
    grid-template-columns: var(--bill-cols);
    gap: 8px;
    align-items: center;
}

.bill-sheet-head {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: calc(13 / 17 * 1rem);
}

.bill-sheet-head .is-num { text-align: right; }

.bill-row-main { padding: 6px 10px; }

.bill-line + .bill-line { border-top: 1px solid var(--line); }

.bill-sheet input,
.bill-sheet select {
    width: 100%;
    min-width: 0;
    height: calc(34 / 17 * 1rem);
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

.bill-sheet input:focus,
.bill-sheet select:focus {
    border-color: var(--accent);
    outline: none;
}

.bill-row-sum {
    color: var(--ink);
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.bill-row-tools {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}

.bill-notes-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: calc(32 / 17 * 1rem);
    height: calc(32 / 17 * 1rem);
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.bill-notes-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.15s ease;
}

.bill-line.is-open .bill-notes-toggle svg { transform: rotate(90deg); }

.bill-notes-toggle:hover,
.bill-notes-toggle[aria-expanded="true"] {
    border-color: var(--line);
    background: #fff;
    color: var(--accent);
}

.bill-notes-toggle.is-filled { color: var(--accent); }

.bill-notes-toggle:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.bill-row-notes {
    padding: 0 10px 8px;
    background: var(--page);
}

.bill-row-notes[hidden] { display: none; }

.bill-row-note span {
    display: block;
    margin: 0 0 4px;
    color: var(--muted);
    font-size: calc(13 / 17 * 1rem);
}

.bill-empty {
    margin: 0;
    padding: 16px;
    border: 1px dashed var(--line);
    color: var(--muted);
    text-align: center;
}

.bill-empty[hidden] { display: none; }

.bill-notes { margin-top: 18px; }

.bill-picker .dialog-panel {
    width: min(520px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
}

.bill-picker .field { margin-top: 16px; }

.bill-block { margin-top: 22px; }

.bill-block h2 {
    margin: 0 0 10px;
    font-size: calc(18 / 17 * 1rem);
}

.bill-repeat {
    display: grid;
    gap: 8px;
    margin: 0 0 10px;
    padding: 12px;
}

.bill-check {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 8px 0 0;
    color: var(--ink);
}

.setup-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.setup-grid {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.setup-side { display: grid; gap: 18px; }

.setup-card {
    background: #fff;
    border: 1px solid var(--line);
    padding: 16px 16px 8px;
}

.setup-card > h2,
.setup-head h2 {
    margin: 0 0 12px;
    font-size: calc(18 / 17 * 1rem);
}

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

.setup-head h2 { margin: 0; }

.setup-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.setup-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.setup-title {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: center;
}

.setup-title strong { color: var(--ink); font-weight: 700; }

.setup-item p,
.setup-empty {
    margin: 2px 0 8px;
    color: var(--muted);
}

.setup-item p { margin: 2px 0 0; }

.cat-name strong,
.cat-name span {
    display: block;
}

.cat-name span {
    margin-top: 2px;
    color: var(--muted);
}

.dialog {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 16, 16, 0.55);
    animation: dialog-fade 0.16s ease;
}

.dialog-panel {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    padding: 28px 28px 22px;
    background: #fff;
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    box-shadow: 0 24px 60px rgba(16, 16, 16, 0.18);
    animation: dialog-in 0.16s ease;
}

.dialog-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 16px;
    border: 2px solid var(--accent);
    color: var(--accent);
    font-family: var(--display);
    font-size: calc(24 / 17 * 1rem);
    font-weight: 800;
    line-height: 1;
}

.dialog-panel .eyebrow { margin-bottom: 8px; }

.dialog-panel h2 {
    margin: 0;
    color: var(--ink);
    font-family: var(--display);
    font-size: calc(26 / 17 * 1rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.15;
}

.dialog-message {
    margin: 10px 0 0;
    color: var(--muted);
}

.dialog-subject {
    margin: 16px 0 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: var(--page);
    color: var(--ink);
    font-weight: 400;
}

.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.dialog-actions .btn { min-width: 120px; }

.dialog .btn-ghost:focus {
    background: #fff;
    border-color: var(--ink);
    color: var(--ink);
}

.dialog .btn:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

@media (max-width: 560px) {
    .dialog-panel { padding: 22px 18px 18px; }
    .dialog-panel h2 { font-size: calc(22 / 17 * 1rem); }
    .dialog-actions {
        flex-direction: column-reverse;
    }
    .dialog-actions .btn { width: 100%; }
}

@keyframes dialog-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
    .nav-toggle svg,
    .perm-tree-toggle svg,
    .perm-card-toggle svg,
    .bill-notes-toggle svg { transition: none; }
    .dialog-backdrop,
    .dialog-panel { animation: none; }
}

@media (max-width: 860px) {
    .bill-grid,
    .bill-split,
    .bill-stats,
    .invoice-parties,
    .invoice-band { grid-template-columns: 1fr; }

    .invoice-mid,
    .invoice-pay { grid-column: auto; }

    .invoice-pay { margin-top: 10px; }

    .invoice-lines { min-width: 0; }

    .invoice-lines th,
    .invoice-lines td { padding: 8px 4px; }

    .invoice-unit { display: none; }

    .invoice-sum-full,
    .invoice-empty-full { display: none; }

    .invoice-sum-compact,
    .invoice-empty-compact { display: table-row; }

    .invoice-measure { display: inline; font-weight: 400; }

    .bill-files .btn { margin-left: 0; }

    .setup-grid,
    .setup-fields { grid-template-columns: 1fr; }

    .data-catalog thead { display: none; }

    .data-catalog tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas:
            "name actions actions"
            "qty cost price";
        gap: 4px 10px;
        padding: 12px;
        border-bottom: 1px solid var(--line);
    }

    .data-catalog td {
        display: block;
        padding: 0;
        border: 0;
    }

    .data-catalog td.cat-name { grid-area: name; }
    .data-catalog td.cat-actions { grid-area: actions; justify-self: end; }
    .data-catalog td.cat-qty { grid-area: qty; color: var(--muted); }
    .data-catalog td.cat-cost { grid-area: cost; }
    .data-catalog td.cat-price { grid-area: price; text-align: right; }

    .data-catalog td.cat-cost::before,
    .data-catalog td.cat-price::before {
        display: block;
        margin-bottom: 2px;
        color: var(--muted);
        font-size: calc(12 / 17 * 1rem);
    }

    .data-catalog td.cat-cost::before { content: "Savikaina"; }
    .data-catalog td.cat-price::before { content: "Kaina"; }

    .data-catalog tbody tr td[colspan] {
        grid-column: 1 / -1;
        color: var(--muted);
    }

    .bill-year-chart {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        overflow: visible;
    }

    .bill-year {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr) 96px;
        grid-template-areas: "label track sum";
        align-items: center;
        gap: 8px;
        width: auto;
    }

    .bill-year-label { grid-area: label; text-align: left; }
    .bill-year-sum { grid-area: sum; text-align: right; }

    .bill-year-track {
        grid-area: track;
        width: auto;
        height: 10px;
    }

    .bill-year-track .bill-bar { width: 0; height: 100%; }
    .bill-year-track .bill-bar[data-level="0"] { width: 0; }
    .bill-year-track .bill-bar[data-level="1"] { width: 5%; }
    .bill-year-track .bill-bar[data-level="2"] { width: 10%; }
    .bill-year-track .bill-bar[data-level="3"] { width: 15%; }
    .bill-year-track .bill-bar[data-level="4"] { width: 20%; }
    .bill-year-track .bill-bar[data-level="5"] { width: 25%; }
    .bill-year-track .bill-bar[data-level="6"] { width: 30%; }
    .bill-year-track .bill-bar[data-level="7"] { width: 35%; }
    .bill-year-track .bill-bar[data-level="8"] { width: 40%; }
    .bill-year-track .bill-bar[data-level="9"] { width: 45%; }
    .bill-year-track .bill-bar[data-level="10"] { width: 50%; }
    .bill-year-track .bill-bar[data-level="11"] { width: 55%; }
    .bill-year-track .bill-bar[data-level="12"] { width: 60%; }
    .bill-year-track .bill-bar[data-level="13"] { width: 65%; }
    .bill-year-track .bill-bar[data-level="14"] { width: 70%; }
    .bill-year-track .bill-bar[data-level="15"] { width: 75%; }
    .bill-year-track .bill-bar[data-level="16"] { width: 80%; }
    .bill-year-track .bill-bar[data-level="17"] { width: 85%; }
    .bill-year-track .bill-bar[data-level="18"] { width: 90%; }
    .bill-year-track .bill-bar[data-level="19"] { width: 95%; }
    .bill-year-track .bill-bar[data-level="20"] { width: 100%; }

    .data-bills tbody tr td[colspan] {
        grid-column: 1 / -1;
        color: var(--muted);
    }
}
