.login-page,
.dashboard-page,
.not-found-page {
    padding: 24px;
}

.login-layout {
    max-width: 1120px;
    min-height: calc(100vh - 48px);
    margin: 0 auto;
    display: grid;
    place-items: center;
}

.login-panel {
    width: min(100%, 560px);
    padding: 40px;
    border-radius: var(--radius);
    background: rgba(255, 250, 242, 0.88);
    border: 1px solid rgba(18, 69, 89, 0.08);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.brand-block {
    display: grid;
    gap: 16px;
    margin-bottom: 28px;
}

.login-form {
    display: grid;
    gap: 18px;
}

.login-form label,
.search-form {
    display: grid;
    gap: 10px;
}

.login-form span,
.search-form label {
    font-weight: 700;
    color: var(--primary);
}

.login-form input,
.search-form input {
    width: 100%;
    border: 1px solid rgba(18, 69, 89, 0.14);
    border-radius: 18px;
    background: #ffffff;
    padding: 16px 18px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form input:focus,
.search-form input:focus {
    border-color: rgba(18, 69, 89, 0.4);
    box-shadow: 0 0 0 4px rgba(18, 69, 89, 0.08);
}

.dashboard-hero,
.dashboard-layout {
    max-width: var(--container);
    margin: 0 auto;
}

.app-shell {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.app-content {
    min-width: 0;
}

.app-sidebar {
    position: sticky;
    top: 24px;
    width: 92px;
    min-height: calc(100vh - 48px);
    padding: 18px 14px;
    border-radius: 28px;
    background: rgba(18, 69, 89, 0.96);
    color: #ffffff;
    box-shadow: 0 24px 60px rgba(18, 69, 89, 0.2);
    overflow: hidden;
    transition: width 0.24s ease;
}

.app-sidebar:hover {
    width: 280px;
}

.app-sidebar-brand,
.app-sidebar-link,
.app-sidebar-footer {
    display: flex;
    align-items: center;
    gap: 14px;
}

.app-sidebar-brand {
    margin-bottom: 28px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.app-sidebar-mark,
.app-sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.app-sidebar-mark svg,
.app-sidebar-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.app-sidebar-copy,
.app-sidebar-text,
.app-sidebar-hint {
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.app-sidebar-nav {
    display: grid;
    gap: 10px;
    justify-items: center;
}

.app-sidebar:not(:hover) .app-sidebar-link {
    width: 54px;
    min-width: 54px;
    padding: 6px;
    justify-content: center;
    gap: 0;
}

.app-sidebar:not(:hover) .app-sidebar-link .app-sidebar-text {
    display: none;
}

.app-sidebar:not(:hover) .app-sidebar-link .app-sidebar-icon {
    margin: 0;
}

.app-sidebar:not(:hover) .app-sidebar-footer {
    display: none;
}

.app-sidebar:hover .app-sidebar-brand {
    opacity: 1;
    pointer-events: auto;
}

.app-sidebar:hover .app-sidebar-copy,
.app-sidebar:hover .app-sidebar-text,
.app-sidebar:hover .app-sidebar-hint {
    opacity: 1;
}

.app-sidebar-copy strong,
.app-sidebar-copy span {
    display: block;
}

.app-sidebar-copy span,
.app-sidebar-hint {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.88rem;
}

.app-sidebar-link {
    min-height: 54px;
    width: 100%;
    padding: 6px 8px;
    border-radius: 18px;
    color: #ffffff;
    transition: background 0.2s ease, transform 0.2s ease;
}

.app-sidebar-link:hover {
    transform: translateX(2px);
    background: rgba(255, 255, 255, 0.08);
}

.app-sidebar-link.is-active {
    background: linear-gradient(135deg, #2a9d8f 0%, #1d7874 100%);
}

.app-sidebar-footer {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 18px;
}

.dashboard-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 28px;
    padding: 24px 0 8px;
}

.dashboard-layout {
    display: grid;
    gap: 24px;
    padding-bottom: 40px;
}

.logout-form {
    margin: 0;
}

.stats-grid,
.panel-grid {
    display: grid;
    gap: 18px;
}

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

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

.stat-card,
.panel {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(18, 69, 89, 0.08);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat-card {
    min-height: 180px;
    padding: 24px;
    display: grid;
    gap: 10px;
    align-content: start;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto -32px -32px auto;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    opacity: 0.28;
}

.stat-card-blue::after { background: #2a9d8f; }
.stat-card-orange::after { background: #f4a261; }
.stat-card-green::after { background: #7cb518; }
.stat-card-red::after { background: #e76f51; }

.stat-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-value {
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(2rem, 4vw, 3rem);
    letter-spacing: -0.04em;
}

.stat-description {
    color: var(--muted);
    font-size: 0.95rem;
}

.panel {
    padding: 24px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header h2 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.4rem;
}

.panel-header p {
    margin: 4px 0 0;
    color: var(--muted);
}

.badge {
    display: inline-flex;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(18, 69, 89, 0.08);
    color: var(--primary);
}

.badge-online {
    background: rgba(42, 157, 143, 0.14);
    color: #176b62;
}

.badge-offline {
    background: rgba(188, 71, 73, 0.14);
    color: #8f2628;
}

.status-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
}

.search-stack {
    display: grid;
    gap: 16px;
}

.simulate-form {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 16px;
    align-items: end;
}

.simulate-form label {
    display: grid;
    gap: 10px;
}

.simulate-form span {
    font-weight: 700;
    color: var(--primary);
}

.simulate-form input,
.simulate-form textarea {
    width: 100%;
    border: 1px solid rgba(18, 69, 89, 0.14);
    border-radius: 18px;
    background: #ffffff;
    padding: 16px 18px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font: inherit;
}

.simulate-form input:focus,
.simulate-form textarea:focus {
    border-color: rgba(18, 69, 89, 0.4);
    box-shadow: 0 0 0 4px rgba(18, 69, 89, 0.08);
}

.simulate-form-message {
    grid-column: 2;
}

.simulate-form-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.simulate-form-actions button {
    border: none;
    border-radius: 999px;
    padding: 14px 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, #0b7285 100%);
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(18, 69, 89, 0.2);
}

.simulate-feedback {
    color: var(--muted);
    font-size: 0.95rem;
}

.results-list,
.messages-table-wrapper,
.conversation-workspace {
    border: 1px solid rgba(18, 69, 89, 0.08);
    border-radius: 20px;
    background: rgba(243, 239, 231, 0.55);
}

.results-list {
    min-height: 160px;
    padding: 18px;
    display: grid;
    gap: 14px;
}

.result-card {
    padding: 16px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid rgba(18, 69, 89, 0.08);
}

.result-card strong,
.result-card span {
    display: block;
}

.result-card strong {
    margin-bottom: 6px;
}

.result-card span {
    color: var(--muted);
    line-height: 1.6;
}

.empty-state {
    color: var(--muted);
    place-items: center;
    text-align: center;
}

.conversation-workspace {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    overflow: hidden;
    min-height: 620px;
}

.conversation-sidebar {
    border-right: 1px solid rgba(18, 69, 89, 0.08);
    background: rgba(255, 255, 255, 0.72);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.conversation-sidebar-header,
.conversation-thread-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(18, 69, 89, 0.08);
}

.conversation-sidebar-header strong,
.conversation-thread-header strong {
    display: block;
    font-size: 1rem;
}

.conversation-sidebar-header span,
.conversation-thread-header span {
    color: var(--muted);
    font-size: 0.92rem;
}

.conversation-list {
    display: grid;
    gap: 0;
    max-height: 560px;
    overflow-y: auto;
}

.conversation-item {
    width: 100%;
    border: none;
    border-bottom: 1px solid rgba(18, 69, 89, 0.08);
    background: transparent;
    padding: 16px 18px;
    text-align: left;
    transition: background 0.2s ease;
}

.conversation-item:hover,
.conversation-item.is-active {
    background: rgba(18, 69, 89, 0.08);
}

.conversation-item-top,
.conversation-item-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.conversation-item-top {
    margin-bottom: 8px;
}

.conversation-item-top strong {
    font-size: 0.96rem;
}

.conversation-item-top span,
.conversation-item-meta,
.conversation-item-preview {
    color: var(--muted);
    font-size: 0.9rem;
}

.conversation-item-preview {
    line-height: 1.5;
    margin-bottom: 8px;
}

.conversation-thread {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    min-height: 0;
}

.conversation-messages {
    display: grid;
    align-content: start;
    gap: 14px;
    padding: 22px;
    min-height: 0;
    overflow-y: auto;
    background:
        radial-gradient(circle at top right, rgba(42, 157, 143, 0.08), transparent 25%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(244, 239, 231, 0.55) 100%);
}

.chat-bubble {
    max-width: min(78%, 680px);
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(18, 69, 89, 0.08);
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(18, 69, 89, 0.08);
}

.chat-bubble-inbound {
    justify-self: start;
    border-top-left-radius: 8px;
}

.chat-bubble-outbound {
    justify-self: end;
    background: linear-gradient(135deg, #d8eef4 0%, #eef8fb 100%);
    border-top-right-radius: 8px;
}

.chat-bubble-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.82rem;
}

.chat-bubble-body {
    line-height: 1.65;
    color: var(--text);
    word-break: break-word;
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }

    .app-sidebar,
    .app-sidebar:hover {
        width: 100%;
    }

    .app-sidebar-copy,
    .app-sidebar-text,
    .app-sidebar-hint {
        opacity: 1;
    }

    .app-sidebar-brand {
        opacity: 1;
        pointer-events: auto;
    }

    .app-sidebar-nav {
        justify-items: stretch;
    }

    .app-sidebar:not(:hover) .app-sidebar-link .app-sidebar-text {
        display: inline;
    }

    .app-sidebar:not(:hover) .app-sidebar-footer {
        display: flex;
    }

    .app-sidebar-footer {
        position: static;
        margin-top: 18px;
    }

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

    .panel-grid {
        grid-template-columns: 1fr;
    }

    .simulate-form {
        grid-template-columns: 1fr;
    }

    .simulate-form-message {
        grid-column: auto;
    }

    .conversation-workspace {
        grid-template-columns: 1fr;
    }

    .conversation-sidebar {
        border-right: none;
        border-bottom: 1px solid rgba(18, 69, 89, 0.08);
    }
}

@media (max-width: 720px) {
    .login-page,
    .dashboard-page,
    .not-found-page {
        padding: 16px;
    }

    .login-panel,
    .panel,
    .stat-card {
        padding: 20px;
    }

    .dashboard-hero {
        flex-direction: column;
    }

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

    .conversation-workspace {
        min-height: auto;
    }

    .conversation-list,
    .conversation-messages {
        max-height: none;
    }

    .chat-bubble {
        max-width: 100%;
    }
}
