/*
 * Jivo Support: the ticket system's own stylesheet (no Django admin CSS).
 * Tokens come in light and dark sets; dark follows the OS unless the
 * theme toggle stored a choice (html[data-theme]).
 */

/* ---- Tokens ----------------------------------------------------------- */

:root {
    color-scheme: light;

    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-3: #eef0f4;
    --border: #e4e7ec;
    --border-strong: #cfd4dc;
    --text: #1d2330;
    --text-2: #515b6c;
    --text-3: #6f7889;
    --accent: #1f6feb;
    --accent-hover: #1759c4;
    --accent-soft: #e8f0fe;
    --accent-text: #1557c0;
    --on-accent: #ffffff;
    --focus: rgba(31, 111, 235, 0.35);
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.12);
    --wash: rgba(29, 35, 48, 0.04);

    --good: #1a7f37;
    --good-soft: #e7f6ec;
    --warning: #8a5a00;
    --warning-soft: #fff3d6;
    --critical: #b42318;
    --critical-soft: #fdecec;
    --info: #1557c0;
    --info-soft: #e8f0fe;
    --neutral: #4b5565;
    --neutral-soft: #eef0f4;
    --danger-bg: #c4302b;
    --danger-hover: #a3241f;

    /* Chart series, validated on #fff (dataviz checks). */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --grid: #eceef2;
    --axis: #cfd4dc;

    --radius: 12px;
    --radius-sm: 8px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --header-h: 60px;
    --nav-w: 252px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #111419;
        --surface: #1b1f27;
        --surface-2: #20252e;
        --surface-3: #272d38;
        --border: #2d3440;
        --border-strong: #3b4351;
        --text: #e6e9ef;
        --text-2: #a8b0be;
        --text-3: #8b94a3;
        --accent: #58a6ff;
        --accent-hover: #7cb9ff;
        --accent-soft: rgba(88, 166, 255, 0.14);
        --accent-text: #8ec2ff;
        --on-accent: #0b1220;
        --focus: rgba(88, 166, 255, 0.45);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
        --wash: rgba(255, 255, 255, 0.04);

        --good: #8fdca8;
        --good-soft: #173323;
        --warning: #f2cc60;
        --warning-soft: #3a2f12;
        --critical: #ff9ea2;
        --critical-soft: #3b1d1f;
        --info: #9cc7ff;
        --info-soft: #16263d;
        --neutral: #c3c9d4;
        --neutral-soft: #2a303b;

        --series-1: #3987e5;
        --series-2: #d95926;
        --grid: #262c36;
        --axis: #3b4351;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #111419;
    --surface: #1b1f27;
    --surface-2: #20252e;
    --surface-3: #272d38;
    --border: #2d3440;
    --border-strong: #3b4351;
    --text: #e6e9ef;
    --text-2: #a8b0be;
    --text-3: #8b94a3;
    --accent: #58a6ff;
    --accent-hover: #7cb9ff;
    --accent-soft: rgba(88, 166, 255, 0.14);
    --accent-text: #8ec2ff;
    --on-accent: #0b1220;
    --focus: rgba(88, 166, 255, 0.45);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --wash: rgba(255, 255, 255, 0.04);

    --good: #8fdca8;
    --good-soft: #173323;
    --warning: #f2cc60;
    --warning-soft: #3a2f12;
    --critical: #ff9ea2;
    --critical-soft: #3b1d1f;
    --info: #9cc7ff;
    --info-soft: #16263d;
    --neutral: #c3c9d4;
    --neutral-soft: #2a303b;

    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #262c36;
    --axis: #3b4351;
}

/* ---- Base ------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    background: var(--bg);
}

body {
    min-height: 100vh;
    color: var(--text);
    font: 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-text);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}

a:hover {
    text-decoration-color: currentColor;
}

h1,
h2,
h3 {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.01em;
}

p {
    margin: 0 0 12px;
}

code,
pre {
    font-family: var(--mono);
    font-size: 0.92em;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.icon {
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.muted {
    color: var(--text-3);
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.text-critical {
    color: var(--critical);
}

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

.skip-link {
    position: absolute;
    top: -40px;
    left: 8px;
    z-index: 2000;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--on-accent);
}

.skip-link:focus {
    top: 8px;
}

/* ---- Layout: header, sidebar, content ------------------------------------ */

.app-header {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--header-h);
    padding: 0 16px 0 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 16px;
    font-weight: 650;
    text-decoration: none;
}

.brand__mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--on-accent);
}

.env-badge {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.app-header__spacer {
    flex: 1;
}

.header-link,
.header-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-2);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.header-link:hover,
.header-button:hover {
    background: var(--surface-3);
    color: var(--text);
}

.header-count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--critical);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
}

.menu-button {
    display: none;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.user-chip__text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-chip__name {
    font-weight: 600;
}

.user-chip__role {
    color: var(--text-3);
    font-size: 11.5px;
}

.avatar {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 12px;
    font-weight: 700;
}

.app-body {
    display: flex;
    min-height: calc(100vh - var(--header-h));
}

.sidenav {
    position: sticky;
    top: var(--header-h);
    flex: 0 0 var(--nav-w);
    align-self: flex-start;
    height: calc(100vh - var(--header-h));
    padding: 16px 12px 24px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.sidenav__section + .sidenav__section {
    margin-top: 18px;
}

.sidenav__heading {
    margin: 0 0 6px;
    padding: 0 12px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

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

.sidenav__item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 1px 0;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
    text-decoration: none;
}

.sidenav__item:hover {
    background: var(--surface-3);
    color: var(--text);
}

.sidenav__item.is-current {
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
}

.sidenav__badge {
    margin-left: auto;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.sidenav__foot {
    margin-top: 24px;
    padding: 12px 0 0;
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 12.5px;
}

.sidenav__foot p {
    margin: 0 12px 8px;
    overflow-wrap: anywhere;
}

.nav-backdrop {
    display: none;
}

.content {
    flex: 1;
    min-width: 0;
    padding: 20px 32px 48px;
}

.content__inner {
    max-width: 1320px;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
    padding: 0;
    color: var(--text-3);
    font-size: 13px;
    list-style: none;
}

.breadcrumbs li + li::before {
    content: "/";
    margin-right: 6px;
    color: var(--border-strong);
}

.breadcrumbs a {
    color: var(--text-2);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

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

.page-head h1 {
    font-size: 24px;
    overflow-wrap: anywhere;
}

.page-head__sub {
    margin: 4px 0 0;
    color: var(--text-2);
}

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

.footer {
    margin-top: 32px;
    color: var(--text-3);
    font-size: 12px;
}

/* ---- Messages and callouts ------------------------------------------------ */

.messages {
    display: grid;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.message {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 44px 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--info-soft);
    color: var(--text);
    animation: slide-in 0.2s ease-out;
}

.message--success { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.message--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.message--error { background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 30%, transparent); }

.message__dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    opacity: 0.6;
    cursor: pointer;
}

.message__dismiss:hover {
    opacity: 1;
    background: var(--wash);
}

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

.callout {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}

.callout p {
    margin: 0;
}

.callout--info { background: var(--info-soft); color: var(--info); }
.callout--warning { background: var(--warning-soft); color: var(--warning); }
.callout--good { background: var(--good-soft); color: var(--good); }
.callout--critical { background: var(--critical-soft); color: var(--critical); }

/* ---- Buttons ------------------------------------------------------------ */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: 600 13px/1 var(--font);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.button:hover {
    background: var(--surface-2);
}

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

.button--primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}

.button--primary:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
}

.button--danger {
    border-color: var(--danger-bg);
    background: var(--danger-bg);
    color: #ffffff;
}

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

.button--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-2);
}

.button--ghost:hover {
    background: var(--surface-3);
}

.button--small {
    min-height: 30px;
    padding: 0 10px;
    font-size: 12.5px;
}

.button[disabled],
.is-busy {
    opacity: 0.65;
    pointer-events: none;
}

.is-busy::after {
    content: "";
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.inline-form {
    display: inline;
    margin: 0;
}

/* ---- Cards, tiles, grids ------------------------------------------------------ */

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

.card--flush {
    padding: 0;
    overflow: hidden;
}

.card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px 12px;
    margin-bottom: 16px;
}

.card--flush > .card__head {
    margin: 0;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

.card__sub {
    margin: 2px 0 0;
    color: var(--text-3);
    font-size: 13px;
}

.card__link {
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.card__link:hover {
    text-decoration: underline;
}

.section-title {
    margin: 28px 0 12px;
    font-size: 16px;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

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

@media (min-width: 1280px) {
    .tiles--six {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

a.tile:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.tile__label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}

.tile__label .icon {
    color: var(--text-3);
}

.tile__value {
    font-size: 30px;
    font-weight: 650;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.tile__note {
    color: var(--text-3);
    font-size: 12.5px;
}

.tile--warning { border-left: 3px solid var(--warning); }
.tile--critical { border-left: 3px solid var(--critical); }

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

.grid--wide-left {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}

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

.attention {
    border-left: 3px solid var(--warning);
}

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

.attention__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.attention__item a {
    font-weight: 600;
}

.attention__item p {
    margin: 2px 0 0;
    font-size: 13px;
}

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

.stats dt {
    color: var(--text-2);
    font-size: 13px;
}

.stats dd {
    margin: 2px 0 0;
    font-size: 24px;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.stats dd.muted {
    font-size: 12.5px;
    font-weight: 400;
    letter-spacing: 0;
}

/* ---- Badges ------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge--neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent-text); }
.badge--good { background: var(--good-soft); color: var(--good); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--critical { background: var(--critical-soft); color: var(--critical); }

.badge--dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* ---- Tables ------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

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

.table thead th {
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--wash);
}

.table tbody tr:last-child td,
.table tbody tr:last-child th {
    border-bottom: 0;
}

.table .num {
    text-align: right;
}

.table--compact th,
.table--compact td {
    padding: 7px 10px;
}

.table tr.is-me td {
    background: var(--accent-soft);
}

.table tr.is-inactive td {
    color: var(--text-3);
}

.card > .table-wrap {
    margin: 0 -20px -20px;
}

.card > .table-wrap .table th:first-child,
.card > .table-wrap .table td:first-child {
    padding-left: 20px;
}

.card--flush > .table-wrap {
    margin: 0;
}

.check-col {
    width: 36px;
}

.tickets__ref {
    margin-right: 6px;
    color: var(--text-3);
    font: 600 12px var(--mono);
}

.tickets__link {
    display: block;
    color: var(--text);
    text-decoration: none;
}

.tickets__subject {
    font-weight: 600;
}

.tickets__link:hover .tickets__subject {
    color: var(--accent-text);
    text-decoration: underline;
}

.tickets__meta {
    display: block;
    margin-top: 2px;
    color: var(--text-3);
    font-size: 12px;
}

.tickets__main {
    min-width: 240px;
}

.tickets tr.is-overdue .tickets__ref {
    color: var(--critical);
}

/* ---- Filters, pagination ------------------------------------------------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.filters__search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 240px;
    max-width: 380px;
}

.filters__search .icon {
    position: absolute;
    left: 10px;
    color: var(--text-3);
    pointer-events: none;
}

/* Outweighs the generic input rule below. */
.filters .filters__search input {
    width: 100%;
    padding-left: 32px;
}

.filters__field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.filters__more {
    flex-basis: 100%;
}

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

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

.filters__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 13px;
}

.pagination__links {
    display: flex;
    align-items: center;
    gap: 2px;
}

.pagination__page,
.pagination__current {
    display: inline-grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    border-radius: 6px;
    color: var(--text-2);
    text-decoration: none;
}

.pagination__page:hover {
    background: var(--surface-3);
}

.pagination__current {
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

/* ---- Forms ------------------------------------------------------------- */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
select,
textarea {
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: 14px/1.4 var(--font);
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
    outline: none;
}

input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.form {
    max-width: 880px;
}

.form--narrow {
    max-width: 560px;
}

.field {
    margin-bottom: 18px;
}

.field > label,
.field__label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
    width: 100%;
}

/* Show/hide button on password fields (app.js). */
.password-reveal {
    position: relative;
    display: block;
}

.password-reveal .password-reveal__input {
    width: 100%;
    padding-right: 40px;
}

.password-reveal__input::-ms-reveal {
    display: none;
}

.password-reveal__button {
    position: absolute;
    top: 50%;
    right: 4px;
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transform: translateY(-50%);
}

.password-reveal__button:hover {
    background: var(--surface-2);
    color: var(--text);
}

.field--check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.field--check label {
    margin: 0;
}

.field__help {
    margin: 6px 0 0;
    color: var(--text-3);
    font-size: 12.5px;
}

.field__help ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

.field__error {
    margin: 6px 0 0;
    color: var(--critical);
    font-size: 13px;
}

.has-error input,
.has-error select,
.has-error textarea {
    border-color: var(--critical);
}

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

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

.form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.fieldset {
    margin: 0 0 20px;
    padding: 0;
    border: 0;
}

.fieldset legend {
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 600;
}

.fieldset__help {
    margin: -4px 0 12px;
    color: var(--text-3);
    font-size: 13px;
}

/* Upload box */
.upload {
    position: relative;
    padding: 14px 16px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.upload:focus-within,
.upload.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.upload input[type="file"] {
    display: block;
    width: 100%;
    font-size: 13px;
}

.upload__hint {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--text-2);
    font-size: 13.5px;
}

.upload--enhanced input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload--enhanced .upload__hint {
    display: flex;
}

.upload__list {
    position: relative;
    z-index: 1;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.upload__list[hidden] {
    display: none;
}

.upload__list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 13px;
}

.upload__list li.is-too-big {
    color: var(--critical);
}

/* ---- Empty states ------------------------------------------------------------ */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--text-2);
    text-align: center;
}

.empty h2 {
    font-size: 16px;
}

.empty p {
    max-width: 440px;
    margin: 0;
}

.empty__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-3);
}

.empty--good .empty__icon {
    background: var(--good-soft);
    color: var(--good);
}

/* ---- Charts (geometry from adminpanel.charts) ------------------------------- */

.chart {
    margin: 0;
    /* Hidden tooltips of the edge columns must not widen the page. */
    overflow-x: clip;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 0 0 12px;
    padding: 0;
    color: var(--text-2);
    font-size: 13px;
    list-style: none;
}

.legend li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--series-1);
}

.swatch--series-2 {
    background: var(--series-2);
}

.columns {
    position: relative;
    padding: 8px 0 26px 40px;
}

.columns__grid {
    position: absolute;
    top: 8px;
    right: 0;
    left: 40px;
    height: 180px;
}

.columns__tick {
    position: absolute;
    right: 0;
    left: 0;
    border-top: 1px solid var(--grid);
}

.columns__tick:first-child {
    border-top-color: var(--axis);
}

.columns__tick span {
    position: absolute;
    right: calc(100% + 8px);
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.columns__plot {
    position: relative;
    display: flex;
    height: 180px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.col {
    position: relative;
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    border-radius: 6px;
}

.col::before {
    content: "";
    position: absolute;
    inset: 0 1px;
    border-radius: 6px;
}

.col:hover::before,
.col:focus-visible::before {
    background: var(--wash);
}

.col__area {
    position: relative;
    display: flex;
    flex: 1;
    align-items: flex-end;
    justify-content: center;
}

.col__stack {
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
    width: min(24px, 62%);
    overflow: hidden;
    border-radius: 4px 4px 0 0;
}

.col__seg {
    display: block;
    flex-basis: 0;
    min-height: 2px;
    background: var(--series-1);
}

.col__seg--series-2 {
    background: var(--series-2);
}

.col__label {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    color: var(--text-3);
    font-size: 11px;
    text-align: center;
}

.col.is-today .col__label {
    color: var(--text);
    font-weight: 700;
}

.tip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    z-index: 20;
    min-width: 150px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px);
    transition: opacity 0.12s, transform 0.12s;
}

.col--start .tip { left: 0; transform: translate(0, 4px); }
.col--end .tip { right: 0; left: auto; transform: translate(0, 4px); }

.col:hover .tip,
.col:focus-visible .tip {
    opacity: 1;
    transform: translate(-50%, 0);
}

.col--start:hover .tip,
.col--start:focus-visible .tip,
.col--end:hover .tip,
.col--end:focus-visible .tip {
    transform: none;
}

.tip__title {
    margin-bottom: 4px;
    color: var(--text-3);
    white-space: nowrap;
}

.tip__row {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.tip__key {
    width: 12px;
    height: 3px;
    border-radius: 2px;
    background: var(--series-1);
}

.tip__key--series-2 {
    background: var(--series-2);
}

.table-view {
    margin-top: 8px;
}

.table-view summary {
    color: var(--text-3);
    font-size: 12.5px;
    cursor: pointer;
}

.bars {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bars__row {
    display: grid;
    grid-template-columns: minmax(90px, 36%) 1fr;
    align-items: center;
    gap: 12px;
}

.bars__label {
    overflow: hidden;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.bars__label:hover {
    text-decoration: underline;
}

.bars__area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bars__fill {
    display: block;
    min-width: 2px;
    height: 12px;
    border-radius: 0 4px 4px 0;
    background: var(--series-1);
}

.bars__value {
    color: var(--text-2);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.share__bar {
    width: 50%;
}

.share__fill {
    display: block;
    min-width: 2px;
    height: 10px;
    border-radius: 0 4px 4px 0;
    background: var(--series-1);
}

/* ---- Ticket page ------------------------------------------------------------ */

.ticket-ref {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    color: var(--text-3);
    font: 600 13px var(--mono);
}

.ticket {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px;
    align-items: start;
}

.ticket__main,
.ticket__side {
    min-width: 0;
}

.msg {
    padding: 16px 20px;
}

.msg--internal {
    border-color: color-mix(in srgb, var(--warning) 40%, transparent);
    background: color-mix(in srgb, var(--warning-soft) 45%, var(--surface));
}

.msg--request {
    border-left: 3px solid var(--accent);
}

.msg__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 13.5px;
}

.msg__head > div {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.msg__body {
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.msg__body p:last-child {
    margin-bottom: 0;
}

.resolution {
    border-left: 3px solid var(--good);
}

.reply .field {
    margin-bottom: 12px;
}

.reply textarea {
    width: 100%;
}

.files {
    display: grid;
    gap: 6px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.files__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.files__thumb {
    flex: none;
    width: 56px;
    height: 56px;
    overflow: hidden;
    border-radius: 6px;
}

.files__thumb img {
    display: block;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    background: var(--surface-3);
    object-fit: cover;
}

.files__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--text-3);
}

.files__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.files__download {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    color: var(--text-2);
}

.files__download:hover {
    background: var(--surface-3);
}

.props {
    display: grid;
    gap: 10px;
    margin: 0;
}

.props > div {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 8px;
    font-size: 13.5px;
}

.props dt {
    color: var(--text-3);
}

.props dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.actions__form {
    margin: 0 0 14px;
}

.actions__form > label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 600;
}

.actions__row {
    display: flex;
    gap: 8px;
}

.actions__row select {
    flex: 1;
    min-width: 0;
}

.actions__form textarea,
.actions__form input[type="text"] {
    width: 100%;
    margin-bottom: 8px;
}

.actions__details {
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

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

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

.actions__details[open] summary {
    margin-bottom: 10px;
}

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

.timeline__item {
    position: relative;
    display: flex;
    gap: 10px;
    padding-bottom: 14px;
}

.timeline__item::before {
    content: "";
    position: absolute;
    top: 24px;
    bottom: 0;
    left: 11px;
    border-left: 1px solid var(--border);
}

.timeline__item:last-child::before {
    display: none;
}

.timeline__icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-2);
}

.timeline__body {
    min-width: 0;
}

.timeline__line,
.timeline__meta {
    margin: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.timeline__meta {
    color: var(--text-3);
    font-size: 12px;
}

/* ---- Notifications ------------------------------------------------------------ */

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

.notes__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.notes__item:last-child {
    border-bottom: 0;
}

.notes__dot {
    flex: none;
    width: 8px;
    height: 8px;
    margin-top: 7px;
    border-radius: 50%;
}

.notes__item.is-unread .notes__dot {
    background: var(--accent);
}

.notes__body {
    flex: 1;
    min-width: 0;
}

.notes__title,
.notes__text,
.notes__meta {
    margin: 0;
    overflow-wrap: anywhere;
}

.notes__title {
    font-weight: 600;
}

.notes__text {
    margin-top: 2px;
    color: var(--text-2);
    font-size: 13px;
}

.notes__meta {
    margin-top: 4px;
    color: var(--text-3);
    font-size: 12px;
}

/* ---- Bulk bar, member rows, misc ------------------------------------------------- */

.bulkbar {
    position: sticky;
    bottom: 12px;
    z-index: 50;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(6px);
}

.bulkbar__count {
    color: var(--text-2);
    font-size: 13px;
}

.bulk-list {
    max-height: 260px;
    margin: 0 0 16px;
    padding: 8px 12px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    list-style: none;
}

.bulk-list li {
    padding: 3px 0;
}

.member-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.member-row select {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 13px;
}

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ---- JI dashboards (boards app) ------------------------------------------------ */

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.dash-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
}

.dash-card__icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent-text);
}

.dash-card__title {
    font-size: 16px;
}

.dash-card__title a {
    color: var(--text);
    text-decoration: none;
}

.dash-card__title a:hover {
    color: var(--accent-text);
    text-decoration: underline;
}

.dash-card__body {
    flex: 1;
}

.dash-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* A wall board drawn in a frame: 16:9 like the factory's screens, as wide as
   the page allows while the whole board stays in view. The board sizes
   itself from the frame's viewport, so it scales exactly. */
.board-frame {
    width: min(100%, calc((100vh - var(--header-h) - 150px) * 16 / 9));
    min-width: min(100%, 720px);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f4f6fa;
    box-shadow: var(--shadow);
}

.board-frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ---- Sign-in page ------------------------------------------------------------ */

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(circle at 20% 0%, var(--accent-soft), transparent 45%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 32px 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.auth-card .brand {
    margin-bottom: 24px;
}

.auth-card h1 {
    margin-bottom: 20px;
    font-size: 22px;
}

.auth-card .button--primary {
    width: 100%;
    min-height: 42px;
}

.auth-card__links {
    display: flex;
    justify-content: space-between;
    margin: -6px 0 16px;
    font-size: 13px;
}

.error-page {
    max-width: 520px;
    margin: 12vh auto;
    padding: 0 16px;
    text-align: center;
}

/* ---- Responsive ------------------------------------------------------------- */

@media (max-width: 1100px) {
    .grid,
    .grid--wide-left {
        grid-template-columns: minmax(0, 1fr);
    }

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

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

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

@media (max-width: 860px) {
    .menu-button {
        display: inline-flex;
    }

    .sidenav {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1000;
        width: min(300px, 86vw);
        height: auto;
        box-shadow: var(--shadow-lg);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
    }

    body.nav-open .sidenav {
        transform: none;
    }

    body.nav-open .nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 999;
        display: block;
        background: rgba(10, 13, 18, 0.45);
    }

    .content {
        padding: 16px 16px 40px;
    }

    .user-chip__text,
    .header-link__label {
        display: none;
    }

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

@media (max-width: 640px) {
    .form__row,
    .form__row--three {
        grid-template-columns: minmax(0, 1fr);
    }

    .props > div {
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
    }

    .filters__search {
        flex-basis: 100%;
        max-width: none;
    }

    .filters select {
        flex: 1 1 45%;
    }

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

    .tile__value {
        font-size: 24px;
    }

    .card {
        padding: 16px;
    }

    .card > .table-wrap {
        margin: 0 -16px -16px;
    }

    .col:nth-child(even) .col__label {
        visibility: hidden;
    }

    .env-badge {
        display: none;
    }

    /* The header keeps menu, brand, bell, sign out and theme; the rest is
       in the sidebar's footer. */
    .header-link--secondary,
    .user-chip {
        display: none;
    }

    .app-header {
        gap: 4px;
        padding: 0 8px;
    }
}

@media (max-width: 420px) {
    .tiles,
    .tiles--six {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    .app-header,
    .sidenav,
    .page-head__actions,
    .reply,
    .actions {
        display: none !important;
    }
}
