/* Fungusware support desk
   Ink navy chrome, flat surfaces, one accent. Colour carries meaning: a ticket's state
   (the "state rail") and whether it needs attention. Everything else stays quiet. */

@font-face {
    font-family: "IBM Plex Sans";
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Sans";
    font-weight: 500;
    font-style: normal;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Sans";
    font-weight: 600;
    font-style: normal;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Mono";
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Mono";
    font-weight: 500;
    font-style: normal;
    font-display: swap;
    src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}

:root {
    /* chrome */
    --ink: #161B2E;
    --ink-raised: #232A45;
    --ink-text: #C9CEDD;
    --ink-muted: #8C93AB;

    /* surfaces and text */
    --paper: #F5F6F8;
    --surface: #FFFFFF;
    --line: #E3E6EC;
    --line-strong: #CDD2DC;
    --text: #171B2B;
    --text-2: #5B6478;

    /* accent */
    --accent: #0B6BCB;
    --accent-strong: #0958A8;
    --accent-soft: #E6F0FB;

    /* ticket state: the rail colours */
    --s-open: #2F6FEB;
    --s-progress: #D99A00;
    --s-waiting: #0E9AA7;
    --s-resolved: #1E8E5A;
    --s-closed: #8A93A3;
    --attn: #D6363F;
    --attn-soft: #FDECEE;
    --attn-text: #A8232B;

    --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, Consolas, "Courier New", monospace;

    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 10px;

    --tabbar-h: 3.5rem;

    /* older names, still used further down */
    --primary-color: var(--accent);
    --primary-dark: var(--accent-strong);
    --secondary-color: var(--ink);
    --text-primary: var(--text);
    --text-secondary: var(--text-2);
    --text-light: var(--ink-text);
    --bg-light: var(--paper);
    --bg-lighter: #ECEEF2;
    --border-color: var(--line);
    --danger: #D6363F;
    --success: #1E8E5A;
    --warning: #D99A00;

    /* point Bootstrap at the same tokens */
    --bs-body-font-family: var(--font-ui);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--paper);
    --bs-border-color: var(--line);
    --bs-primary: var(--accent);
    --bs-primary-rgb: 11, 107, 203;
    --bs-link-color: var(--accent);
    --bs-link-hover-color: var(--accent-strong);
    --bs-link-color-rgb: 11, 107, 203;
}

html, body {
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    background-color: var(--paper);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a, .btn-link {
    color: var(--accent);
    text-decoration: none;
}

a:hover, .btn-link:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

/* ticket numbers and serials are identifiers: set them as such */
code, .font-monospace, .ticket-id {
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: inherit;
    background: none;
    padding: 0;
}

.ticket-id {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* keyboard focus is always visible */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---- buttons: flat, no lift ---- */
.btn {
    border: 1px solid transparent;
    border-radius: var(--r-md);
    font-weight: 500;
    padding: 0.45rem 0.95rem;
    font-size: 0.9rem;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

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

.btn-primary:hover, .btn-primary:focus-visible {
    color: #fff;
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    text-decoration: none;
}

.btn-primary:disabled {
    background: var(--accent);
    border-color: var(--accent);
    opacity: 0.55;
}

.btn-success {
    color: #fff;
    background: var(--s-resolved);
    border-color: var(--s-resolved);
}

.btn-success:hover {
    color: #fff;
    background: #17704A;
    border-color: #17704A;
}

.btn-secondary, .btn-outline-secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line-strong);
}

.btn-secondary:hover, .btn-outline-secondary:hover {
    color: var(--text);
    background: var(--paper);
    border-color: var(--line-strong);
    text-decoration: none;
}

.btn-outline-primary {
    color: var(--accent);
    background: var(--surface);
    border-color: var(--accent);
}

.btn-outline-primary:hover {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    text-decoration: none;
}

.btn-outline-danger {
    color: var(--attn-text);
    background: var(--surface);
    border-color: #E7A3A8;
}

.btn-outline-danger:hover {
    color: #fff;
    background: var(--attn);
    border-color: var(--attn);
}

/* ---- page ---- */
.content {
    padding: 1rem 1.5rem 2rem;
    background: transparent;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

h1 {
    font-size: 1.625rem;
    letter-spacing: -0.01em;
    margin-top: 0;
}

h1:focus {
    outline: none;
}

h2 {
    font-size: 1.3rem;
    letter-spacing: -0.005em;
}

h3 {
    font-size: 1.125rem;
}

h5 {
    font-size: 1rem;
}

.text-muted, .form-text {
    color: var(--text-2) !important;
}

/* ---- forms ---- */
.form-control, .form-select {
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    padding: 0.45rem 0.75rem;
    font-size: 0.95rem;
    color: var(--text);
    background-color: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(11, 107, 203, 0.18);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(11, 107, 203, 0.18);
    outline: none;
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* validation */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--s-resolved);
}

.invalid {
    outline: 1px solid var(--attn);
}

.validation-message {
    color: var(--attn-text);
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: block;
}

.blazor-error-boundary {
    background: #FFF4D6;
    padding: 1rem;
    border-radius: var(--r-md);
    border-left: 4px solid var(--s-progress);
    color: #664d03;
    margin: 1rem;
}

.blazor-error-boundary::after {
    content: "Something went wrong on this page. Reload to try again.";
    display: block;
    font-weight: 600;
}

/* ---- panels: a hairline, no shadow, no hover lift ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: none;
    overflow: hidden;
}

.card-header {
    background: var(--surface);
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
}

.card-header h2, .card-header h5 {
    margin: 0;
}

.card-body {
    padding: 1rem;
}

.card-footer {
    background: var(--paper);
    padding: 0.85rem 1.1rem;
    border-top: 1px solid var(--line);
}

/* ---- tables ---- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-hover-bg: transparent;
    --bs-table-hover-color: var(--text);
    margin-bottom: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
}

.table-responsive {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}

thead {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

th {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-2);
    white-space: nowrap;
}

td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--line);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover > td {
    background-color: rgba(11, 107, 203, 0.035);
}

/* ---- chips: state, priority, reasons ---- */
.chip, .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0.55rem;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}

/* state: soft fill with a dot in the rail colour */
.chip-status::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.chip-status.s-open { background: #E6EEFD; color: #1A4FC4; }
.chip-status.s-progress { background: #FBF0D2; color: #8A5F00; }
.chip-status.s-waiting { background: #DDF3F5; color: #0A6E78; }
.chip-status.s-resolved { background: #DFF3E8; color: #17704A; }
.chip-status.s-closed { background: #ECEEF2; color: var(--text-2); }

/* priority: outline only, so it never reads as a state; critical is the one solid chip */
.chip-priority {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text-2);
}

.chip-priority.p-high { border-color: #E0B040; color: #8A5F00; }
.chip-priority.p-critical { background: var(--attn); border-color: var(--attn); color: #fff; }

/* why a ticket needs attention */
.chip-reason {
    background: var(--attn-soft);
    border-color: #F3C4C8;
    color: var(--attn-text);
}

.chip-quiet {
    background: #ECEEF2;
    color: var(--text-2);
}

/* other Bootstrap badges (KB, users): soft instead of saturated */
.badge.bg-primary { background: #E6EEFD !important; color: #1A4FC4 !important; }
.badge.bg-success { background: #DFF3E8 !important; color: #17704A !important; }
.badge.bg-warning { background: #FBF0D2 !important; color: #8A5F00 !important; }
.badge.bg-danger { background: var(--attn-soft) !important; color: var(--attn-text) !important; }
.badge.bg-info { background: #DDF3F5 !important; color: #0A6E78 !important; }
.badge.bg-secondary, .badge.bg-light { background: #ECEEF2 !important; color: var(--text-2) !important; }

/* ---- alerts ---- */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    border-left: 4px solid;
    margin-bottom: 1rem;
    font-size: 0.93rem;
}

.alert-primary, .alert-info {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: #0A4A8F;
}

.alert-success {
    background: #E5F4EC;
    border-color: var(--s-resolved);
    color: #14633F;
}

.alert-danger {
    background: var(--attn-soft);
    border-color: var(--attn);
    color: var(--attn-text);
}

.alert-warning {
    background: #FFF4D6;
    border-color: var(--s-progress);
    color: #664d03;
}

/* Markdown Content Styling */
.markdown-content {
    line-height: 1.7;
    color: var(--text-primary);
}

.markdown-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.markdown-content h2 {
    font-size: 1.625rem;
    font-weight: 700;
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-color);
}

.markdown-content h3 {
    font-size: 1.375rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem 0;
}

.markdown-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
}

.markdown-content h5, .markdown-content h6 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
}

.markdown-content p {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.markdown-content ul, .markdown-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.markdown-content li {
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.markdown-content ul ul, .markdown-content ol ul,
.markdown-content ul ol, .markdown-content ol ol {
    margin-top: 0.35rem;
    margin-bottom: 0.35rem;
}

.markdown-content code {
    background-color: var(--bg-lighter);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: #c7254e;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    border: 1px solid #f0eded;
}

.markdown-content pre {
    background-color: var(--bg-lighter);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    line-height: 1.5;
}

.markdown-content pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
    font-size: 0.9rem;
    border: none;
}

.markdown-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-style: italic;
    background-color: rgba(13, 153, 255, 0.03);
    padding: 0.75rem 1rem;
    border-radius: 0 6px 6px 0;
}

.markdown-content table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.markdown-content table th,
.markdown-content table td {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
}

.markdown-content table th {
    background-color: var(--bg-light);
    font-weight: 600;
    color: var(--text-primary);
}

.markdown-content table tr:nth-child(even) {
    background-color: rgba(13, 153, 255, 0.02);
}

.markdown-content a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.markdown-content a:hover {
    border-bottom-color: var(--primary-color);
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: block;
}

.markdown-content hr {
    margin: 2rem 0;
    border: 0;
    border-top: 1px solid var(--border-color);
}

.markdown-content strong {
    font-weight: 700;
    color: var(--text-primary);
}

.markdown-content em {
    font-style: italic;
}

/* Utilities */
.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--text-secondary);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Print Styles */
@media print {
    body {
        background-color: white;
    }

    .btn, .card {
        box-shadow: none;
    }
}

/* ---- ticket queue (Manage Tickets and My Tickets) ---- */

.queue-tabs {
    border-bottom: 1px solid var(--line);
    gap: 0.25rem;
}

.queue-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 0.85rem;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--text-2);
    font-weight: 500;
    cursor: pointer;
}

.queue-tabs .nav-link:hover {
    color: var(--text);
}

.queue-tabs .nav-link.active {
    background: none;
    color: var(--text);
    font-weight: 600;
    border-bottom-color: var(--accent);
}

/* the state rail: left edge colour says what state the ticket is in */
.queue-table td.stripe {
    border-left: 4px solid var(--line-strong);
    padding-left: 0.85rem;
    white-space: nowrap;
}

.queue-table tr.state-open td.stripe { border-left-color: var(--s-open); }
.queue-table tr.state-progress td.stripe { border-left-color: var(--s-progress); }
.queue-table tr.state-waiting td.stripe { border-left-color: var(--s-waiting); }
.queue-table tr.state-resolved td.stripe { border-left-color: var(--s-resolved); }
.queue-table tr.state-closed td.stripe { border-left-color: var(--s-closed); }

/* needs attention overrides the rail: red edge and a faint tint */
.queue-table tr.needs-attention > td { background-color: rgba(214, 54, 63, 0.045); }
.queue-table tr.needs-attention td.stripe { border-left-color: var(--attn); }

/* resolved and closed recede */
.queue-table tr.is-done > td { opacity: 0.7; }

.status-select.status-open { border-color: var(--s-open); }
.status-select.status-progress { border-color: var(--s-progress); }
.status-select.status-waiting { border-color: var(--s-waiting); }
.status-select.status-resolved { border-color: var(--s-resolved); }
.status-select.status-closed { border-color: var(--s-closed); }

.ticket-title-link {
    color: var(--text);
    font-weight: 600;
}

.ticket-title-link:hover {
    color: var(--accent);
}

.ticket-meta {
    margin-top: 0.15rem;
    color: var(--text-2);
    font-size: 0.85rem;
}


/* ---- nav icons (shared by the sidebar and the mobile tab bar) ---- */
.bi {
    display: inline-block;
    position: relative;
    width: 1.125rem;
    height: 1.125rem;
    margin-right: 0.625rem;
    top: -1px;
    background-size: cover;
}

.bi-house-door-fill-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
}

.bi-plus-square-fill-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
}

.bi-list-nested-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
}

.bi-lock-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2zM5 8h6a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1z'/%3E%3C/svg%3E");
}

.bi-person-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-person' viewBox='0 0 16 16'%3E%3Cpath d='M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0Zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4Zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664h10Z'/%3E%3C/svg%3E");
}

.bi-person-badge-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-person-badge' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 2a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1h-3zM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0z'/%3E%3Cpath d='M4.5 0A2.5 2.5 0 0 0 2 2.5V14a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2.5A2.5 2.5 0 0 0 11.5 0h-7zM3 2.5A1.5 1.5 0 0 1 4.5 1h7A1.5 1.5 0 0 1 13 2.5v10.795a4.2 4.2 0 0 0-.776-.492C11.392 12.387 10.063 12 8 12s-3.392.387-4.224.803a4.2 4.2 0 0 0-.776.492V2.5z'/%3E%3C/svg%3E");
}

.bi-person-fill-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-person-fill' viewBox='0 0 16 16'%3E%3Cpath d='M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3Zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z'/%3E%3C/svg%3E");
}

.bi-arrow-bar-left-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-arrow-bar-left' viewBox='0 0 16 16'%3E%3Cpath d='M12.5 15a.5.5 0 0 1-.5-.5v-13a.5.5 0 0 1 1 0v13a.5.5 0 0 1-.5.5ZM10 8a.5.5 0 0 1-.5.5H3.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L3.707 7.5H9.5a.5.5 0 0 1 .5.5Z'/%3E%3C/svg%3E");
}

/* Knowledge base icon to match other nav icons */
.bi-book-fill-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-book-fill' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.783C7.015.936 5.587.81 4.287.94c-1.514.153-3.042.672-3.994 1.105A.5.5 0 0 0 0 2.5v11a.5.5 0 0 0 .707.455c.882-.4 2.303-.881 3.68-1.02 1.409-.142 2.59.087 3.223.877a.5.5 0 0 0 .78 0c.633-.79 1.814-1.019 3.222-.877 1.378.139 2.8.62 3.681 1.02A.5.5 0 0 0 16 13.5v-11a.5.5 0 0 0-.293-.455c-.952-.433-2.48-.952-3.994-1.105C10.413.809 8.985.936 8 1.783z'/%3E%3C/svg%3E");
}

/* My tickets icon to match other nav icons */
.bi-ticket-fill-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-ticket-fill' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 3A1.5 1.5 0 0 0 0 4.5V6a.5.5 0 0 0 .5.5 1.5 1.5 0 1 1 0 3 .5.5 0 0 0-.5.5v1.5A1.5 1.5 0 0 0 1.5 13h13a1.5 1.5 0 0 0 1.5-1.5V10a.5.5 0 0 0-.5-.5 1.5 1.5 0 0 1 0-3A.5.5 0 0 0 16 6V4.5A1.5 1.5 0 0 0 14.5 3h-13Z'/%3E%3C/svg%3E");
}

/* Manage tickets (admin) */
.bi-gear-fill-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-gear-fill' viewBox='0 0 16 16'%3E%3Cpath d='M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872l-.1-.34ZM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858Z'/%3E%3C/svg%3E");
}

/* Manage KB (admin) */
.bi-pencil-square-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-pencil-square' viewBox='0 0 16 16'%3E%3Cpath d='M15.502 1.94a.5.5 0 0 1 0 .706l-1 1a.5.5 0 0 1-.706 0L13 3.207l1.146-1.147a.5.5 0 0 1 .708 0l.648.648Zm-1.75 2.456L6 12.098V13h.902l7.752-7.752-1.902-1.902ZM1 13.5A1.5 1.5 0 0 0 2.5 15h11A1.5 1.5 0 0 0 15 13.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11Z'/%3E%3C/svg%3E");
}

/* Manage Products (admin) */
.bi-box-seam-fill-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M8 .5 14.5 3.7v8.6L8 15.5 1.5 12.3V3.7L8 .5Zm0 1.1L3.3 3.9 8 6.2l4.7-2.3L8 1.6ZM2.5 4.8v6.9l5 2.4V7.2l-5-2.4Zm6 2.4v6.9l5-2.4V4.8l-5 2.4Z'/%3E%3C/svg%3E");
}

/* Manage Users (admin) */
.bi-people-fill-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-people-fill' viewBox='0 0 16 16'%3E%3Cpath d='M7 14s-1 0-1-1 1-4 5-4 5 3 5 4-1 1-1 1H7Zm4-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm-5.784 6A2.238 2.238 0 0 1 5 13c0-1.355.68-2.75 1.936-3.72A6.325 6.325 0 0 0 5 9c-4 0-5 3-5 4s1 1 1 1h4.216ZM4.5 8a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z'/%3E%3C/svg%3E");
}

/* Admin Settings */
.bi-sliders-nav-menu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-sliders' viewBox='0 0 16 16'%3E%3Cpath d='M11.5 2a.5.5 0 0 1 .5.5V4h2a.5.5 0 0 1 0 1h-2v1.5a.5.5 0 0 1-1 0V5H2a.5.5 0 0 1 0-1h9V2.5a.5.5 0 0 1 .5-.5Zm-7 5a.5.5 0 0 1 .5.5V9h9a.5.5 0 0 1 0 1H5v1.5a.5.5 0 0 1-1 0V10H2a.5.5 0 0 1 0-1h2V7.5a.5.5 0 0 1 .5-.5Zm7 5a.5.5 0 0 1 .5.5V14h2a.5.5 0 0 1 0 1h-2v1.5a.5.5 0 0 1-1 0V15H2a.5.5 0 0 1 0-1h9v-1.5a.5.5 0 0 1 .5-.5Z'/%3E%3C/svg%3E");
}


/* ================= responsive shell and mobile ================= */

/* Blazor shows this banner by setting display:block when an unhandled error occurs. */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    padding: 0.6rem 2.5rem 0.7rem 1rem;
    background: #fff3cd;
    color: #664d03;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* page toolbars: search + filters + actions */
.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.page-toolbar .toolbar-search {
    width: 22rem;
    max-width: 100%;
}

.page-toolbar .toolbar-select {
    width: 10rem;
}

/* queue tabs scroll sideways instead of wrapping */
.queue-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
}

.queue-tabs::-webkit-scrollbar {
    display: none;
}

.queue-tabs .nav-item {
    flex: 0 0 auto;
}

/* phone ticket list: two-line rows (title, then badges and meta) */
.ticket-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ticket-item {
    display: block;
    padding: 0.7rem 0.85rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-left: 5px solid #6c757d;
    border-radius: var(--r-md);
    color: inherit;
    text-decoration: none;
}

.ticket-item:hover {
    color: inherit;
    text-decoration: none;
    background: var(--bg-light);
}

.ticket-item.state-open { border-left-color: var(--s-open); }
.ticket-item.state-progress { border-left-color: var(--s-progress); }
.ticket-item.state-waiting { border-left-color: var(--s-waiting); }
.ticket-item.state-resolved { border-left-color: var(--s-resolved); }
.ticket-item.state-closed { border-left-color: var(--s-closed); }
.ticket-item.needs-attention { background: #FEF5F6; border-left-color: var(--attn); }
.ticket-item.is-done { opacity: 0.7; }

.ticket-item-title {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-weight: 600;
    line-height: 1.3;
}

.ticket-item-id {
    flex: none;
    color: var(--text-secondary);
    font-weight: 500;
}

.ticket-item-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.ticket-item-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 0.4rem;
    margin-top: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* bottom tab bar and More sheet: hidden on larger screens */
.tabbar, .more-sheet, .more-backdrop, .more-toggle {
    display: none;
}

@media (max-width: 767.98px) {
    /* the content card and its nested containers used to stack three paddings */
    .content {
        margin: 0;
        padding: 0.75rem 0.75rem calc(5rem + env(safe-area-inset-bottom));
        border-radius: 0;
    }

    .content > .container,
    .content > .container-fluid {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
        margin-top: 0.25rem !important;
    }

    h1 {
        font-size: 1.5rem;
        margin-top: 0.5rem;
    }

    .page-toolbar {
        width: 100%;
    }

    .page-toolbar .toolbar-search {
        flex: 1 1 100%;
        width: 100%;
    }

    .page-toolbar .toolbar-select {
        flex: 1 1 8rem;
        width: auto;
    }

    .page-toolbar .btn {
        flex: 1 1 auto;
    }

    /* bottom tab bar */
    .tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1033;
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--ink);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    }

    .tab {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        color: #aab0c0;
        font-size: 0.68rem;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .tab:hover {
        color: #fff;
        text-decoration: none;
    }

    .tab .bi {
        margin: 0;
        top: 0;
        width: 1.35rem;
        height: 1.35rem;
        opacity: 0.7;
    }

    .tab.active {
        color: #fff;
        box-shadow: inset 0 3px 0 #6DB3F2;
    }

    .tab.active .bi {
        opacity: 1;
    }

    .tab-label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .more-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1031;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .more-toggle:checked ~ .more-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .more-sheet {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
        z-index: 1032;
        max-height: 70vh;
        overflow-y: auto;
        padding: 0.5rem 0.75rem 1rem;
        background: var(--ink);
        border-radius: 14px 14px 0 0;
        transform: translateY(110%);
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0.2s;
    }

    .more-toggle:checked ~ .more-sheet {
        transform: none;
        visibility: visible;
    }

    .more-sheet-user {
        padding: 0.5rem 0.75rem;
        color: #9aa0b4;
        font-size: 0.8rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .more-link {
        display: flex;
        align-items: center;
        width: 100%;
        min-height: 3rem;
        padding: 0 0.75rem;
        border: none;
        border-radius: 8px;
        background: none;
        color: #e8eaef;
        font-size: 1rem;
        text-decoration: none;
    }

    .more-link:hover {
        color: #fff;
        text-decoration: none;
        background: rgba(255, 255, 255, 0.08);
    }

    .more-link.active {
        background: rgba(13, 153, 255, 0.25);
    }

    .more-link .bi {
        margin-right: 0.75rem;
    }

    /* forms: the submit bar stays reachable above the tab bar */
    .form-actions {
        position: sticky;
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
        z-index: 5;
        display: flex;
        gap: 0.5rem;
        padding: 0.75rem 0;
        background: linear-gradient(to top, var(--paper) 75%, rgba(245, 246, 248, 0));
    }

    .form-actions .btn {
        flex: 1 1 0;
        margin-left: 0 !important;
    }
}

/* touch targets: phones and any touch screen */
@media (max-width: 767.98px), (pointer: coarse) {
    .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-sm {
        min-height: 40px;
    }

    /* 16px stops iOS zooming into the field on focus */
    .form-control, .form-select {
        min-height: 44px;
        font-size: 16px;
    }

    .form-control-sm, .form-select-sm {
        min-height: 40px;
        font-size: 16px;
    }

    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }

    .nav-tabs .nav-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
    }
}

/* motion answers an action; people who ask for less get none */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .more-sheet {
        transition: none;
    }
}

.chip-note {
    background: #FBF0D2;
    color: #8A5F00;
}

.ticket-item-who {
    color: var(--text);
    font-weight: 500;
}

/* ================= page patterns shared across the site ================= */

/* tighter vertical rhythm: pages start at the top of the content area */
.content > .container,
.content > .container-fluid {
    margin-top: 0 !important;
}

.content > .container-fluid {
    padding-left: 0;
    padding-right: 0;
}

.card-body > :first-child,
.card-body > .card-title {
    margin-top: 0;
}

.card-title {
    margin-top: 0;
    margin-bottom: 0.4rem;
}

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

/* title on the left, primary action on the right; wraps on a narrow screen */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}

.page-head h1 {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* home */
.home-hero {
    padding: 1.5rem 0 1.25rem;
    max-width: 40rem;
}

.home-hero h1 {
    font-size: 2rem;
    margin-bottom: 0.4rem;
}

.home-lead {
    color: var(--text-2);
    font-size: 1.05rem;
    margin: 0;
}

/* ticket page: the ticket is the card, its state is the rail */
.ticket-card {
    border-left: 4px solid var(--line-strong);
}

.ticket-card.state-open { border-left-color: var(--s-open); }
.ticket-card.state-progress { border-left-color: var(--s-progress); }
.ticket-card.state-waiting { border-left-color: var(--s-waiting); }
.ticket-card.state-resolved { border-left-color: var(--s-resolved); }
.ticket-card.state-closed { border-left-color: var(--s-closed); }

.ticket-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.ticket-description {
    max-width: 70ch;
    margin-bottom: 1rem;
    white-space: pre-wrap;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.75rem 1.5rem;
    margin: 0;
    padding-top: 0.85rem;
    border-top: 1px solid var(--line);
}

.detail-grid dt {
    color: var(--text-2);
    font-size: 0.82rem;
    font-weight: 500;
}

.detail-grid dd {
    margin: 0;
    font-weight: 500;
}

.handling {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.75rem 1.5rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--line);
}

.handling .form-label {
    font-size: 0.82rem;
    color: var(--text-2);
}

.handling .form-label strong {
    font-weight: 500;
}

/* account settings: pill navigation in the accent colour */
.nav-pills {
    --bs-nav-pills-link-active-bg: var(--accent);
    --bs-nav-pills-border-radius: var(--r-md);
}

/* comments and list groups on the ticket page */
.list-group-item {
    border-color: var(--line);
}

/* data tables that become one card per row on a phone */
@media (max-width: 767.98px) {
    .table-responsive:has(> .table-stack) {
        background: none;
        border: none;
        overflow: visible;
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }

    .table-stack thead {
        display: none;
    }

    .table-stack tr {
        margin-bottom: 0.6rem;
        padding: 0.55rem 0.85rem;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--r-md);
    }

    .table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        padding: 0.25rem 0;
        border: none;
        text-align: right;
    }

    .table-stack td::before {
        content: attr(data-label);
        flex: 0 0 5.5rem;
        color: var(--text-2);
        font-size: 0.85rem;
        text-align: left;
    }

    .table-stack td[data-label=""]::before {
        display: none;
    }

    .table-stack tbody tr:hover > td {
        background: none;
    }

    .table-stack td.stack-title {
        font-weight: 600;
        justify-content: flex-start;
        text-align: left;
        padding-bottom: 0.35rem;
    }

    .table-stack td.stack-title::before {
        display: none;
    }

    .table-stack td.stack-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.4rem;
        padding-top: 0.5rem;
        margin-top: 0.25rem;
        border-top: 1px solid var(--line);
    }

    .table-stack td.stack-actions .btn {
        flex: 1 1 auto;
    }

    /* the account settings menu becomes a row you scroll sideways */
    .nav-pills.flex-column {
        flex-direction: row !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 0.25rem;
        padding-bottom: 0.25rem;
        scrollbar-width: none;
    }

    .nav-pills.flex-column .nav-link {
        white-space: nowrap;
    }

    .home-hero {
        padding-top: 0.5rem;
    }

    .home-hero h1 {
        font-size: 1.6rem;
    }
}

.back-link {
    display: inline-block;
    margin-bottom: 0.35rem;
    color: var(--text-2);
    font-size: 0.9rem;
}

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

/* the last paragraph in a panel should not add its own gap */
.card-body p:last-child {
    margin-bottom: 0;
}

/* queue controls keep a readable width; the ticket column takes what is left */
.queue-table .status-select {
    min-width: 8.75rem;
}

.queue-table td .d-flex > .form-select {
    min-width: 8rem;
}

@media (max-width: 575.98px) {
    .detail-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---- home dashboard ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-tile {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.7rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    border-radius: var(--r-md);
    color: var(--text);
    text-decoration: none;
}

.stat-tile:hover {
    color: var(--text);
    text-decoration: none;
    background: var(--paper);
}

.stat-num {
    font-size: 1.9rem;
    font-weight: 600;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    color: var(--text-2);
    font-size: 0.88rem;
}

.tile-attention.has-items { border-left-color: var(--attn); background: #FEF5F6; }
.tile-attention.has-items .stat-num { color: var(--attn-text); }
.tile-active { border-left-color: var(--s-open); }
.tile-assigned { border-left-color: var(--s-progress); }
.tile-resolved { border-left-color: var(--s-resolved); }

.dash-section {
    margin-bottom: 1.25rem;
}

.dash-section .ticket-list {
    max-width: 60rem;
}

.dash-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.dash-section-head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.dash-empty {
    margin: 0;
    padding: 0.75rem 1rem;
    max-width: 60rem;
    color: var(--text-2);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.dash-footer {
    margin-top: 1.5rem;
    color: var(--text-2);
}

@media (max-width: 575.98px) {
    .stat-tile {
        padding: 0.5rem 0.8rem;
    }

    .stat-num {
        font-size: 1.5rem;
    }
}

/* ---------- Fungusware star: fixed to the background, content scrolls over it ---------- */

body::before {
    content: "";
    position: fixed; right: -70px; bottom: -70px; z-index: -1;
    width: min(560px, 60vw); aspect-ratio: 1;
    background: url("fungusware-star.svg") no-repeat center / contain;
    opacity: .12;
    pointer-events: none;
}
@media print { body::before { display: none; } }
html { background-color: var(--paper); }
body { background-color: transparent; }
