:root {
    --nav-bg: #f6f7fb;
    --nav-border: #e4e7ef;
    --text: #101828;
    --muted: #667085;
    --line: #eaecf0;
    --blue: #175cd3;
    --blue-bg: #eff4ff;
    --green: #039855;
    --green-bg: #ecfdf3;
    --red: #d92d20;
    --red-bg: #fef3f2;
    --amber: #dc6803;
    --card: #ffffff;
    --shadow: 0 14px 34px rgba(16, 24, 40, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #fbfcfe;
    color: var(--text);
    font-family: Inter, Arial, Helvetica, sans-serif;
    font-size: 14px;
}

.side-nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    background: var(--nav-bg);
    border-right: 1px solid var(--nav-border);
    padding: 18px 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.side-nav-main {
    min-height: 0;
}

.nav-bottom {
    border-top: 1px solid var(--nav-border);
    padding-top: 12px;
    margin-top: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 6px 24px;
}

.brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--blue);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    flex: 0 0 auto;
}

.brand-title {
    font-weight: 700;
    font-size: 15px;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.nav-section {
    margin-top: 12px;
}

.nav-heading {
    color: #667085;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: .04em;
    margin: 18px 8px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #344054;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 9px;
    margin: 2px 0;
}

.nav-link:hover,
.nav-link.active {
    background: #ffffff;
    color: #101828;
    box-shadow: 0 1px 2px rgba(16,24,40,.06);
}

.logout-link {
    color: #b42318;
}

.logout-link:hover {
    background: #fef3f2;
    color: #b42318;
}

.nav-icon {
    width: 18px;
    display: inline-block;
    text-align: center;
}

.main-content {
    margin-left: 248px;
    padding: 28px 30px;
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 22px;
}

.page-header h1 {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 700;
}

.page-header p {
    margin: 0;
    color: var(--muted);
}

.toolbar {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}

.date-range {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.date-range label,
.settings-grid label,
.login-form label {
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}

input[type="date"],
input[type="email"],
input[type="text"],
input[type="password"],
select {
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 9px 10px;
    min-width: 160px;
    background: #fff;
    color: var(--text);
}

input[type="email"],
input[type="text"],
input[type="password"],
select {
    width: 100%;
}

.btn {
    border: 1px solid var(--blue);
    background: var(--blue);
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-light {
    background: #fff;
    color: #344054;
    border-color: #d0d5dd;
}

.btn-danger {
    background: var(--red);
    border-color: var(--red);
}

.btn:hover {
    opacity: .94;
}

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

.table-card,
.settings-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.settings-card {
    padding: 22px;
    max-width: 950px;
    margin-bottom: 18px;
}

.settings-card h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.settings-help {
    color: var(--muted);
    line-height: 1.5;
}

.settings-form {
    margin-top: 18px;
}

.switch-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fcfcfd;
    margin-bottom: 18px;
}

.switch-row input {
    margin-top: 4px;
    width: auto;
    min-width: auto;
}

.switch-row small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.inline-check {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    color: #344054;
}

.inline-check input {
    min-width: auto;
    width: auto;
}

.field-label {
    display: block;
    color: #344054;
    font-weight: 700;
    margin-bottom: 8px;
}

.email-list {
    margin-bottom: 10px;
}

.email-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.email-row input {
    flex: 1;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.settings-divider {
    height: 1px;
    background: var(--line);
    margin: 22px 0;
}

.settings-meta p {
    margin: 0 0 8px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.notice {
    max-width: 950px;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid;
}

.notice-success {
    background: var(--green-bg);
    border-color: #abefc6;
    color: #067647;
}

.notice-error {
    background: var(--red-bg);
    border-color: #fecdca;
    color: #b42318;
}

.table-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    color: #344054;
}

.auto-refresh-status {
    font-size: 13px;
}

.muted {
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
}

.calls-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

.calls-table th,
.calls-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.calls-table th {
    color: #667085;
    font-weight: 600;
    background: #fcfcfd;
}

.calls-table tbody tr {
    cursor: pointer;
}

.calls-table tbody tr:hover {
    background: #f9fafb;
}

.calls-table tbody tr.active-row {
    background: #eff4ff;
}

.empty {
    text-align: center !important;
    color: var(--muted);
    padding: 34px !important;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #344054;
    font-size: 12px;
    font-weight: 600;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #98a2b3;
}

.badge.positive::before,
.badge.ended::before {
    background: var(--green);
}

.badge.negative::before,
.badge.failed::before {
    background: var(--red);
}

.badge.neutral::before {
    background: #2e90fa;
}

.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.18);
    z-index: 40;
}

.drawer-backdrop.open {
    display: block;
}

.call-drawer {
    position: fixed;
    top: 0;
    right: -560px;
    width: min(560px, 100vw);
    height: 100vh;
    background: #fff;
    box-shadow: var(--shadow);
    border-left: 1px solid var(--line);
    z-index: 50;
    transition: right .22s ease;
    display: flex;
    flex-direction: column;
}

.call-drawer.open {
    right: 0;
}

.drawer-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.drawer-header h2 {
    margin: 0;
    font-size: 18px;
}

.drawer-subtitle {
    color: var(--muted);
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.4;
}

.drawer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    border: 0;
    background: #f2f4f7;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: grid;
    place-items: center;
}

.icon-btn:hover {
    background: #e4e7ec;
}

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

.delete-btn {
    background: var(--red-bg);
    color: var(--red);
}

.delete-btn:hover {
    background: #fee4e2;
}

.drawer-audio,
.analysis-grid,
.drawer-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.drawer-audio audio {
    width: 100%;
}

.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.analysis-item {
    background: #f9fafb;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 10px;
}

.analysis-label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.analysis-value {
    font-weight: 700;
}

.drawer-section h3 {
    margin: 0 0 10px;
    font-size: 14px;
}

.drawer-section p {
    margin: 0;
    color: #344054;
    line-height: 1.5;
}

.transcript {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: calc(100vh - 455px);
    padding-right: 4px;
}

.message {
    border-radius: 12px;
    padding: 10px 12px;
    background: #f2f4f7;
    line-height: 1.5;
}

.message.agent {
    background: #f2f4f7;
}

.message.user {
    background: #eff4ff;
}

.message.tool {
    background: #fff7ed;
}

.message-role {
    color: #667085;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
    text-transform: capitalize;
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(16, 24, 40, .38);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.open {
    display: flex;
}

.confirm-modal {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.confirm-modal h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.confirm-modal p {
    margin: 0;
    color: #475467;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

code {
    background: #f2f4f7;
    padding: 2px 5px;
    border-radius: 4px;
}

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(23, 92, 211, .16), transparent 32%),
        #f6f7fb;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(420px, 100%);
}

.login-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 26px;
}

.login-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 22px;
}

.login-brand h1 {
    margin: 0;
    font-size: 22px;
}

.login-brand p {
    margin: 3px 0 0;
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-btn {
    width: 100%;
    margin-top: 4px;
}

@media (max-width: 820px) {
    .side-nav {
        position: static;
        width: 100%;
        height: auto;
    }

    .main-content {
        margin-left: 0;
        padding: 18px;
    }

    .table-meta,
    .email-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .email-row input,
    .email-row button {
        width: 100%;
    }

    .settings-grid,
    .analysis-grid {
        grid-template-columns: 1fr;
    }
}
