:root {
    --chat-orange: #ff6b00;
    --chat-orange-dark: #cc5500;
    --chat-ink: #f8fafc;
    --chat-ink-dark: #0f172a;
    --chat-muted: #94a3b8;
    --chat-line: rgba(255, 255, 255, 0.08);
    --chat-line-dark: rgba(0, 0, 0, 0.08);
    --chat-surface: #0f1115;
    --chat-surface-light: #16181d;
    --chat-canvas: #090a0c;
    
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 12px 24px rgba(0, 0, 0, 0.3);
    
    --font-family: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--chat-ink);
    background: var(--chat-canvas);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
}

button, textarea, input, select { font: inherit; }
.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Auth Container */
#admin-auth-container { text-align: center; }

/* Dashboard Header */
.dashboard-header {
    height: 72px;
    padding: 0 32px;
    border-bottom: 1px solid var(--chat-line);
    background: rgba(15, 17, 21, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    position: relative;
}

.dashboard-header > div:first-child > span {
    color: var(--chat-orange);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.dashboard-header h1 {
    margin: 4px 0 0;
    font-size: 1.25rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: #fff;
}

#agent-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    color: #cbd5e1;
    border: 1px solid var(--chat-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

#agent-info i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

.dashboard-header-actions { display: flex; align-items: center; gap: 12px; }

.support-settings-button { 
    min-height: 36px; 
    padding: 0 14px; 
    border: 1px solid var(--chat-line); 
    border-radius: 999px; 
    color: #e2e8f0; 
    background: rgba(255, 255, 255, 0.05); 
    font-size: 0.75rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.2s ease;
}

.support-settings-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.learning-review-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

/* Main Layout */
.dashboard-main {
    display: flex;
    height: calc(100vh - 72px);
    min-height: 0;
}

/* Sidebar / Queue */
#session-list-panel {
    width: 380px;
    min-width: 320px;
    border-right: 1px solid var(--chat-line);
    background: var(--chat-surface);
    display: flex;
    flex-direction: column;
}

.queue-heading {
    min-height: 84px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--chat-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--chat-surface-light);
}

.queue-heading h2 {
    margin: 4px 0 0;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.queue-eyebrow {
    color: var(--chat-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.queue-count {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid rgba(255, 107, 0, 0.3);
    border-radius: 12px;
    color: var(--chat-orange);
    background: rgba(255, 107, 0, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.inbox-tools { 
    padding: 16px; 
    border-bottom: 1px solid var(--chat-line); 
    background: var(--chat-surface); 
}

.inbox-search { 
    height: 40px; 
    padding: 0 12px; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    border: 1px solid var(--chat-line); 
    border-radius: 12px; 
    background: rgba(255, 255, 255, 0.03); 
    transition: all 0.2s ease; 
}

.inbox-search:focus-within { 
    border-color: var(--chat-orange); 
    background: rgba(255, 255, 255, 0.06); 
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15); 
}

.inbox-search svg { width: 16px; height: 16px; stroke: var(--chat-muted); stroke-width: 2; }
.inbox-search input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--chat-ink); flex: 1; font-size: 0.8rem; }

.queue-filters {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.queue-filters button { 
    min-width: 0;
    min-height: 30px; 
    padding: 0 8px;
    border: 1px solid var(--chat-line); 
    border-radius: 999px; 
    color: var(--chat-muted); 
    background: rgba(255, 255, 255, 0.03); 
    font-size: 0.75rem; 
    font-weight: 600; 
    white-space: nowrap; 
    cursor: pointer; 
    transition: all 0.2s ease;
}

.queue-filters button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.queue-filters button.active { 
    border-color: rgba(255, 107, 0, 0.4); 
    color: var(--chat-orange); 
    background: rgba(255, 107, 0, 0.1); 
}

#session-list {
    min-height: 0;
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.session-item {
    position: relative;
    width: 100%;
    margin: 0 0 8px;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: inherit;
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.session-item:hover {
    border-color: rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.04);
}

.session-item.active {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: var(--shadow-sm);
}

.session-item.unread::before {
    content: "";
    position: absolute;
    top: 17px;
    left: 4px;
    width: 4px;
    height: 20px;
    border-radius: 4px;
    background: var(--chat-orange);
    animation: unreadPulse 2s ease-in-out infinite;
}

@keyframes unreadPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

/* Status border accents on session items */
.session-item[data-state="queued"]:hover,
.session-item[data-state="queued"].active {
    border-color: rgba(251, 191, 36, 0.25);
    box-shadow: inset 3px 0 0 #fbbf24;
}

.session-item[data-state="active"]:hover,
.session-item[data-state="active"].active {
    border-color: rgba(52, 211, 153, 0.2);
    box-shadow: inset 3px 0 0 #34d399;
}

.session-item[data-state="waiting_on_buyer"]:hover,
.session-item[data-state="waiting_on_buyer"].active {
    border-color: rgba(167, 139, 250, 0.25);
    box-shadow: inset 3px 0 0 #a78bfa;
}

.session-item[data-state="resolved"]:hover,
.session-item[data-state="resolved"].active {
    border-color: rgba(100, 116, 139, 0.2);
    box-shadow: inset 3px 0 0 #475569;
}

.session-item-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.session-item-heading strong {
    min-width: 0;
    overflow: hidden;
    font-size: 0.9rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-item-preview {
    display: block;
    margin-top: 6px;
    color: var(--chat-muted);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-item small {
    display: block;
    margin-top: 6px;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 500;
}

.session-item-badges { margin-top: 8px; display: flex; gap: 6px; overflow: hidden; }
.session-item-badges b { 
    max-width: 130px; 
    padding: 3px 8px; 
    border-radius: 6px; 
    color: #e2e8f0; 
    background: rgba(255, 255, 255, 0.08); 
    font-size: 0.65rem; 
    font-weight: 600; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
    text-transform: capitalize; 
}
.session-item-badges b[data-priority="urgent"] { color: #fca5a5; background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); }
.session-item-badges b[data-priority="high"] { color: #fdba74; background: rgba(249, 115, 22, 0.15); border: 1px solid rgba(249, 115, 22, 0.3); }

.session-status, .chat-session-status {
    flex: none;
    padding: 4px 10px;
    border-radius: 6px;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.session-status.needs_agent, .chat-session-status.needs_agent { color: #fca5a5; background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); }
.session-status.waiting_for_agent, .chat-session-status.waiting_for_agent { color: #fde047; background: rgba(234, 179, 8, 0.15); border-color: rgba(234, 179, 8, 0.3); }
.session-status.active, .chat-session-status.active { color: #86efac; background: rgba(34, 197, 94, 0.15); border-color: rgba(34, 197, 94, 0.3); }
.session-status.queued, .chat-session-status.queued { color: #fca5a5; background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); }
.session-status.assigned, .chat-session-status.assigned { color: #93c5fd; background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.3); }
.session-status.waiting_on_buyer, .chat-session-status.waiting_on_buyer { color: #fde047; background: rgba(234, 179, 8, 0.15); border-color: rgba(234, 179, 8, 0.3); }
.session-status.resolved, .chat-session-status.resolved { color: #94a3b8; background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); }

.queue-empty, .queue-error {
    margin: 12px;
    padding: 32px 24px;
    border: 1px dashed var(--chat-line);
    border-radius: 12px;
    color: var(--chat-muted);
    background: rgba(255, 255, 255, 0.02);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
}

.queue-empty strong, .queue-error strong { color: var(--chat-ink); font-size: 0.95rem; }
.queue-error { border-color: rgba(239, 68, 68, 0.3); color: #fca5a5; background: rgba(239, 68, 68, 0.05); }

/* Chat View */
#chat-view-panel {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-canvas);
}

#chat-view-placeholder {
    height: 100%;
    color: var(--chat-muted);
    display: grid;
    place-items: center;
}

#chat-view-placeholder p {
    padding: 16px 24px;
    border: 1px solid var(--chat-line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.9rem;
}

#chat-view-content {
    position: relative;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#chat-view-header {
    min-height: 72px;
    padding: 16px 28px;
    border-bottom: 1px solid var(--chat-line);
    background: var(--chat-surface-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

#chat-view-header h3 { margin: 0; font-size: 1.1rem; font-weight: 600; }
#chat-view-header p { margin: 4px 0 0; color: var(--chat-muted); font-size: 0.8rem; }

.chat-header-actions { display: flex; align-items: center; gap: 10px; }

.claim-chat-button, .waiting-chat-button, .reopen-chat-button, .resolve-chat-button {
    min-height: 36px; 
    padding: 0 16px; 
    border-radius: 8px; 
    font-size: 0.8rem; 
    font-weight: 600; 
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.claim-chat-button { 
    color: #fff; 
    background: var(--chat-orange); 
}

.claim-chat-button:hover { background: var(--chat-orange-dark); }
.claim-chat-button:disabled { background: rgba(255, 255, 255, 0.1); color: var(--chat-muted); cursor: not-allowed; }

.waiting-chat-button { 
    color: #fde047; 
    background: rgba(234, 179, 8, 0.15); 
    border-color: rgba(234, 179, 8, 0.3);
}

.reopen-chat-button { 
    color: #93c5fd; 
    background: rgba(59, 130, 246, 0.15); 
    border-color: rgba(59, 130, 246, 0.3);
}

.resolve-chat-button {
    color: #86efac; 
    background: rgba(34, 197, 94, 0.15); 
    border-color: rgba(34, 197, 94, 0.3);
}

.resolve-chat-button:hover { background: rgba(34, 197, 94, 0.25); }

/* Conversation Context (Metadata) */
.conversation-context { 
    min-height: 48px; 
    padding: 10px 28px; 
    border-bottom: 1px solid var(--chat-line); 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    background: var(--chat-surface); 
    overflow-x: auto; 
    scrollbar-width: none;
}

.conversation-context > span { 
    padding: 6px 10px; 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 6px; 
    color: var(--chat-muted); 
    background: rgba(255, 255, 255, 0.03); 
    font-size: 0.75rem; 
    font-weight: 500; 
    white-space: nowrap; 
}

.conversation-context #chat-verification[data-verified="true"] { 
    color: #86efac; 
    border-color: rgba(34, 197, 94, 0.3); 
    background: rgba(34, 197, 94, 0.15); 
}

.conversation-context label { 
    display: inline-flex; 
    align-items: center; 
    gap: 8px; 
    color: var(--chat-muted); 
    font-size: 0.75rem; 
    white-space: nowrap; 
}

.conversation-context select, .conversation-context input { 
    height: 30px; 
    padding: 0 10px; 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 6px; 
    outline: 0; 
    color: #fff; 
    background: rgba(255, 255, 255, 0.05); 
    font-size: 0.75rem; 
}

.conversation-context input:focus, .conversation-context select:focus {
    border-color: var(--chat-orange);
}

.conversation-context .tag-editor { min-width: 200px; }
.conversation-context .tag-editor input { min-width: 140px; flex: 1; }

#save-chat-metadata { 
    height: 30px; 
    padding: 0 12px; 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 6px; 
    color: #fff; 
    background: rgba(255, 255, 255, 0.05); 
    font-size: 0.75rem; 
    font-weight: 500; 
    cursor: pointer; 
    transition: all 0.2s;
}

#save-chat-metadata:hover { background: rgba(255, 255, 255, 0.1); }

/* Messages */
#chat-view-messages {
    min-height: 0;
    padding: 28px clamp(24px, 5vw, 60px);
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.conversation-loading {
    display: grid;
    width: min(72%, 620px);
    gap: 11px;
    align-self: flex-start;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.035);
}

.conversation-loading span {
    width: var(--loading-width, 64%);
    height: 9px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.08);
}

.conversation-loading span::after {
    display: block;
    width: 46%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, rgba(255, 139, 44, 0.38), transparent);
    content: "";
    animation: admin-loading-shimmer 1s ease-in-out infinite;
}

.message {
    width: fit-content;
    max-width: min(75%, 680px);
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.95rem;
    animation: message-arrive 0.3s ease both;
}

.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.message time {
    display: block;
    margin-top: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.5;
    text-align: right;
}

.message.user {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #fff;
}

.message.agent {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    color: #fff;
    background: var(--chat-orange);
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.15);
}

.message.agent.delivery-failed {
    border-color: rgba(248, 113, 113, 0.5);
    background: rgba(127, 29, 29, 0.78);
}

.admin-message-delivery {
    font-weight: 700;
}

.admin-message-delivery.sending {
    color: rgba(255, 255, 255, 0.88);
}

.admin-message-delivery.failed {
    color: #fecaca;
}

.message.system {
    align-self: center;
    max-width: 80%;
    color: var(--chat-muted);
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    text-align: center;
    font-size: 0.8rem;
    border-radius: 10px;
}

/* Chat Input Form */
#agent-chat-form {
    padding: 16px 28px 20px;
    border-top: 1px solid var(--chat-line);
    background: var(--chat-surface-light);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

#saved-reply-select { 
    min-width: 0;
    width: 130px; 
    flex-shrink: 0;
    padding: 0 12px; 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 8px; 
    color: var(--chat-muted); 
    background: rgba(255, 255, 255, 0.05); 
    outline: 0; 
    font-size: 0.8rem; 
}

#agent-message-input {
    min-height: 48px;
    max-height: 140px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    outline: none;
    color: #fff;
    background: rgba(0, 0, 0, 0.2);
    resize: vertical;
    flex: 1;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

#agent-message-input:focus {
    border-color: var(--chat-orange);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

#agent-chat-form button[type="submit"] {
    min-width: 100px;
    padding: 0 24px;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: var(--chat-orange);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#agent-chat-form button[type="submit"]:hover:not(:disabled) { 
    background: var(--chat-orange-dark);
}

#agent-chat-form button:disabled { 
    background: rgba(255, 255, 255, 0.1); 
    color: var(--chat-muted); 
    cursor: not-allowed; 
}

/* Internal Notes */
.internal-notes-panel { 
    border-top: 1px solid var(--chat-line); 
    background: rgba(255, 255, 255, 0.02); 
}

#toggle-notes-button { 
    width: 100%; 
    min-height: 40px; 
    padding: 0 28px; 
    border: 0; 
    color: var(--chat-muted); 
    background: transparent; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 0.8rem; 
    font-weight: 600; 
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

#toggle-notes-button:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.03);
}

#toggle-notes-button span { 
    min-width: 24px; 
    height: 24px; 
    display: grid; 
    place-items: center; 
    border-radius: 999px; 
    color: #fff; 
    background: rgba(255, 255, 255, 0.1); 
    font-size: 0.7rem;
}

#internal-notes-content { max-height: 240px; padding: 0 28px 16px; overflow-y: auto; }
#internal-notes-list { display: grid; gap: 10px; }
#internal-notes-list article { 
    padding: 12px 14px; 
    border: 1px solid rgba(250, 204, 21, 0.2); 
    border-radius: 8px; 
    background: rgba(250, 204, 21, 0.05); 
}
#internal-notes-list strong { color: #fde047; font-size: 0.75rem; }
#internal-notes-list p { margin: 6px 0 0; color: #cbd5e1; font-size: 0.85rem; white-space: pre-wrap; }

#internal-note-form { margin-top: 12px; display: flex; gap: 10px; }
#internal-note-input { 
    min-height: 44px; 
    padding: 10px 12px; 
    border: 1px solid rgba(255, 255, 255, 0.15); 
    border-radius: 8px; 
    outline: 0; 
    resize: vertical; 
    flex: 1; 
    font-size: 0.85rem; 
    background: transparent; 
    color: #fff;
}
#internal-note-form button { 
    padding: 0 16px; 
    border: 0; 
    border-radius: 8px; 
    color: #0f172a; 
    background: #fde047; 
    font-size: 0.8rem; 
    font-weight: 600; 
    cursor: pointer; 
}

/* Premium confirmation and settings dialogs */
.resolve-dialog {
    width: min(480px, calc(100vw - 32px));
    max-width: none;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    color: var(--chat-ink);
    background: linear-gradient(145deg, #1b1e25 0%, #111318 100%);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255, 107, 0, 0.08);
    animation: admin-dialog-enter 180ms ease-out both;
}

.resolve-dialog::backdrop {
    background: rgba(3, 5, 9, 0.76);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.resolve-dialog form {
    position: relative;
    display: grid;
    gap: 14px;
    padding: 30px;
}

.resolve-dialog .dialog-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.04);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: 160ms ease;
}

.resolve-dialog .dialog-close:hover {
    color: #fff;
    border-color: rgba(255, 107, 0, 0.45);
    background: rgba(255, 107, 0, 0.14);
}

.resolve-dialog .dialog-eyebrow {
    color: #fb923c;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.resolve-dialog h2 {
    margin: 0;
    padding-right: 40px;
    color: #f8fafc;
    font-size: clamp(1.25rem, 2vw, 1.55rem);
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.resolve-dialog p {
    margin: -4px 0 4px;
    color: #94a3b8;
    font-size: 0.9rem;
    line-height: 1.55;
}

.resolve-dialog label {
    color: #cbd5e1;
    font-size: 0.78rem;
    font-weight: 700;
}

.resolve-dialog select,
.resolve-dialog textarea {
    width: 100%;
    min-height: 46px;
    padding: 0 13px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 12px;
    outline: none;
    color: #f8fafc;
    background: #0d0f13;
    transition: 160ms ease;
}

.resolve-dialog textarea {
    min-height: 82px;
    padding: 12px 13px;
    resize: vertical;
}

.resolve-dialog select:focus,
.resolve-dialog textarea:focus {
    border-color: rgba(255, 107, 0, 0.8);
    box-shadow: 0 0 0 4px rgba(255, 107, 0, 0.12);
}

.resolve-dialog .dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.resolve-dialog .dialog-actions button {
    min-height: 44px;
    padding: 0 17px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.82rem;
    font-weight: 750;
    cursor: pointer;
    transition: 160ms ease;
}

.resolve-dialog .dialog-actions button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.resolve-dialog .dialog-actions .confirm-resolve {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, #ff7a18, #e85d04);
    box-shadow: 0 9px 22px rgba(255, 107, 0, 0.24);
}

.resolve-dialog .dialog-actions .confirm-resolve:hover {
    background: linear-gradient(135deg, #ff8a32, #f06b0c);
    transform: translateY(-1px);
}

.resend-order-summary {
    display: grid;
    gap: 9px;
    margin: 2px 0;
}

.resend-order-summary > div {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 11px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
}

.resend-order-summary dt {
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.resend-order-summary dd {
    margin: 0;
    color: #f8fafc;
    font-size: 0.84rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.order-action-note {
    align-self: center;
    color: #94a3b8;
    font-size: 0.7rem;
    line-height: 1.35;
}

@keyframes admin-dialog-enter {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 560px) {
    .resolve-dialog {
        width: calc(100vw - 20px);
        border-radius: 20px;
    }

    .resolve-dialog form { padding: 24px 20px 20px; }
    .resolve-dialog .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .resolve-dialog .dialog-actions button { width: 100%; padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .resolve-dialog { animation: none; }
}

@keyframes message-arrive {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@keyframes admin-loading-shimmer {
    from { transform: translateX(-120%); }
    to { transform: translateX(240%); }
}

/* ============================================================
   PREMIUM AUTH SCREEN
   ============================================================ */

.admin-auth-screen {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 15% 25%, rgba(255, 107, 0, 0.18), transparent 38%),
        radial-gradient(circle at 85% 75%, rgba(99, 102, 241, 0.14), transparent 38%),
        linear-gradient(145deg, #060709 0%, #0c0e14 50%, #070810 100%);
    font-family: var(--font-family);
}

.admin-auth-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}

.admin-auth-orb--a {
    width: 480px;
    height: 480px;
    top: -160px;
    right: -120px;
    background: rgba(255, 107, 0, 0.22);
    animation: authOrbA 14s ease-in-out infinite alternate;
}

.admin-auth-orb--b {
    width: 420px;
    height: 420px;
    bottom: -140px;
    left: -100px;
    background: rgba(99, 102, 241, 0.18);
    animation: authOrbB 17s ease-in-out infinite alternate;
}

@keyframes authOrbA {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(-40px, 30px) scale(1.08); }
}

@keyframes authOrbB {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(30px, -25px) scale(1.06); }
}

.admin-auth-card {
    position: relative;
    z-index: 1;
    width: min(420px, calc(100vw - 40px));
    padding: 48px 40px 44px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    background:
        linear-gradient(145deg, rgba(22, 25, 35, 0.96), rgba(14, 16, 24, 0.98));
    box-shadow:
        0 40px 100px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 107, 0, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    text-align: center;
    animation: authCardIn 0.54s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes authCardIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.admin-auth-logo-ring {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    border: 1px solid rgba(255, 107, 0, 0.22);
    border-radius: 22px;
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.14), transparent 52%),
        rgba(255, 255, 255, 0.055);
    box-shadow: 0 0 0 6px rgba(255, 107, 0, 0.07), 0 16px 40px rgba(255, 107, 0, 0.18);
}

.admin-auth-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(255, 107, 0, 0.35));
}

.admin-auth-eyebrow {
    display: block;
    margin-bottom: 8px;
    color: #ff9f4e;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.admin-auth-title {
    margin: 0 0 10px;
    color: #f8fafc;
    font-size: 1.65rem;
    font-weight: 760;
    letter-spacing: -0.035em;
    line-height: 1.15;
}

.admin-auth-subtitle {
    margin: 0 0 32px;
    color: #64748b;
    font-size: 0.88rem;
    line-height: 1.55;
}

.admin-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    color: #1e2531;
    font: 600 0.95rem/1 var(--font-family);
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, background 0.2s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.admin-google-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.36);
    background: #fff;
}

.admin-google-btn:active {
    transform: translateY(0) scale(0.98);
}

.admin-google-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.admin-signin-error {
    min-height: 18px;
    margin-top: 16px;
    color: #f87171;
    font-size: 0.82rem;
    line-height: 1.45;
}

/* ============================================================
   ADMIN MOBILE RESPONSIVE LAYOUT
   ============================================================ */

.mobile-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-back-btn:hover {
    color: #fff;
    border-color: rgba(255, 107, 0, 0.4);
    background: rgba(255, 107, 0, 0.1);
}

.chat-view-header-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

@media (max-width: 860px) {
    .dashboard-header {
        height: auto;
        min-height: 56px;
        padding: 0 16px;
    }

    .dashboard-header h1 {
        font-size: 1rem;
    }

    .dashboard-header-actions {
        gap: 8px;
    }

    .support-settings-button {
        min-height: 30px;
        padding: 0 10px;
        font-size: 0.7rem;
    }

    #agent-info {
        display: none;
    }

    .dashboard-main {
        position: relative;
        overflow: hidden;
    }

    #session-list-panel {
        position: absolute;
        inset: 0;
        width: 100%;
        min-width: 0;
        z-index: 2;
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    }

    #session-list-panel.mobile-hidden {
        transform: translateX(-100%);
        pointer-events: none;
    }

    #chat-view-panel {
        position: absolute;
        inset: 0;
        z-index: 1;
        transform: translateX(100%);
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    }

    #chat-view-panel.mobile-visible {
        transform: translateX(0);
    }

    .mobile-back-btn {
        display: flex;
    }

    #chat-view-header {
        min-height: 60px;
        padding: 12px 16px;
    }

    #chat-view-header h3 { font-size: 0.95rem; }
    #chat-view-header p  { font-size: 0.72rem; }

    .chat-header-actions {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .claim-chat-button,
    .waiting-chat-button,
    .reopen-chat-button,
    .resolve-chat-button {
        min-height: 30px;
        padding: 0 10px;
        font-size: 0.72rem;
    }

    .conversation-context {
        padding: 8px 14px;
        gap: 8px;
    }

    #chat-view-messages {
        padding: 16px;
    }

    #agent-chat-form {
        padding: 12px 16px 16px;
        flex-wrap: wrap;
    }

    #saved-reply-select {
        width: 100%;
    }

    #agent-message-input {
        min-height: 44px;
    }

    #internal-notes-content {
        padding: 0 16px 12px;
    }

    #toggle-notes-button {
        padding: 0 16px;
    }

    .queue-heading {
        min-height: 64px;
        padding: 14px 16px;
    }

    .inbox-tools {
        padding: 10px 12px;
    }

    #session-list {
        padding: 8px;
    }

    .resolve-dialog {
        width: calc(100vw - 20px);
        border-radius: 20px;
    }

    .resolve-dialog form {
        padding: 24px 20px 20px;
    }

    .resolve-dialog .dialog-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .resolve-dialog .dialog-actions button {
        width: 100%;
    }
}

/* ============================================================
   ADMIN PREMIUM POLISH
   ============================================================ */

/* Empty state placeholder polish */
#chat-view-placeholder {
    height: 100%;
    color: var(--chat-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 40px;
    text-align: center;
}

#chat-view-placeholder::before {
    content: '';
    display: block;
    width: 68px;
    height: 68px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 107, 0, 0.14), transparent 55%),
        rgba(255, 255, 255, 0.03);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
    animation: placeholderPulse 3s ease-in-out infinite;
}

@keyframes placeholderPulse {
    0%, 100% { box-shadow: 0 12px 32px rgba(0,0,0,0.24), 0 0 0 0 rgba(255,107,0,0); }
    50%       { box-shadow: 0 12px 32px rgba(0,0,0,0.24), 0 0 0 8px rgba(255,107,0,0.06); }
}

#chat-view-placeholder p {
    max-width: 240px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #475569;
    font-size: 0.88rem;
    line-height: 1.6;
}

.placeholder-hint {
    font-size: 0.72rem;
    color: #334155;
}

/* Metrics dialog cards */
.support-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.support-metrics-grid article {
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    text-align: center;
}

.support-metrics-grid strong {
    display: block;
    color: #f8fafc;
    font-size: 1.45rem;
    font-weight: 760;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 5px;
}

.support-metrics-grid span {
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metrics-loading {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--chat-muted);
    font-size: 0.85rem;
    padding: 24px;
}

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

/* Weekly schedule rows */
.weekly-support-schedule {
    display: grid;
    gap: 8px;
}

.weekly-support-schedule [data-day] {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.8rem;
    color: var(--chat-ink);
}

.weekly-support-schedule label:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 110px;
    color: #cbd5e1;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.weekly-support-schedule .schedule-start,
.weekly-support-schedule .schedule-end {
    width: 52px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 0.8rem;
    text-align: center;
    outline: none;
}

.weekly-support-schedule .schedule-start:focus,
.weekly-support-schedule .schedule-end:focus {
    border-color: var(--chat-orange);
    box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.15);
}

.weekly-support-schedule span { color: #475569; font-size: 0.75rem; }

/* Action status */
.admin-action-status {
    font-size: 0.78rem;
    color: var(--chat-muted);
    min-height: 18px;
    padding: 0 28px 4px;
}

.admin-action-status[data-state="success"] { color: #86efac; }
.admin-action-status[data-state="error"]   { color: #f87171; }

/* Support metrics / settings dialogs wider */
.support-metrics-dialog,
.support-settings-dialog {
    width: min(580px, calc(100vw - 32px));
}

/* Customer Context Panel */
.chat-context-panel {
    width: 340px;
    min-width: 300px;
    border-left: 1px solid var(--chat-line);
    background: var(--chat-surface);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.32s ease, opacity 0.32s ease;
}

.chat-context-panel.hidden {
    display: none;
}

.context-panel-header {
    min-height: 60px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--chat-line);
}

.context-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--chat-ink);
}

.context-panel-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.context-section h4 {
    margin: 0 0 12px 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--chat-muted);
    font-weight: 700;
}

/* Professional Order Card */
.admin-order-card {
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dark-mode .admin-order-card {
    background: linear-gradient(145deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
    border-color: rgba(255,255,255,0.08);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--chat-ink);
    margin: 0;
}

.order-badge {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(34, 197, 94, 0.15);
    color: #15803d;
}
.order-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

.order-card-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--chat-text);
}

.order-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.order-action-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    background: transparent;
    color: var(--chat-ink);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.order-action-btn:hover {
    background: rgba(0,0,0,0.04);
}
.order-action-btn.primary {
    background: linear-gradient(135deg, #ff6b00, #ff8a00);
    color: white;
    border: none;
}
.order-action-btn.primary:hover {
    box-shadow: 0 4px 12px rgba(255,107,0,0.3);
}
.order-action-btn.warning {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
}
.order-action-btn.warning:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.insight-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--chat-text);
}
.insight-list i {
    width: 20px;
    color: var(--chat-muted);
}

/* Buyer Typing Indicator */
.buyer-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--chat-muted, #6b7280);
    padding: 2px 8px;
    margin-left: auto;
    animation: fadeIn 0.3s ease;
}
.buyer-typing-indicator.hidden {
    display: none;
}
.buyer-typing-dot {
    width: 4px;
    height: 4px;
    background-color: currentColor;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.buyer-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.buyer-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.buyer-typing-label {
    margin-left: 4px;
    font-style: italic;
}
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
