:root {
    color-scheme: dark;
    --bg: #0a0a0c;
    --surface: #121216;
    --surface-2: #17171c;
    --surface-3: #1d1d24;
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .16);
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --faint: #6b6b76;
    --accent: #2dd4bf;
    --accent-bright: #7af2e3;
    --accent-deep: #0e9488;
    --accent-soft: rgba(45, 212, 191, .1);
    --accent-border: rgba(45, 212, 191, .3);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .09);
    --danger-border: rgba(248, 113, 113, .28);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, .09);
    --success-border: rgba(74, 222, 128, .24);
    --radius: 16px;
    --radius-sm: 10px;
    --mono: "Cascadia Code", "SF Mono", Consolas, monospace;
    --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-family: var(--sans);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-feature-settings: "cv02", "cv11";
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

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

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

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

h1, h2, h3, p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(32px, 5vw, 44px);
    line-height: 1.1;
    letter-spacing: -.03em;
}

h2 {
    margin-bottom: 8px;
    font-size: 22px;
    letter-spacing: -.02em;
}

h3 {
    letter-spacing: -.015em;
}

.hidden {
    display: none !important;
}

.site-header {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 0 max(24px, calc((100vw - 1120px) / 2));
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 12, .92);
    backdrop-filter: blur(14px);
}

.brand, .header-nav, .inline-actions, .form-actions, .label-row {
    display: flex;
    align-items: center;
}

.brand {
    gap: 12px;
}

.brand-logo {
    width: auto;
    height: 40px;
    image-rendering: pixelated;
}

.brand-copy {
    display: grid;
    line-height: 1.25;
}

.brand-copy strong {
    font-size: 15px;
}

.brand-copy small {
    color: var(--muted);
    font-size: 12px;
}

.header-nav {
    gap: 8px;
}

.nav-link {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, .03);
    font-size: 13px;
    font-weight: 550;
}

.nav-link:hover {
    border-color: var(--border-strong);
    color: var(--text);
    background: rgba(255, 255, 255, .06);
}

.page-shell {
    width: min(1120px, calc(100% - 48px));
    margin: 0 auto;
    padding: 58px 0 100px;
}

.page-intro {
    margin-bottom: 46px;
}

.page-intro p, .panel-heading p, .ticket-toolbar p, .empty-panel p {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.6;
}

.page-intro p {
    max-width: 560px;
    font-size: 16px;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 14px;
    padding: 4px 11px;
    border: 1px solid var(--accent-border);
    border-radius: 999px;
    color: var(--accent-bright);
    background: var(--accent-soft);
    font-size: 12px;
    font-weight: 650;
}

.section-heading, .panel-heading, .admin-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.section-heading {
    margin-bottom: 20px;
}

.section-heading h2, .section-heading p, .panel-heading h2 {
    margin-bottom: 0;
}

.ticket-toolbar p {
    font-size: 13px;
}

.primary-button, .secondary-button, .danger-button, .text-button {
    min-height: 42px;
    padding: 0 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 650;
}

.primary-button {
    border: 1px solid var(--accent);
    color: #071311;
    background: var(--accent);
}

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

.secondary-button {
    border: 1px solid var(--border-strong);
    color: var(--text);
    background: var(--surface-3);
}

.secondary-button:hover {
    border-color: rgba(255, 255, 255, .25);
    background: #24242c;
}

.danger-button {
    border: 1px solid var(--danger-border);
    color: var(--danger);
    background: var(--danger-soft);
}

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

.text-button {
    min-height: 36px;
    padding: 0 10px;
    border: 0;
    color: var(--muted);
    background: transparent;
}

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

.panel, .empty-panel, .loading-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.panel {
    padding: 28px;
}

.panel-heading {
    margin-bottom: 26px;
}

.empty-panel, .loading-card {
    padding: 42px;
    text-align: center;
}

.empty-panel h2, .empty-panel h3 {
    margin-bottom: 8px;
}

.empty-panel .primary-button {
    margin-top: 22px;
}

.empty-panel.compact {
    padding: 36px;
}

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

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

.type-card {
    display: flex;
    min-height: 220px;
    flex-direction: column;
    align-items: flex-start;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--surface-2);
    text-align: left;
    transition: border-color .15s ease, transform .15s ease, background .15s ease;
}

.type-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-border);
    background: var(--surface-3);
}

.type-card strong {
    margin: 18px 0 8px;
    font-size: 18px;
}

.type-card p {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.type-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--accent-border);
    border-radius: 9px;
    color: var(--accent-bright);
    background: var(--accent-soft);
    font-weight: 800;
}

.card-action {
    margin-top: auto;
    color: var(--accent-bright);
    font-size: 13px;
    font-weight: 650;
}

.type-description {
    margin-bottom: 24px;
    padding: 16px 18px;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--muted);
    background: var(--accent-soft);
    font-size: 14px;
    line-height: 1.6;
}

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

.field {
    display: grid;
    align-content: start;
    gap: 8px;
}

.field.full, .form-actions {
    grid-column: 1 / -1;
}

.field label, .field legend, .message-form label {
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
}

.field label span {
    color: var(--faint);
    font-weight: 500;
}

.field small, .label-row span {
    color: var(--faint);
    font-size: 12px;
    line-height: 1.5;
}

.coordinate-field {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

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

.field.invalid input, .field.invalid textarea, .field.invalid select,
input.input-error, textarea.input-error, select.input-error {
    border-color: var(--danger);
    outline: 1px solid var(--danger);
}

.field .field-error, .input-error-message {
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
}

.label-row {
    justify-content: space-between;
    gap: 16px;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: #0d0d10;
}

input, select {
    min-height: 44px;
    padding: 0 13px;
}

textarea {
    min-height: 120px;
    padding: 12px 13px;
    line-height: 1.55;
    resize: vertical;
}

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

.form-actions {
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

.ticket-list {
    display: grid;
    gap: 10px;
}

.ticket-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    width: 100%;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: var(--surface);
    text-align: left;
    transition: border-color .15s ease, background .15s ease;
}

.ticket-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.ticket-card.requires-response {
    border-color: var(--accent-border);
}

.ticket-card-status {
    display: grid;
    justify-items: start;
    gap: 7px;
}

.response-required-badge {
    display: inline-flex;
    padding: 4px 8px;
    border: 1px solid var(--danger-border);
    border-radius: 999px;
    color: var(--danger);
    background: var(--danger-soft);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.ticket-card-main {
    min-width: 0;
}

.ticket-card-main strong {
    font-size: 15px;
}

.ticket-card-main p {
    overflow: hidden;
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket-card-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px 14px;
    color: var(--faint);
    font-size: 12px;
}

.status-badge {
    display: inline-flex;
    width: max-content;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.status-badge.open {
    border: 1px solid var(--success-border);
    color: var(--success);
    background: var(--success-soft);
}

.status-badge.closed {
    border: 1px solid var(--border-strong);
    color: var(--muted);
    background: rgba(255, 255, 255, .04);
}

.modal-backdrop {
    position: fixed;
    z-index: 100;
    inset: 0;
    overflow-y: auto;
    padding: 36px 20px;
    background: rgba(0, 0, 0, .76);
}

.modal {
    position: relative;
    width: min(540px, 100%);
    margin: 4vh auto;
    padding: 28px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
}

.ticket-dialog {
    width: min(820px, 100%);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    color: var(--muted);
    background: transparent;
    font-size: 26px;
    line-height: 1;
}

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

.auth-modal {
    text-align: center;
}

.auth-modal h2 {
    margin: 4px 0 10px;
}

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

.auth-modal .muted {
    font-size: 14px;
    line-height: 1.6;
}

.auth-content .primary-button, .account-logout {
    width: 100%;
}

.auth-status {
    margin: 0;
    color: var(--accent-bright);
    font-size: 13px;
}

.auth-status.error {
    margin-bottom: 18px;
    color: var(--danger);
}

.auth-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.account-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 22px 0;
    text-align: left;
}

.account-summary span {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.account-summary small {
    color: var(--faint);
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.command {
    display: block;
    margin: 22px 0 18px;
    padding: 16px;
    border: 1px dashed var(--accent-border);
    border-radius: var(--radius-sm);
    color: var(--accent-bright);
    background: var(--bg);
    font-family: var(--mono);
    font-size: clamp(17px, 4.5vw, 22px);
    font-weight: 700;
    cursor: copy;
}

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

.command-hint {
    display: block;
    margin: -8px 0 16px;
    color: var(--faint);
    font-size: 12px;
}

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

.dialog-heading {
    padding-right: 42px;
}

.dialog-heading h2 {
    margin: 12px 0 5px;
}

.dialog-heading p {
    margin-bottom: 0;
    color: var(--faint);
    font-size: 13px;
}

.ticket-back-link {
    display: inline-flex;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

#ticket-view {
    width: min(900px, 100%);
    margin: 0 auto;
}

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

.ticket-page-panel {
    width: min(900px, 100%);
    margin: 0 auto;
}

.ticket-page-panel .dialog-heading h1 {
    margin: 12px 0 5px;
    font-size: clamp(28px, 5vw, 38px);
}

.response-required-notice {
    margin-top: 24px;
    padding: 16px 18px;
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
}

.response-required-notice strong {
    color: var(--danger);
    font-size: 14px;
}

.response-required-notice p {
    margin: 5px 0 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.55;
}

.ticket-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    margin: 24px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--border);
}

.ticket-details div {
    min-width: 0;
    padding: 13px 15px;
    background: var(--surface-2);
}

.ticket-details .wide {
    grid-column: 1 / -1;
}

.ticket-details dt {
    margin-bottom: 4px;
    color: var(--faint);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.ticket-details dd {
    overflow-wrap: anywhere;
    margin: 0;
    color: var(--text);
    font-size: 13px;
    white-space: pre-wrap;
}

.conversation {
    display: grid;
    gap: 12px;
    margin: 26px 0;
}

.message {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.message.staff {
    border-color: var(--accent-border);
    /*    background: var(--accent-soft);  */
}

   .message header {
       display: flex;
       align-items: baseline;
       justify-content: space-between;
       gap: 14px;
       margin-bottom: 10px;
   }

   .message header strong {
       font-size: 13px;
   }

   .message header span {
       color: var(--faint);
       font-size: 11px;
   }

   .message-body {
       overflow-wrap: anywhere;
       color: #d6d6da;
       font-size: 14px;
       line-height: 1.65;
   }

   .message-body a {
       color: var(--accent-bright);
       text-decoration: underline;
       text-underline-offset: 2px;
   }

   .message-body blockquote {
       margin: 6px 0;
       padding: 7px 12px;
       border-left: 3px solid var(--accent-deep);
       color: var(--muted);
       background: rgba(0, 0, 0, .14);
   }

   .message-form {
       display: grid;
       gap: 10px;
       padding-top: 22px;
       border-top: 1px solid var(--border);
   }

   .closed-notice {
       padding: 17px;
       border: 1px solid var(--danger-border);
       border-radius: var(--radius-sm);
       background: var(--danger-soft);
   }

   .closed-notice strong {
       color: var(--danger);
       font-size: 13px;
   }

   .closed-notice p {
       margin: 7px 0;
       color: var(--text);
       font-size: 14px;
       line-height: 1.55;
   }

   .closed-notice span {
       color: var(--faint);
       font-size: 11px;
   }

   .toast {
       position: fixed;
       z-index: 200;
       right: 24px;
       bottom: 24px;
       max-width: min(380px, calc(100vw - 48px));
       padding: 13px 16px;
       border: 1px solid var(--accent-border);
       border-radius: var(--radius-sm);
       color: var(--text);
       background: var(--surface-3);
       opacity: 0;
       transform: translateY(8px);
       pointer-events: none;
       transition: opacity .16s ease, transform .16s ease;
       font-size: 13px;
   }

   .toast.visible {
       opacity: 1;
       transform: translateY(0);
   }

   .toast.error {
       border-color: var(--danger-border);
   }

   .site-footer {
       padding: 28px max(24px, calc((100vw - 1120px) / 2)) 36px;
       border-top: 1px solid var(--border);
       color: var(--faint);
       font-size: 13px;
   }

   /* Staff ticket list */

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

.admin-home-card {
    display: flex;
    min-height: 230px;
    flex-direction: column;
    align-items: flex-start;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color .15s ease, transform .15s ease, background .15s ease;
}

.admin-home-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-border);
    background: var(--surface-2);
}

.admin-home-card strong {
    margin: 18px 0 8px;
    font-size: 19px;
}

.admin-home-card p {
    margin-bottom: 20px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.admin-home-card .card-action {
    margin-top: auto;
}

.admin-heading {
    align-items: center;
    margin-bottom: 26px;
}

.admin-heading h1 {
    margin-bottom: 6px;
}

.admin-heading p {
    margin-bottom: 0;
    color: var(--muted);
}

.staff-role {
    color: var(--accent-bright);
    font-size: 12px;
    font-weight: 650;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(140px, 190px));
    gap: 10px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.filter-bar input, .filter-bar select {
    min-height: 40px;
    font-size: 13px;
}

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

.staff-ticket {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.staff-ticket:hover, .staff-ticket.expanded {
    border-color: var(--border-strong);
}

.staff-ticket.unviewed, .staff-ticket.unviewed:hover {
    border-color: var(--success);
}

.staff-ticket-summary {
    display: grid;
    grid-template-columns: minmax(190px, .7fr) minmax(260px, 1.5fr) auto;
    gap: 24px;
    width: 100%;
    padding: 18px 20px;
    border: 0;
    color: var(--text);
    background: transparent;
    text-align: left;
}

.staff-identity strong {
    font-size: 15px;
}

.staff-meta, .staff-ticket-time {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 11px;
    margin-top: 7px;
    color: var(--faint);
    font-size: 11px;
}

.staff-preview {
    min-width: 0;
}

.staff-preview strong {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
}

.staff-preview p {
    display: -webkit-box;
    overflow: hidden;
    margin-bottom: 0;
    color: #d2d2d6;
    font-size: 13px;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.staff-ticket-time {
    justify-content: flex-end;
    text-align: right;
}

.staff-ticket-detail {
    padding: 0 20px 22px;
    border-top: 1px solid var(--border);
}

.staff-detail-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 0 0;
}

.staff-detail-heading p {
    margin: 0;
    color: var(--faint);
    font-size: 12px;
}

.staff-compose {
    display: grid;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.close-form {
    display: grid;
    max-width: 850px;
    gap: 10px;
    margin-top: 14px;
    padding: 16px;
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
}

.result-count {
    margin: 12px 2px 0;
    color: var(--faint);
    font-size: 12px;
}

@media (max-width: 820px) {
    .filter-bar {
        grid-template-columns: 1fr 1fr;
    }

    .filter-bar input {
        grid-column: 1 / -1;
    }

    .staff-ticket-summary {
        grid-template-columns: 1fr;
        gap: 13px;
    }

    .staff-ticket-time {
        justify-content: flex-start;
        text-align: left;
    }
}

@media (max-width: 640px) {
    .site-header {
        padding: 0 16px;
    }

    .brand-copy small, .header-nav .nav-link:first-child {
        display: none;
    }

    .page-shell {
        width: min(100% - 28px, 1120px);
        padding-top: 38px;
    }

    .page-intro {
        margin-bottom: 34px;
    }

    .section-heading, .panel-heading, .admin-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .ticket-toolbar .primary-button {
        width: 100%;
    }

    .panel {
        padding: 20px;
    }

    .type-grid, .ticket-form, .ticket-details, .admin-home-grid, .coordinate-grid {
        grid-template-columns: 1fr;
    }

    .ticket-details .wide {
        grid-column: auto;
    }

    .ticket-card {
        grid-template-columns: 1fr;
        gap: 11px;
    }

    .ticket-card-meta {
        justify-content: flex-start;
    }

    .modal-backdrop {
        padding: 12px;
    }

    .modal {
        margin: 0 auto;
        padding: 22px 18px;
    }

    .message header {
        align-items: flex-start;
        flex-direction: column;
        gap: 3px;
    }

    .form-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .form-actions button {
        width: 100%;
    }

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

    .filter-bar input {
        grid-column: auto;
    }
}
