:root {
    --bg-page: #0f2436;
    --bg-panel: #243b50;
    --bg-panel-soft: #2b4861;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-card-strong: rgba(255, 255, 255, 0.1);
    --bg-light: #f4f7fb;
    --text-light: #f7f9fc;
    --text-muted: rgba(247, 249, 252, 0.74);
    --text-dark: #163041;
    --line-light: rgba(255, 255, 255, 0.12);
    --line-dark: rgba(18, 35, 49, 0.12);
    --accent: #d5d9e3;
    --accent-dark: #12202d;
    --success: #57c084;
    --warning: #efb45b;
    --danger: #df6f6f;
    --info: #69a7ff;
    --shadow: 0 30px 70px rgba(7, 18, 28, 0.28);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --max-width: 1320px;
    font-family: Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top, rgba(73, 112, 149, 0.22), transparent 35%),
        linear-gradient(180deg, #163149 0%, #102538 100%);
    color: var(--text-light);
}

body.is-portal-mode {
    background: #ffffff;
    color: var(--text-dark);
}

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

button,
input,
textarea {
    font: inherit;
}

.page {
    min-height: 100vh;
}

.app-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(circle at center, rgba(20, 32, 42, 0.2), rgba(8, 13, 18, 0.68)),
        rgba(8, 13, 18, 0.38);
    backdrop-filter: blur(12px);
}

.app-loading-overlay[hidden] {
    display: none !important;
}

.app-loading-shell {
    width: min(360px, calc(100vw - 2rem));
    display: grid;
    justify-items: center;
    gap: 0.7rem;
    padding: 1.35rem 1.2rem 1.1rem;
    border: 1px solid rgba(122, 173, 214, 0.2);
    border-radius: 1.2rem;
    background: linear-gradient(180deg, rgba(14, 23, 32, 0.92), rgba(19, 34, 48, 0.9));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
    text-align: center;
}

.app-loading-spinner {
    position: relative;
    width: 150px;
    height: 150px;
    display: grid;
    place-items: center;
}

.app-loading-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        conic-gradient(
            from 0deg,
            rgba(122, 173, 214, 0.14) 0deg,
            rgba(122, 173, 214, 0.95) 110deg,
            rgba(255, 255, 255, 0.9) 215deg,
            rgba(45, 79, 108, 0.95) 300deg,
            rgba(122, 173, 214, 0.14) 360deg
        );
    -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%);
    mask: radial-gradient(circle, transparent 58%, #000 60%);
    animation: app-loading-spin 1.15s linear infinite;
}

.app-loading-ring::after {
    content: "";
    position: absolute;
    inset: 17px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(15, 26, 35, 0.22), rgba(15, 26, 35, 0.74));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.app-loading-logo {
    position: relative;
    z-index: 1;
    width: 86px;
    max-width: 62%;
    filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.28));
}

.app-loading-title {
    font-size: 0.94rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(246, 248, 250, 0.92);
}

.app-loading-text {
    max-width: 28ch;
    font-size: 0.8rem;
    line-height: 1.45;
    color: rgba(246, 248, 250, 0.72);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(18, 35, 49, 0.08);
}

.nav-shell,
.portal-hero,
.portal-main {
    width: min(calc(100vw - 2rem), var(--max-width));
    margin: 0 auto;
}

.nav-shell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 0;
}

.nav-brand,
.nav-links a {
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    gap: 1.4rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.portal-hero {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    align-items: center;
    gap: 2.75rem;
    padding: clamp(4rem, 10vw, 7rem) 1rem 3rem;
}

.hero-copy {
    display: grid;
    gap: 1.5rem;
}

.portal-kicker,
.panel-kicker,
.detail-kicker,
.auth-kicker {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.76rem;
    font-weight: 700;
    opacity: 0.78;
}

.portal-hero h1,
.auth-title,
.state-copy h2,
.dashboard-topbar h2 {
    margin: 0;
    letter-spacing: -0.05em;
    line-height: 0.96;
}

.portal-hero h1 {
    font-size: clamp(2.6rem, 5vw, 4.5rem);
}

.portal-copy,
.panel-note,
.detail-text,
.auth-subtitle,
.state-copy p {
    margin: 0;
    line-height: 1.7;
}

.hero-points {
    display: grid;
    gap: 12px;
}

.hero-points span {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
}

.hero-logo-panel {
    display: grid;
    place-items: center;
    min-height: 420px;
}

.portal-logo,
.auth-logo {
    width: min(100%, 460px);
    max-width: 100%;
    object-fit: contain;
}

.portal-main {
    padding: 2rem 0 3rem;
}

.portal-main-qr {
    padding: 2.75rem 0;
}

.spa-shell {
    position: relative;
    width: min(calc(100vw - 2rem), var(--max-width));
    margin: 0 auto;
    padding: clamp(1.5rem, 3vw, 2.25rem);
    border: 1px solid var(--line-light);
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, rgba(37, 59, 80, 0.96), rgba(23, 39, 55, 0.98));
    box-shadow: var(--shadow);
    overflow: hidden;
}

.spa-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.08), transparent 30%),
        radial-gradient(circle at bottom left, rgba(102, 163, 224, 0.12), transparent 35%);
    pointer-events: none;
}

.auth-header,
.dashboard-topbar,
.column-header,
.timeline-top,
.attachment-top,
.message-meta {
    position: relative;
    z-index: 1;
}

.auth-header {
    display: grid;
    grid-template-columns: minmax(180px, 280px) 1fr;
    align-items: center;
    gap: 1.75rem;
    margin-bottom: 1.5rem;
}

.auth-copy,
.state-copy {
    display: grid;
    gap: 0.65rem;
}

.auth-title {
    font-size: clamp(2.1rem, 4vw, 4rem);
}

.feedback,
.state-view,
.dashboard-shell {
    position: relative;
    z-index: 1;
}

.feedback {
    margin-top: 1rem;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.feedback.is-error {
    background: rgba(180, 61, 61, 0.16);
    border-color: rgba(223, 111, 111, 0.35);
}

.state-view {
    margin-top: 1.5rem;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 180ms ease, transform 180ms ease;
}

.state-view[hidden] {
    display: none;
}

.auth-card {
    display: grid;
    grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
    padding: 1.4rem;
    border: 1px solid var(--line-light);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.05);
}

.stack-form {
    display: grid;
    gap: 1rem;
}

.stack-form label,
.stack-form textarea,
.stack-form input[type="file"] {
    display: grid;
    gap: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.stack-form input,
.stack-form textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.06);
}

.stack-form textarea {
    resize: vertical;
    min-height: 110px;
}

.stack-form input::placeholder,
.stack-form textarea::placeholder {
    color: rgba(247, 249, 252, 0.48);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 1.3rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: transparent;
    color: var(--text-light);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
}

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

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
}

.action-row-compact {
    justify-content: flex-end;
}

.dashboard-shell {
    display: grid;
    gap: 1.5rem;
}

.dashboard-topbar {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: flex-start;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr) minmax(300px, 360px);
    gap: 1rem;
    align-items: start;
}

.dashboard-column {
    min-height: 580px;
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line-light);
    background: rgba(255, 255, 255, 0.05);
    overflow-y: auto;
    scrollbar-width: auto;
    scrollbar-color: rgba(122, 173, 214, 0.95) rgba(10, 18, 26, 0.72);
}

.dashboard-column::-webkit-scrollbar,
.ticket-list::-webkit-scrollbar,
.messages::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.dashboard-column::-webkit-scrollbar-track,
.ticket-list::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track {
    background: linear-gradient(180deg, rgba(8, 14, 20, 0.92), rgba(14, 24, 34, 0.92));
    border-left: 1px solid rgba(122, 173, 214, 0.08);
    border-radius: 999px;
}

.dashboard-column::-webkit-scrollbar-thumb,
.ticket-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(145, 197, 236, 0.98), rgba(49, 80, 108, 1));
    border: 2px solid rgba(10, 18, 26, 0.72);
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.dashboard-column::-webkit-scrollbar-thumb:hover,
.ticket-list::-webkit-scrollbar-thumb:hover,
.messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(170, 214, 245, 1), rgba(63, 100, 133, 1));
}

.dashboard-column-list,
.dashboard-column-chat {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 1rem;
}

.dashboard-column-detail {
    display: grid;
    gap: 1rem;
}

.messages {
    scrollbar-width: auto;
    scrollbar-color: rgba(122, 173, 214, 0.95) rgba(10, 18, 26, 0.72);
}

.column-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.column-header h3,
.detail-card h4 {
    margin: 0.15rem 0 0;
    font-size: 1.15rem;
    letter-spacing: -0.03em;
}

.ticket-list,
.detail-stack,
.timeline,
.attachments,
.messages {
    display: grid;
    gap: 0.75rem;
}

.ticket-list {
    align-content: start;
    grid-auto-rows: max-content;
}

.ticket-item {
    width: 100%;
    display: grid;
    gap: 0.55rem;
    padding: 0.85rem 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-light);
    text-align: left;
    cursor: pointer;
    align-self: start;
}

.ticket-item.is-active {
    background: rgba(213, 217, 227, 0.16);
    border-color: rgba(213, 217, 227, 0.34);
}

.ticket-lot {
    font-size: 0.96rem;
    font-weight: 700;
    line-height: 1.15;
}

.ticket-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.ticket-alert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    border-radius: 999px;
    border: 1px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.ticket-alert svg {
    width: 14px;
    height: 14px;
    display: block;
}

.ticket-alert.is-viewed {
    background: rgba(64, 142, 255, 0.18);
    border-color: rgba(96, 168, 255, 0.42);
    color: #a9d0ff;
}

.ticket-alert.is-unread {
    background: rgba(217, 75, 87, 0.18);
    border-color: rgba(237, 108, 120, 0.44);
    color: #ffb1b8;
}

.ticket-status,
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.detail-stack {
    grid-template-columns: 1fr;
}

.detail-card {
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.timeline-item,
.attachment-item,
.message-bubble {
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.timeline-top,
.attachment-top,
.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 0.4rem;
}

.message-bubble.is-user {
    background: rgba(213, 217, 227, 0.15);
    border-color: rgba(213, 217, 227, 0.22);
}

.message-bubble.is-support {
    background: rgba(255, 255, 255, 0.04);
}

.messages {
    align-content: start;
    min-height: 420px;
    max-height: 620px;
    overflow: auto;
    padding-right: 0.2rem;
}

.chat-form {
    margin-top: auto;
}

.help-box {
    display: grid;
    gap: 0.65rem;
    margin-top: 1rem;
}

.help-box a,
.attachment-item a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.empty-state {
    padding: 1.1rem;
    border-radius: 16px;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    color: var(--text-muted);
}

.loading-bar {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 44px;
    padding: 0 1rem;
    border-radius: 999px;
    background: rgba(8, 18, 27, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(10px);
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spa-shell.is-loading .state-view,
.spa-shell.is-loading .dashboard-topbar {
    opacity: 0.72;
}

.is-slate {
    background: rgba(181, 192, 203, 0.22);
}

.is-blue,
.ticket-status.is-blue {
    background: rgba(105, 167, 255, 0.22);
}

.is-amber,
.ticket-status.is-amber {
    background: rgba(239, 180, 91, 0.22);
}

.is-orange,
.ticket-status.is-orange {
    background: rgba(243, 150, 92, 0.22);
}

.is-purple,
.ticket-status.is-purple {
    background: rgba(173, 129, 235, 0.22);
}

.is-green,
.ticket-status.is-green {
    background: rgba(87, 192, 132, 0.22);
}

.is-red,
.ticket-status.is-red {
    background: rgba(223, 111, 111, 0.22);
}

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

@keyframes app-loading-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-column {
        min-height: auto;
    }

    .messages {
        max-height: none;
        min-height: 220px;
    }
}

@media (max-width: 820px) {
    .portal-hero,
    .auth-header,
    .auth-card,
    .dashboard-topbar {
        grid-template-columns: 1fr;
    }

    .auth-header,
    .auth-card,
    .dashboard-topbar {
        display: grid;
    }

    .portal-hero {
        padding-top: 3rem;
    }

    .action-row-compact {
        justify-content: stretch;
    }

    .action-row-compact .button,
    .action-row .button {
        flex: 1 1 100%;
    }
}
