@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
    /* Light blue + white palette. The brand logo is black ink, so every surface
       it sits on stays light — no dark panels anywhere in the system. */
    --bg-dark: #e9f1fb;         /* page background (light blue) */
    --bg-card: #ffffff;         /* cards and panels (white) */
    --primary: #2563eb;
    --primary-glow: rgba(37, 99, 235, 0.14);
    --secondary: #64748b;
    --accent: #0ea5e9;
    --accent-glow: rgba(14, 165, 233, 0.16);
    --success: #059669;
    --text-main: #0f2340;       /* deep navy ink */
    --text-muted: #5b7089;
    --border-glass: rgba(15, 35, 64, 0.10);

    /* Names kept stable so existing rules keep working; values re-tuned to the
       blue system. --forest-*/--sand-*/--clay-*/--gold-* are legacy names. */
    --forest-900: #ffffff;      /* sidebar / hero surface — now light */
    --forest-800: #f2f7fd;
    --sand-50: #f4f9ff;
    --sand-100: #eef4fc;        /* tinted fills (inputs, wells) */
    --clay-600: #dc2626;        /* destructive */
    --gold-500: #2563eb;        /* brand highlight */
    --shadow-organic: 0 14px 34px rgba(15, 35, 64, 0.10);
    --shadow-organic-sm: 0 6px 16px rgba(15, 35, 64, 0.07);
    --radius-blob: 28px 20px 30px 18px;
    --radius-blob-sm: 16px 12px 18px 12px;
    --radius-pill: 999px;
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

body {
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(at 8% 0%, rgba(37, 99, 235, 0.10) 0, transparent 45%),
        radial-gradient(at 100% 12%, rgba(14, 165, 233, 0.10) 0, transparent 50%),
        radial-gradient(at 15% 100%, rgba(37, 99, 235, 0.07) 0, transparent 45%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

h1, h2, h3, h4, .logo, .qr-form-panel h3 {
    font-family: var(--font-display);
    font-weight: 600;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    background-image: radial-gradient(at 90% 100%, rgba(37, 99, 235, 0.06) 0, transparent 55%);
    border-right: 1px solid var(--border-glass);
    border-radius: 0 40px 40px 0;
    padding: 2rem 1.5rem;
    height: 100vh;
    position: fixed;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-organic);
}

.logo {
    display: flex;
    align-items: center;
    margin-bottom: 3rem;
    padding: 0 0.25rem;
}

/* The brand mark is a wide lockup ("INSTA" over "GROUP"); size it by width and
   let height follow so it never distorts. */
.logo img {
    width: 100%;
    max-width: 180px;
    height: auto;
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-pill);
    margin-bottom: 0.5rem;
    transition: all 0.25s ease;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--sand-100);
    color: var(--text-main);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), #1d4ed8);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.nav-item i {
    width: 20px;
    margin-right: 12px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 3rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header h1 {
    font-size: 1.75rem;
    color: var(--text-main);
}

.status-badge {
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-connected {
    background: rgba(5, 150, 105, 0.12);
    color: var(--success);
}

.status-disconnected {
    background: var(--accent-glow);
    color: var(--accent);
}

/* Cards & Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    padding: 1.5rem;
    border-radius: var(--radius-blob);
    box-shadow: var(--shadow-organic-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--primary-glow);
    filter: blur(2px);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-organic);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    margin-top: 0.5rem;
    position: relative;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    position: relative;
}

/* Data Tables */
.content-box {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-blob);
    box-shadow: var(--shadow-organic-sm);
    padding: 1.5rem;
    overflow-x: auto;
}

.content-box h2 {
    color: var(--text-main);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.8rem;
    border-bottom: 2px solid var(--border-glass);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.95rem;
}

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

/* Panels (info boxes within tabs) */
.panel {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--sand-100);
    border-radius: var(--radius-blob-sm);
    border: 1px solid var(--border-glass);
}

.panel-title {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-main);
}

.panel-title i {
    color: var(--primary);
}

.panel-hint {
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* Section headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    margin: 0;
}

.btn-group {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

/* WhatsApp connection */
.qr-scan-box {
    text-align: center;
    margin-top: 1rem;
    padding: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-blob-sm);
    border: 1px solid var(--border-glass);
}

.qr-scan-box h3 {
    margin-bottom: 1rem;
    color: var(--text-main);
}

.qr-scan-img {
    background: white;
    padding: 1rem;
    border-radius: 20px;
    margin: 0 auto;
    display: block;
    max-width: 280px;
    box-shadow: var(--shadow-organic);
}

.qr-scan-hint {
    margin-top: 1rem;
    color: var(--text-muted);
}

.connection-active p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Form Styles */
.editor-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

textarea {
    width: 100%;
    min-height: 500px;
    background: var(--sand-100);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-blob-sm);
    padding: 1.5rem;
    color: var(--text-main);
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

textarea:focus {
    border-color: var(--primary);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-pill);
    border: none;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 4px 20px var(--primary-glow);
    transform: scale(1.02);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #0284c7);
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-accent:hover {
    transform: scale(1.02);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #047857);
    color: #fff;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
    transform: scale(1.02);
}

.btn-ghost {
    background: var(--sand-100);
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
}

.btn-ghost:hover {
    background: var(--bg-card);
}

.btn-danger {
    background: transparent;
    color: var(--clay-600);
    border: 1px solid var(--clay-600);
}

.btn-danger:hover {
    background: var(--clay-600);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Icon-only action buttons (table rows, compact actions) — uniform circles
   instead of stretching the pill radius over a lopsided rectangle. */
.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.82rem;
    flex-shrink: 0;
}

/* Quick reply form panel */
.qr-form-panel {
    margin-bottom: 2.5rem;
    animation: slideDown 0.3s ease-out forwards;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-blob);
    padding: 2rem;
    box-shadow: var(--shadow-organic);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.qr-form-panel h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 1rem;
    display: flex;
    align-items: center;
}

.qr-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.qr-icon-wrapper i {
    color: var(--primary);
    font-size: 0.9rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.form-label .required {
    color: var(--clay-600);
}

.form-input, .form-textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-blob-sm);
    background: var(--sand-100);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-input {
    font-family: monospace;
}

.form-textarea {
    font-family: var(--font-body);
    line-height: 1.6;
    resize: vertical;
}

.form-input:focus, .form-textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-field-group {
    margin-bottom: 1.5rem;
}

.form-field-wide {
    margin-bottom: 2rem;
}

/* Upload area */
.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 2rem 1.5rem;
    border: 2px dashed var(--border-glass);
    border-radius: var(--radius-blob-sm);
    background: var(--sand-100);
    transition: all 0.2s;
    position: relative;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--bg-card);
}

.upload-input {
    opacity: 0;
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
    top: 0;
    left: 0;
    z-index: 10;
}

.upload-placeholder {
    text-align: center;
    pointer-events: none;
}

.upload-icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem auto;
}

.upload-icon-circle i {
    font-size: 1.25rem;
    color: var(--primary);
}

.upload-placeholder p:first-of-type {
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.upload-placeholder p:last-of-type {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.upload-preview {
    display: none;
    max-height: 150px;
    border-radius: var(--radius-blob-sm);
    margin-top: 1rem;
    box-shadow: var(--shadow-organic-sm);
    position: relative;
    z-index: 5;
}

.upload-clear-btn {
    display: none;
    margin-top: 10px;
    position: relative;
    z-index: 15;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-glass);
}

/* Logs */
.logs-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.logs-filters {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    align-items: center;
}

.logs-select, .logs-search-input {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-blob-sm);
    background: var(--sand-100);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
}

.logs-search-input {
    min-width: 220px;
}

.logs-autorefresh-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
}

.logs-console {
    background: var(--sand-100);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-blob-sm);
    padding: 1rem;
    max-height: 65vh;
    overflow-y: auto;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.6;
}

.logs-loading, .logs-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-dark);
    background-image: radial-gradient(at 15% 10%, rgba(37, 99, 235, 0.16) 0, transparent 50%),
        radial-gradient(at 85% 90%, rgba(14, 165, 233, 0.16) 0, transparent 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-blob);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 60px rgba(15, 35, 64, 0.18);
    text-align: center;
}

.login-logo {
    display: block;
    width: 100%;
    max-width: 190px;
    height: auto;
    margin: 0 auto 1.75rem auto;
}

.login-title {
    color: var(--text-main);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    font-family: var(--font-display);
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.login-field {
    position: relative;
    margin-bottom: 1.5rem;
}

.login-input {
    width: 100%;
    padding: 0.9rem 1rem 0.9rem 2.8rem;
    border-radius: var(--radius-blob-sm);
    background: var(--sand-100);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.2s;
    outline: none;
    box-sizing: border-box;
}

.login-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.login-field-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.login-error {
    display: none;
    color: var(--clay-600);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    padding: 0.6rem;
    background: rgba(220, 38, 38, 0.10);
    border-radius: var(--radius-blob-sm);
    border: 1px solid rgba(220, 38, 38, 0.22);
}

.login-btn {
    width: 100%;
    padding: 0.9rem;
    border-radius: var(--radius-blob-sm);
    background: linear-gradient(135deg, var(--primary), #1d4ed8);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--primary-glow);
    transition: all 0.2s;
}

/* Detail panel (contact / customer / inquiry) */
.detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(15, 35, 64, 0.32);
    display: flex;
    justify-content: flex-end;
}

.detail-panel {
    width: 480px;
    max-width: 92vw;
    height: 100%;
    background: var(--bg-card);
    box-shadow: -20px 0 50px rgba(15, 35, 64, 0.20);
    display: flex;
    flex-direction: column;
    border-radius: 32px 0 0 32px;
    animation: slideInPanel 0.3s ease-out;
    overflow: hidden;
}

@keyframes slideInPanel {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.detail-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-glass);
    background: var(--sand-100);
    flex-shrink: 0;
}

.detail-panel-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.detail-panel-close {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.detail-panel-close:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.detail-panel-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.detail-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-field label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.detail-field .value {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.5;
}

.detail-section-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin: 1.75rem 0 1rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.detail-link-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-link-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1rem;
    background: var(--sand-100);
    border-radius: var(--radius-blob-sm);
    border: 1px solid var(--border-glass);
    cursor: pointer;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

.detail-link-item:hover {
    border-color: var(--primary);
}

.detail-link-item i {
    color: var(--text-muted);
}

/* Conversation history */
.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 360px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--sand-100);
    border-radius: var(--radius-blob-sm);
    border: 1px solid var(--border-glass);
}

.chat-bubble {
    max-width: 82%;
    padding: 0.6rem 0.9rem;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

.chat-bubble-time {
    font-size: 0.7rem;
    opacity: 0.65;
    margin-top: 0.3rem;
    display: block;
}

.chat-empty, .chat-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 1.5rem;
}

/* Clickable table rows */
tr.clickable-row {
    cursor: pointer;
}

tr.clickable-row:hover {
    background: var(--sand-100);
}

/* Toast notifications (replaces browser alert()) */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-end;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 280px;
    max-width: min(420px, calc(100vw - 3rem));
    padding: 0.9rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-left: 4px solid var(--secondary);
    border-radius: var(--radius-blob-sm);
    box-shadow: var(--shadow-organic);
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--text-main);
    animation: toastIn 0.28s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.toast.toast-out {
    animation: toastOut 0.22s ease-in forwards;
}

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-message { flex: 1; word-break: break-word; }

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 0 0 0.25rem;
    line-height: 1.4;
}

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

.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error { border-left-color: var(--clay-600); }
.toast-error .toast-icon { color: var(--clay-600); }
.toast-info { border-left-color: var(--primary); }
.toast-info .toast-icon { color: var(--primary); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 600px) {
    .toast-container { left: 1rem; right: 1rem; bottom: 1rem; align-items: stretch; }
    .toast { min-width: 0; max-width: none; }
}

/* Confirm dialog (replaces browser confirm()) */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(15, 35, 64, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: confirmFade 0.18s ease-out;
}

.confirm-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-blob);
    box-shadow: 0 25px 60px rgba(15, 35, 64, 0.24);
    padding: 1.75rem;
    width: 100%;
    max-width: 420px;
    animation: confirmPop 0.22s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.confirm-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    background: var(--primary-glow);
    color: var(--primary);
}

.confirm-card.danger .confirm-icon { background: var(--accent-glow); color: var(--clay-600); }

.confirm-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.confirm-message {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.55;
    margin-bottom: 1.5rem;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.7rem;
    flex-wrap: wrap;
}

@keyframes confirmFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes confirmPop {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .toast, .toast.toast-out, .confirm-overlay, .confirm-card { animation: none; }
}

/* Utilities */
.hidden { display: none; }
.pill {
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
}
.pill-lead { background: var(--primary-glow); color: var(--primary); }
.pill-visit { background: rgba(5, 150, 105, 0.14); color: var(--success); }
.pill-active { background: var(--sand-100); color: var(--text-muted); }
.pill-code { background: var(--accent-glow); color: var(--clay-600); font-family: monospace; }
