:root {
    --color-background: #FAFAF8;
    --color-foreground: #0D0D0D;
    --color-accent: #E85D04;
    --color-accent-hover: #D4520A;
    --color-secondary: #2D6A4F;
    --color-secondary-hover: #245A42;
    --color-muted: #71717A;
    --color-border: #E4E4E7;
    --font-display: "DM Serif Display", Georgia, serif;
    --font-body: "IBM Plex Sans", system-ui, sans-serif;
    --sidebar-width: 16rem;
    --sidebar-collapsed-width: 4rem;
    --sidebar-bg: #1a1a1a;
    --sidebar-text: #a3a3a3;
    --sidebar-active-bg: rgba(232, 93, 4, 0.12);
    --sidebar-active-text: #E85D04;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-background);
    color: var(--color-foreground);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { font-family: var(--font-display); }

/* ---- Sidebar layout ---- */
.has-sidebar {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transition: width 0.2s ease;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 4rem;
}

.sidebar-logo {
    text-decoration: none;
    color: #fff;
    font-family: var(--font-display);
    font-size: 1.25rem;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
}
.sidebar-toggle:hover { color: #fff; }

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-section {
    padding: 0 0.75rem;
    margin-bottom: 1.5rem;
}

.sidebar-section-title {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.3);
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    margin-bottom: 0.125rem;
}
.sidebar-link:hover {
    color: #fff;
    background-color: rgba(255,255,255,0.06);
}
.sidebar-link.active {
    color: var(--sidebar-active-text);
    background-color: var(--sidebar-active-bg);
}

.sidebar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.sidebar-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-user-name {
    font-size: 0.8125rem;
    color: var(--sidebar-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout-form { display: inline; }

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.8125rem;
}
.sidebar-logout-btn:hover { color: #ef4444; }

/* Collapsed sidebar overrides */
body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-section-title,
body.sidebar-collapsed .sidebar-user-name {
    display: none;
}
body.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 1.25rem 0.5rem;
}
body.sidebar-collapsed .sidebar-section {
    padding: 0 0.375rem;
}
body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 0.5rem;
    gap: 0;
}
body.sidebar-collapsed .sidebar-footer {
    padding: 0.75rem 0.5rem;
}
body.sidebar-collapsed .sidebar-user {
    justify-content: center;
}

.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.2s ease;
    min-height: 100vh;
}
body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.main-content-inner {
    max-width: 80rem;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ---- Forms ---- */
.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.1);
}
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-foreground);
    margin-bottom: 0.375rem;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}
.btn-primary { background-color: var(--color-accent); color: white; }
.btn-primary:hover { background-color: var(--color-accent-hover); }
.btn-secondary { background-color: var(--color-secondary); color: white; }
.btn-secondary:hover { background-color: var(--color-secondary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-foreground); }
.btn-outline:hover { background-color: #f4f4f5; }
.btn-danger { background-color: #ef4444; color: white; }
.btn-danger:hover { background-color: #dc2626; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }

/* ---- Card ---- */
.card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* ---- Stat cards ---- */
.stat-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
}
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    line-height: 1;
    color: var(--color-foreground);
}
.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--color-muted);
    margin-top: 0.25rem;
}
.stat-card .stat-comparison {
    font-size: 0.75rem;
    margin-top: 0.375rem;
}
.stat-comparison.positive { color: #16a34a; }
.stat-comparison.negative { color: #dc2626; }

/* ---- Data table ---- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.data-table td {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
    border-bottom: 1px solid var(--color-border);
}
.data-table tbody tr { cursor: pointer; transition: background-color 0.15s; }
.data-table tbody tr:hover { background-color: #f9f9f7; }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-completed { background-color: #dcfce7; color: #166534; }
.badge-failed { background-color: #fef2f2; color: #991b1b; }
.badge-no-answer { background-color: #fef9c3; color: #854d0e; }
.badge-inbound { background-color: #dbeafe; color: #1e40af; }
.badge-outbound { background-color: #f3e8ff; color: #6b21a8; }
.badge-active { background-color: #dcfce7; color: #166534; }
.badge-draft { background-color: #fef9c3; color: #854d0e; }

/* Read status badges */
.badge-new { background-color: #dbeafe; color: #1e40af; }
.badge-read { background-color: #f4f4f5; color: #52525b; }
.badge-in-progress { background-color: #fef9c3; color: #854d0e; }
.badge-done { background-color: #dcfce7; color: #166534; }

/* Role badges */
.badge-role-sales { background-color: #dbeafe; color: #1e40af; }
.badge-role-support { background-color: #fef9c3; color: #854d0e; }
.badge-role-manager { background-color: #f3e8ff; color: #6b21a8; }
.badge-role-general { background-color: #f4f4f5; color: #52525b; }
.badge-role-billing { background-color: #dcfce7; color: #166534; }
.badge-role-hr { background-color: #fce7f3; color: #9d174d; }
.badge-role-marketing { background-color: #ffedd5; color: #9a3412; }
.badge-role-engineering { background-color: #e0e7ff; color: #3730a3; }
.badge-role-accounting { background-color: #ccfbf1; color: #115e59; }

/* Role chip selector */
.role-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.role-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--color-border);
    background: white;
    color: var(--color-muted);
    transition: all 0.15s ease;
    user-select: none;
}
.role-chip:hover {
    border-color: var(--color-accent);
}
.role-chip.selected {
    background-color: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

/* ---- Flash messages ---- */
.flash { padding: 0.75rem 1rem; border-radius: 0.5rem; margin-bottom: 1rem; font-size: 0.875rem; }
.flash-error { background-color: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-success { background-color: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

/* ---- Transcript ---- */
.transcript-message {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    max-width: 80%;
    font-size: 0.9375rem;
    line-height: 1.5;
}
.transcript-bot { background-color: rgba(232, 93, 4, 0.12); margin-left: auto; }
.transcript-human { background-color: #f4f4f5; margin-right: auto; }
input[type="range"] { accent-color: var(--color-accent); }
.transcript-tool-call {
    background-color: #f8fafc;
    border-left: 3px solid var(--color-accent);
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    margin: 0.25rem 2rem;
    font-family: var(--font-body);
}
.transcript-tool-call pre {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    background-color: #f1f5f9;
    padding: 0.375rem 0.5rem;
    border-radius: 0.25rem;
    overflow-x: auto;
}
.transcript-fn-output {
    background-color: #f8fafc;
    border-right: 3px solid var(--color-accent);
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    margin: 0.25rem 2rem;
}
.transcript-fn-output-pre {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    background-color: #f1f5f9;
    padding: 0.5rem 0.625rem;
    border-radius: 0.25rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 15rem;
    overflow-y: auto;
    margin: 0;
}

/* Evaluation label truncation tooltip */
.eval-label {
    cursor: default;
    position: relative;
}
.eval-label[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 0.25rem;
    background: var(--color-foreground);
    color: white;
    font-size: 0.6875rem;
    text-transform: none;
    letter-spacing: normal;
    padding: 0.375rem 0.625rem;
    border-radius: 0.375rem;
    white-space: normal;
    max-width: 20rem;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    line-height: 1.4;
}

/* ---- Tabs ---- */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab:hover { color: var(--color-foreground); }
.tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

/* Sub-tabs (within agent style tab) */
.sub-tab-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.sub-tab {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-muted);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s;
}
.sub-tab:hover { color: var(--color-foreground); background-color: #f4f4f5; }
.sub-tab.active {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background-color: rgba(232, 93, 4, 0.06);
}

/* ---- Utility ---- */
.hidden { display: none !important; }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}
.modal-content {
    background: white;
    border-radius: 0.75rem;
    width: 100%;
    max-width: 48rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
    border-radius: 0.75rem 0.75rem 0 0;
    flex-shrink: 0;
}
.modal-body { padding: 1.5rem; }
.modal-close {
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    font-size: 1.25rem;
    line-height: 1;
}
.modal-close:hover { color: var(--color-foreground); }

/* ---- Slide-over ---- */
.slide-over {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28rem;
    max-width: 100vw;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}
.slide-over.open { transform: translateX(0); }
.slide-over-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 49;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.slide-over-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}
.slide-over-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.slide-over-body { padding: 1.5rem; }

/* ---- Flow step cards ---- */
.flow-step-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 0.625rem;
    margin-bottom: 0.5rem;
    cursor: grab;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s, opacity 0.2s;
    user-select: none;
}
.flow-step-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: rgba(0,0,0,0.12);
}
.flow-step-card.dragging {
    opacity: 0.66;
    cursor: grabbing;
    border-color: var(--color-accent);
    border-style: dashed;
    background: #fef7f0;
    z-index: 10;
    box-shadow: none;
    transform: none;
}
.flow-step-card.disabled { opacity: 0.45; }

/* Drop indicator line during drag */
.flow-step-drop-indicator {
    height: 3px;
    background: var(--color-accent);
    border-radius: 2px;
    margin: -0.125rem 0;
    position: relative;
    pointer-events: none;
}
.flow-step-drop-indicator::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent);
}
.flow-step-drop-indicator::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent);
}

.flow-step-grip {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-border);
    cursor: grab;
    flex-shrink: 0;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: color 0.15s;
}
.flow-step-card:hover .flow-step-grip { color: var(--color-muted); }

.flow-step-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: #f4f4f5;
    flex-shrink: 0;
    transition: background-color 0.15s;
}
.flow-step-card:hover .flow-step-icon-wrap { background: #e4e4e7; }

.flow-step-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #52525b;
}
.flow-step-icon-statement { color: #d97706; }
.flow-step-icon-question { color: #7c3aed; }
.flow-step-icon-connection { color: #2563eb; }
.flow-step-icon-function { color: #4f46e5; }
.flow-step-icon-tool { color: #0891b2; }

.flow-step-body { flex: 1; min-width: 0; }
.flow-step-title { font-weight: 600; font-size: 0.875rem; }
.flow-step-subtitle { font-size: 0.75rem; color: var(--color-muted); margin-top: 0.125rem; }

.flow-step-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Edit / Delete icon buttons */
.flow-step-edit-btn,
.flow-step-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.flow-step-edit-btn:hover {
    background-color: #dbeafe;
    color: #2563eb;
    transform: rotate(12deg);
}
.flow-step-delete-btn:hover {
    background-color: #fef2f2;
    color: #ef4444;
}

/* Flow type badges */
.badge-statement { background: white; color: #92400e; border: 1px solid #e4e4e7; }
.badge-question { background: white; color: #5b21b6; border: 1px solid #e4e4e7; }
.badge-connection { background: white; color: #1e40af; border: 1px solid #e4e4e7; }
.badge-function { background: white; color: #3730a3; border: 1px solid #e4e4e7; }
.badge-tool { background: white; color: #0e7490; border: 1px solid #e4e4e7; }

/* ---- Post-call field cards ---- */
.pcf-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    transition: box-shadow 0.15s;
}
.pcf-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

.pcf-type-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}
.pcf-type-string { background-color: #0891b2; }
.pcf-type-bool { background-color: #059669; }
.pcf-type-number { background-color: #d97706; }

.pcf-body { flex: 1; min-width: 0; }
.pcf-name { font-weight: 500; font-size: 0.875rem; font-family: monospace; }
.pcf-description { font-size: 0.75rem; color: var(--color-muted); margin-top: 0.125rem; }

.pcf-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Post-call field type badges */
.badge-pcf-string { background-color: #cffafe; color: #155e75; }
.badge-pcf-bool { background-color: #d1fae5; color: #065f46; }
.badge-pcf-number { background-color: #fef3c7; color: #92400e; }

/* Step type picker */
.step-type-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding: 1rem;
}
.step-type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    background: white;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-foreground);
    text-align: center;
}
.step-type-option:hover { border-color: var(--color-accent); background-color: rgba(232, 93, 4, 0.04); }

/* ---- Card select (for style settings) ---- */
.card-select {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.card-select-option {
    flex: 1;
    min-width: 8rem;
    padding: 1rem;
    border: 2px solid var(--color-border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    background: white;
}
.card-select-option:hover { border-color: var(--color-accent); }
.card-select-option.selected {
    border-color: var(--color-accent);
    background-color: rgba(232, 93, 4, 0.06);
}
.card-select-option input[type="radio"] { display: none; }
.card-select-label { font-size: 0.875rem; font-weight: 500; }
.card-select-desc { font-size: 0.75rem; color: var(--color-muted); margin-top: 0.25rem; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 0.25rem; align-items: center; }
.page-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--color-foreground);
    background: white;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.page-btn:hover { background-color: #f4f4f5; }
.page-btn.active { background-color: var(--color-accent); color: white; border-color: var(--color-accent); }

/* ---- Misc ---- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }

.audio-player { width: 100%; margin-top: 0.5rem; }

.score-bar { height: 0.5rem; border-radius: 9999px; background-color: var(--color-border); overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 9999px; transition: width 0.3s; }

/* ---- Onboarding ---- */
.onboarding-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(232, 93, 4, 0.1);
    color: var(--color-accent);
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}
.progress-dots { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 2rem; }
.progress-dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background-color: var(--color-border);
    transition: background-color 0.2s;
}
.progress-dot.active { background-color: var(--color-accent); }
.progress-dot.completed { background-color: var(--color-secondary); }

/* ---- Opening hours rows ---- */
.hours-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}
.hours-row select { flex: 1; }
.hours-row .btn-remove {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    color: #991b1b;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: all 0.15s;
}
.hours-row .btn-remove:hover { background-color: #fef2f2; }

/* ---- Agent cards ---- */
.agent-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.15s, border-color 0.15s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.agent-card:hover { border-color: var(--color-accent); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }

/* ---- Keyword tags ---- */
.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background-color: #f4f4f5;
    border: 1px solid var(--color-border);
    border-radius: 9999px;
    font-size: 0.8125rem;
}
.keyword-tag-remove {
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1;
}
.keyword-tag-remove:hover { color: #ef4444; }

/* ---- Mobile header ---- */
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    background-color: var(--sidebar-bg);
    z-index: 41;
}
.mobile-header button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0.25rem;
}

/* ---- Sidebar backdrop ---- */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 39;
    display: none;
    opacity: 0;
    transition: opacity 0.25s;
}
body.sidebar-mobile-open .sidebar-backdrop {
    display: block;
    opacity: 1;
}

/* ---- Responsive: below lg (1024px) ---- */
@media (max-width: 1023px) {
    .mobile-header { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    /* Override collapsed state on mobile — show full labels in drawer */
    body.sidebar-collapsed .sidebar-logo-text,
    body.sidebar-collapsed .sidebar-label,
    body.sidebar-collapsed .sidebar-user-name {
        display: inline;
    }
    body.sidebar-collapsed .sidebar-section-title {
        display: block;
    }
    body.sidebar-collapsed .sidebar-header {
        justify-content: space-between;
        padding: 1.25rem 1rem;
    }
    body.sidebar-collapsed .sidebar-section {
        padding: 0 0.75rem;
    }
    body.sidebar-collapsed .sidebar-link {
        justify-content: flex-start;
        padding: 0.5rem 0.625rem;
        gap: 0.75rem;
    }
    body.sidebar-collapsed .sidebar-footer {
        padding: 0.75rem 1rem;
    }
    body.sidebar-collapsed .sidebar-user {
        justify-content: space-between;
    }
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width);
    }

    .main-content { margin-left: 0 !important; overflow-x: hidden; }
    /* !important beats Tailwind browser CDN's py-8 which injects after portal.css */
    .main-content-inner { padding-top: 4.5rem !important; }
    .sidebar-toggle { display: none; }
    .card { overflow: hidden; }
}

/* ---- Responsive: below sm (640px) ---- */
@media (max-width: 639px) {
    .main-content-inner {
        padding-top: 4.5rem !important;
        padding-right: 0.75rem;
        padding-bottom: 1rem;
        padding-left: 0.75rem;
    }
    .slide-over { width: 100vw; }
    .modal-overlay { padding: 0.5rem; }
    .modal-content { margin-top: 0; max-height: 100vh; border-radius: 0.5rem; }
    .tab { padding: 0.75rem 1rem; }
    .sub-tab-bar { overflow-x: auto; }
    .hours-row { flex-wrap: wrap; }
    .hours-row select { flex: 1 1 45%; min-width: 0; }
    .hours-row select:first-child { flex: 1 1 100%; }
    .hours-row .btn-remove { flex: 0 0 auto; }
    .step-type-picker { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Tools page ---- */
.tool-card {
    transition: box-shadow 0.15s ease;
}
.tool-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.tool-card-available {
    opacity: 0.95;
}
.tool-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tool-feature-tag {
    display: inline-block;
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background-color: rgba(45, 106, 79, 0.08);
    color: var(--color-secondary);
    font-weight: 500;
}
.btn-outline-danger {
    background: none;
    border: 1px solid #fca5a5;
    border-radius: 0.375rem;
    color: #dc2626;
    cursor: pointer;
    font-weight: 500;
}
.btn-outline-danger:hover {
    background-color: #fef2f2;
}

/* ---- Info tooltips ---- */
.info-tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    cursor: help;
}
.info-tooltip-icon {
    font-size: 0.7rem;
    color: var(--color-muted);
    width: 0.95rem;
    height: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    font-style: normal;
    font-weight: 600;
    line-height: 1;
}
.info-tooltip-wrap:hover .info-tooltip-icon {
    color: var(--color-accent);
    border-color: var(--color-accent);
}
.info-tooltip-box {
    display: none;
    position: fixed;
    background: var(--color-foreground);
    color: #fff;
    font-size: 0.75rem;
    font-family: var(--font-body);
    font-weight: 400;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    white-space: normal;
    width: max-content;
    max-width: 14rem;
    z-index: 9999;
    line-height: 1.4;
    pointer-events: none;
}

/* ---- Toggle switch ---- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 2.5rem;
    height: 1.375rem;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--color-border);
    border-radius: 9999px;
    transition: background-color 0.2s ease;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 1rem;
    width: 1rem;
    left: 0.1875rem;
    bottom: 0.1875rem;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
}
.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-accent);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(1.125rem);
}

/* ---- Team table → card view on mobile ---- */
@media (max-width: 767px) {
    .team-card-wrap { padding: 0; border: none; background: transparent; box-shadow: none; }
    .team-table thead { display: none; }
    .team-table,
    .team-table tbody { display: block; }
    .team-table tbody tr {
        display: block;
        background: white;
        border: 1px solid var(--color-border);
        border-radius: 0.75rem;
        padding: 1rem;
        margin-bottom: 0.75rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
        cursor: pointer;
    }
    .team-table tbody tr:hover { background-color: #f9f9f7; }
    .team-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.375rem 0;
        border: none;
        font-size: 0.875rem;
    }
    .team-table td::before {
        content: attr(data-label);
        font-weight: 500;
        font-size: 0.8125rem;
        color: var(--color-muted);
        flex-shrink: 0;
        margin-right: 1rem;
    }
    .team-table td[data-label=""]::before { display: none; }
    .team-table td:last-child {
        justify-content: flex-end;
        padding-top: 0.75rem;
        margin-top: 0.375rem;
        border-top: 1px solid var(--color-border);
    }
}

/* ---- Call table → card view on mobile ---- */
@media (max-width: 767px) {
    .call-table-wrap { overflow-x: visible; }
    .call-table thead { display: none; }
    .call-table,
    .call-table tbody { display: block; }
    .call-table tbody tr {
        display: block;
        background: white;
        border: 1px solid var(--color-border);
        border-radius: 0.75rem;
        padding: 0.875rem 1rem;
        margin-bottom: 0.5rem;
        cursor: pointer;
    }
    .call-table tbody tr:hover { background-color: #f9f9f7; }
    .call-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
        border: none;
        font-size: 0.875rem;
    }
    .call-table td::before {
        content: attr(data-label);
        font-weight: 500;
        font-size: 0.8125rem;
        color: var(--color-muted);
        flex-shrink: 0;
        margin-right: 1rem;
    }
    .call-table td[data-label=""]::before { display: none; }
    .call-table td:first-child { font-weight: 500; }
    .call-table td:first-child::before { display: none; }
}

/* ---- Flow step cards — mobile adjustments ---- */
@media (max-width: 639px) {
    .flow-step-grip {
        min-width: 2.75rem;
        min-height: 2.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .flow-step-actions .badge { display: none; }
    .flow-step-edit-btn,
    .flow-step-delete-btn {
        width: 2.75rem;
        height: 2.75rem;
    }
    .flow-step-card { padding: 0.625rem 0.75rem; gap: 0.5rem; }
}

/* ---- Touch target minimums on mobile ---- */
@media (max-width: 767px) {
    .btn-sm { min-height: 2.75rem; min-width: 2.75rem; padding: 0.5rem 0.875rem; }
    .page-btn { min-height: 2.75rem; min-width: 2.75rem; }
}

/* ---- Tab bar scroll fade ---- */
.tab-bar {
    position: relative;
    -webkit-overflow-scrolling: touch;
}
.tab-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 2rem;
    background: linear-gradient(to right, transparent, var(--color-background));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.tab-bar.has-overflow::after { opacity: 1; }

/* ---- Responsive: lg+ (1024px) — force hide mobile elements ---- */
@media (min-width: 1024px) {
    .mobile-header { display: none !important; }
    .sidebar-backdrop { display: none !important; }
}
