/* AB Mobil Support — minimal SaaS admin UI */
:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #e3e6ea;
    --text: #1c2430;
    --muted: #64707f;
    --primary: #2456d6;
    --primary-hover: #1c46b4;
    --danger: #c0362c;
    --success: #1c7c46;
    --warning: #a16207;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06);
    font-size: 15px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .brand { font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a {
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 500;
    white-space: nowrap;
}
.topbar nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.topbar nav a.active { background: #e8eefc; color: var(--primary); }
.topbar .userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; white-space: nowrap; }

/* Right-aligned settings dropdown (pure HTML details, no JS) */
.nav-dropdown { position: relative; }
.nav-dropdown summary {
    list-style: none;
    cursor: pointer;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 500;
    white-space: nowrap;
    user-select: none;
}
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary:hover { background: var(--bg); color: var(--text); }
.nav-dropdown[data-active] summary, .nav-dropdown[open] summary { background: #e8eefc; color: var(--primary); }
.nav-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(16, 24, 40, .12);
    padding: 6px;
    z-index: 40;
}
.nav-dropdown-menu a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
}
.nav-dropdown-menu a:hover { background: var(--bg); text-decoration: none; }
.nav-dropdown-menu a.active { background: #e8eefc; color: var(--primary); }
.nav-plain-link { color: var(--muted); padding: 6px 12px; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.nav-plain-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }

.nav-badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    line-height: 18px;
}
.nav-badge.badge-warn { background: var(--warning); }
.nav-badge.badge-danger { background: var(--danger); }

/* Layout */
.container { max-width: 1480px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }

/* Cards, tables */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-pad { padding: 16px 20px; }
.card h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 12px; }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #fafbfc; }
.row-link { color: inherit; display: block; }
.row-link:hover { text-decoration: none; }

/* Pills & chips */
.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.pill-NEW { background: #e8eefc; color: #2456d6; }
.pill-PROCESSING { background: #ede9fe; color: #6d28d9; }
.pill-READY_FOR_REVIEW { background: #dcfce7; color: #15803d; }
.pill-NEEDS_HUMAN { background: #fef3c7; color: #a16207; }
.pill-APPROVED { background: #dbeafe; color: #1d4ed8; }
.pill-SENDING { background: #e0f2fe; color: #0369a1; }
.pill-SENT { background: #f1f5f9; color: #475569; }
.pill-FAILED { background: #fee2e2; color: #b91c1c; }
.pill-CLOSED { background: #f1f5f9; color: #94a3b8; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.chip-high { background: #dcfce7; color: #15803d; }
.chip-medium { background: #fef3c7; color: #a16207; }
.chip-low { background: #fee2e2; color: #b91c1c; }
.chip-lang { background: #eef2f6; color: #475569; text-transform: uppercase; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    color: var(--text);
    background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd0f7; border-color: var(--primary); }
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #fff; border-color: #efc4c0; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #166534; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.loading { position: relative; color: transparent; }
.btn.loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 14px; height: 14px;
    border: 2px solid rgba(0,0,0,.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Flash */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash-success { background: #f0fdf4; border-color: #bbe7c9; color: var(--success); }
.flash-error { background: #fef2f2; border-color: #f3c7c3; color: var(--danger); }
.flash-warning { background: #fffbeb; border-color: #f2e2b3; color: var(--warning); }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=text] { width: 260px; }
.filters select { width: auto; }

/* Empty state */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }

/* Pagination */
.pagination-wrap { margin-top: 16px; font-size: 14px; }
.pagination-wrap nav { display: flex; gap: 6px; flex-wrap: wrap; }

/* Ticket detail */
.ticket-grid { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .ticket-grid { grid-template-columns: 1fr; } }

.mail-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; background: var(--surface); }
.mail-item.outbound { border-left: 3px solid var(--primary); }
.mail-item.inbound { border-left: 3px solid #94a3b8; }
.mail-head { padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fafbfc; font-size: 13px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mail-head .who { font-weight: 600; }
.mail-head .when { color: var(--muted); white-space: nowrap; }
.mail-body { padding: 14px; }
.mail-body pre { margin: 0; white-space: pre-wrap; word-wrap: break-word; font: inherit; }
.mail-html-frame { width: 100%; border: 0; min-height: 60px; max-height: 640px; }
.mail-attachments { padding: 8px 14px; border-top: 1px solid var(--border); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.mail-attachments a { background: var(--bg); padding: 3px 10px; border-radius: 6px; }

.ai-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.ai-meta dt { color: var(--muted); }
.ai-meta dd { margin: 0; }

.source-item { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.source-item .name { font-weight: 600; }
.source-item .excerpt { color: var(--muted); margin-top: 4px; font-size: 12px; white-space: pre-wrap; }

.stale-note { background: #fffbeb; border: 1px solid #f2e2b3; color: var(--warning); border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }

.action-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.action-bar form { display: inline; }

.kbd { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--muted); }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .card-pad { padding: 28px; }
.auth-card h1 { font-size: 18px; margin: 0 0 18px; text-align: center; }

/* In-page confirmation modal */
dialog.confirm-modal {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(16, 24, 40, .18);
    padding: 22px 24px;
    width: min(420px, calc(100vw - 40px));
    background: var(--surface);
    color: var(--text);
}
dialog.confirm-modal::backdrop {
    background: rgba(16, 24, 40, .45);
}
.confirm-modal-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
}
.confirm-modal-text {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 18px;
    white-space: pre-line;
}
.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.w-100 { width: 100%; }

/* ============================================================
   Inbox filter header
   ============================================================ */
.inbox-head {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.inbox-head select { width: auto; }
.inbox-head input[type=text] { width: 100%; }
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-row + .filter-row { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}
.search-wrap { position: relative; flex: 1; min-width: 240px; }
.search-wrap input { padding-left: 32px; }
.search-wrap svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); opacity: .45; }
.daterange { display: inline-flex; gap: 6px; align-items: center; }
.daterange input { width: 150px; }

/* Segmented control (confidence) — radio inputs, works without JS as a form field */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    padding: 5px 11px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}
.seg span:hover { color: var(--text); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid #bcd0f7; }
.seg .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-high { background: #16a34a; }
.dot-medium { background: #d9a012; }
.dot-low { background: #dc2626; }

/* Toggle switch (requires human) */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    padding: 5px 11px 5px 8px;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
    width: 32px; height: 18px;
    border-radius: 999px;
    background: #d3d8de;
    position: relative;
    transition: background .15s;
}
.switch .track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
    transition: transform .15s;
}
.switch input:checked + .track { background: var(--warning); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid #bcd0f7; }
.switch.on { border-color: #f2e2b3; background: #fffbeb; color: var(--warning); }

/* Active-filter summary */
.filter-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 13px;
}
.tagchip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e8eefc;
    color: var(--primary);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
}
.tagchip:hover { background: #dbe4fa; text-decoration: none; }

table.list tbody tr.is-human td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.human-flag { font-size: 12px; font-weight: 600; color: var(--warning); }

/* ============================================================
   Ticket detail — two equal parts: the ticket and the reply
   ============================================================ */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1180px) { .split { grid-template-columns: 1fr; } }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}
.panel-head .num {
    width: 22px; height: 22px;
    flex: none;
    border-radius: 6px;
    background: var(--text);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: grid;
    place-items: center;
}
.panel-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text); }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel--reply .panel-head { background: #f4f7ff; border-bottom-color: #dbe4fa; }
.panel--reply .panel-head .num { background: var(--primary); }
.panel .mail-item:last-child { margin-bottom: 0; }

.meta-strip {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.meta-box { border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12px; min-width: 96px; }
.meta-box .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.meta-box .v { font-weight: 600; }
.meta-box .v-normal { font-weight: 400; }
.meta-box-wide { flex: 1; min-width: 220px; }

/* Reply editor */
.reply-lang { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.lang-flow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 10px;
    font-weight: 600;
    color: var(--text);
}
.editor-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.send-box { border-top: 1px solid var(--border); background: #fafbfc; padding: 14px 16px; }
.send-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: 13px; margin: 0 0 12px; }
.send-meta dt { color: var(--muted); }
.send-meta dd { margin: 0; word-break: break-word; }

/* Collapsed disclosure (sources, reasoning, translation, preview) */
details.disclose { border: 1px solid var(--border); border-radius: var(--radius); background: #fbfcfd; margin-top: 14px; }
details.disclose > summary {
    cursor: pointer;
    list-style: none;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary:hover { color: var(--text); }
details.disclose > summary .caret { font-size: 11px; transition: transform .15s; }
details.disclose[open] > summary { border-bottom: 1px solid var(--border); color: var(--text); }
details.disclose[open] > summary .caret { transform: rotate(90deg); }
details.disclose .disclose-body { padding: 14px; }
.reasoning {
    font-size: 13px;
    color: var(--muted);
    white-space: pre-wrap;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
}

/* Slovenian version of a foreign-language message, with the original one click away */
.translation-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 7px 13px;
    border-bottom: 1px solid var(--border);
    background: #f7f9fc;
    font-size: 13px;
}
.translation-bar form { display: inline; }
.translation-bar .chip-lang { text-transform: none; }

/* Questions the AI needs the operator to answer */
.questions {
    border: 1px solid #f2e2b3;
    background: #fffdf6;
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 14px;
}
.questions-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.questions-head strong { color: var(--warning); }
.question + .question { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #f2e2b3; }
.question-text { font-size: 14px; font-weight: 600; margin-bottom: 6px; display: flex; gap: 8px; align-items: baseline; }
.question-num {
    flex: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--warning);
    color: #fff;
    font-size: 11px;
    display: inline-grid;
    place-items: center;
}
.question textarea { min-height: 56px; background: #fff; }
.file-field { display: block; margin-top: 6px; font-weight: 400; }
.file-field input[type=file] { font-size: 12px; margin-top: 3px; }
input[type=file] {
    font: inherit;
    font-size: 13px;
    max-width: 100%;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

/* Attachments queued for the outgoing reply */
.reply-files { margin-bottom: 12px; }
.reply-file {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    margin-bottom: 6px;
    font-size: 13px;
}
.reply-file form { margin-left: auto; }
