/* Theme follows the Calls QA Agent dashboard (white sidebar, #2f5aa7 accents, header card). */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; background: #f3f4f6; color: #1f2937; overflow: hidden; font-size: 14px; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }
.App { display: flex; height: 100vh; }

/* sidebar */
.sidebar { width: 230px; min-width: 230px; background: #fff; border-right: 1px solid #d9dee8; display: flex; flex-direction: column; transition: width .22s, min-width .22s; overflow: hidden; }
.sidebar.collapsed { width: 72px; min-width: 72px; }
.sidebar.collapsed .sidebar-label, .sidebar.collapsed .ai-pill span { display: none; }
.sidebar-logo-zone { height: 78px; display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid #e3e7ef; }
.sidebar-brand-logo { height: 32px; max-width: 100%; object-fit: contain; }
.sidebar-nav { flex: 1; padding: 8px 0; }
.sidebar-item { width: calc(100% - 8px); margin: 0 4px 1px; display: flex; align-items: center; gap: 10px; border: 0; border-left: 3px solid transparent; background: transparent; color: #374151; padding: 10px 12px 10px 16px; cursor: pointer; text-align: left; }
.sidebar-item:hover { background: #edf2fb; color: #2f5aa7; border-left-color: #2f5aa7; }
.sidebar-item.active { background: #dbe7fb; color: #2f5aa7; border-left-color: #2f5aa7; }
.sidebar-label { font-size: 15px; font-weight: 500; white-space: nowrap; }
.sidebar-footer { padding: 10px; border-top: 1px solid #e3e7ef; }
.ai-pill { font-size: 12px; padding: 8px 10px; border-radius: 8px; background: #f8fafc; border: 1px solid #d7dee9; display: flex; gap: 6px; align-items: center; }
.ai-pill i { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; flex: 0 0 8px; }
.ai-pill.on i { background: #16a34a; }

/* header */
.right-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-header { height: 62px; min-height: 62px; margin: 0 24px; background: #fff; border: 1px solid #e1e6ef; border-top: 0; border-radius: 0 0 10px 10px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px 0 12px; box-shadow: 0 2px 6px rgba(15,23,42,.06); }
.header-left-section { display: flex; align-items: center; gap: 12px; }
.sidebar-toggle-btn { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: #5b6472; }
.sidebar-toggle-btn:hover { background: #f3f4f6; color: #2f5aa7; }
.header-title-group { display: flex; flex-direction: column; }
.header-app-name { font-size: 15px; font-weight: 600; color: #343a40; }
.header-tagline { font-size: 11px; color: #7a8595; }
.header-right-section { display: flex; gap: 8px; }
.kpi { border: 1px solid #e1e6ef; border-radius: 8px; padding: 4px 10px; text-align: center; min-width: 74px; cursor: pointer; background: #fff; }
.kpi b { display: block; font-size: 16px; color: #2f5aa7; }
.kpi span { font-size: 11px; color: #6b7280; }
.kpi.warn b { color: #dc3545; } .kpi.amber b { color: #d97706; }

.main-content { flex: 1; min-height: 0; padding: 14px 24px 18px; overflow: auto; }
.page { display: none; height: 100%; }
.page.active { display: block; }
.card { background: #fff; border: 1px solid #e1e6ef; border-radius: 10px; box-shadow: 0 2px 6px rgba(15,23,42,.04); padding: 14px; }
.muted { color: #6b7280; } .small { font-size: 12px; }
h3 { margin: 0 8px 0 0; font-size: 16px; }

/* buttons & inputs */
.btn { border: 1px solid #d7dee9; background: #fff; color: #374151; border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #2f5aa7; color: #2f5aa7; }
.btn.primary { background: #2f5aa7; border-color: #2f5aa7; color: #fff; }
.btn.primary:hover { background: #24488a; color: #fff; }
.btn.danger:hover { background: #dc3545; border-color: #dc3545; color: #fff; }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: wait; }
.link { border: 0; background: none; color: #2f5aa7; cursor: pointer; }
.input, select, textarea, .form-grid input { border: 1px solid #d7dee9; border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%; }
.input:focus, textarea:focus, select:focus, .form-grid input:focus { outline: 2px solid #dbe7fb; border-color: #2f5aa7; }

/* planner */
.planner { display: flex; gap: 14px; height: 100%; }
.map-wrap { flex: 1; position: relative; border-radius: 10px; overflow: hidden; border: 1px solid #e1e6ef; }
#map { position: absolute; inset: 0; }
.map-tools { position: absolute; top: 10px; left: 54px; z-index: 500; display: flex; gap: 6px; }
.map-tools .btn { box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.picking #map { cursor: crosshair; }
.layers { position: absolute; bottom: 14px; left: 10px; z-index: 500; background: #fff; border-radius: 8px; padding: 8px 10px; box-shadow: 0 1px 6px rgba(0,0,0,.15); font-size: 12px; line-height: 1.8; }
.layers label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #0002; }
.chat-panel { width: 440px; min-width: 360px; display: flex; flex-direction: column; background: #fff; border: 1px solid #e1e6ef; border-radius: 10px; overflow: hidden; }
.chat-head { padding: 10px 14px; border-bottom: 1px solid #e3e7ef; display: flex; align-items: center; gap: 8px; }
.chat-head .link { margin-left: auto; font-size: 12px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #dbe7fb; color: #2f5aa7; }
.tag.off { background: #fef3c7; color: #92400e; }
.chat { flex: 1; overflow-y: auto; padding: 12px; background: #f8fafc; }
.msg { margin: 8px 0; max-width: 92%; line-height: 1.5; word-wrap: break-word; }
.msg.user { margin-left: auto; background: #2f5aa7; color: #fff; padding: 8px 12px; border-radius: 12px 12px 2px 12px; width: fit-content; }
.msg.bot .bubble { background: #fff; border: 1px solid #e1e6ef; padding: 10px 12px; border-radius: 12px 12px 12px 2px; }
.msg.bot ul { margin: 4px 0; padding-left: 18px; }
.msg .meta { font-size: 11px; color: #9ca3af; margin-top: 3px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; background: #94a3b8; border-radius: 50%; animation: b 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes b { 50% { transform: translateY(-4px); opacity: .5; } }
.chips { padding: 6px 10px 0; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid #eef1f6; }
.chip { border: 1px solid #c9d6ee; background: #f1f5fd; color: #2f5aa7; border-radius: 14px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip:hover { background: #dbe7fb; }
.chat-input { display: flex; gap: 8px; padding: 10px; }
.chat-input textarea { resize: none; max-height: 120px; }

/* result cards inside chat */
.rcard { margin-top: 8px; background: #fff; border: 1px solid #dbe3f0; border-radius: 10px; overflow: hidden; font-size: 13px; }
.rcard-head { background: #f1f5fd; padding: 8px 10px; font-weight: 600; color: #24488a; display: flex; justify-content: space-between; gap: 6px; }
.rcard-body { padding: 8px 10px; }
.best { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.best div { background: #f8fafc; border-radius: 8px; padding: 6px; text-align: center; }
.best b { display: block; font-size: 15px; color: #1f2937; }
.best span { font-size: 11px; color: #6b7280; }
.opt { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; padding: 6px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; align-items: center; }
.opt:hover { background: #f8fafc; }
.opt.sel { border-color: #2f5aa7; background: #f1f5fd; }
.opt .rk { width: 20px; height: 20px; border-radius: 50%; background: #e5e7eb; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.opt.sel .rk { background: #2f5aa7; color: #fff; }
.opt small { color: #6b7280; display: block; }
.warn-chip { display: inline-block; background: #fef2f2; color: #b91c1c; border-radius: 6px; padding: 1px 6px; font-size: 11px; margin: 2px 2px 0 0; }
.ok-chip { display: inline-block; background: #ecfdf5; color: #047857; border-radius: 6px; padding: 1px 6px; font-size: 11px; margin: 2px 2px 0 0; }
.bar { display: grid; grid-template-columns: 130px 1fr 80px; gap: 6px; align-items: center; font-size: 12px; margin: 2px 0; }
.bar i { display: block; height: 8px; background: #2f5aa7; border-radius: 4px; opacity: .8; }
.bar em { text-align: right; font-style: normal; color: #374151; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
details summary { cursor: pointer; color: #2f5aa7; font-size: 12px; margin-top: 6px; }
ol.steps { margin: 4px 0; padding-left: 18px; font-size: 12px; max-height: 150px; overflow-y: auto; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.compare > div { border-radius: 8px; padding: 6px 8px; font-size: 12px; }
.compare .cur { background: #fef2f2; } .compare .new { background: #ecfdf5; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

/* data tables */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar .input { max-width: 260px; margin-left: auto; }
.tabs { display: flex; gap: 4px; background: #f3f4f6; padding: 3px; border-radius: 8px; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: #4b5563; }
.tabs button.active { background: #fff; color: #2f5aa7; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tabs button em { font-style: normal; font-size: 11px; color: #9ca3af; margin-left: 4px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 190px); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; background: #f8fafc; color: #4b5563; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid #e3e7ef; position: sticky; top: 0; z-index: 1; }
.table td { padding: 8px 10px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
.table tr:hover td { background: #fafbfe; }
.table td.act { white-space: nowrap; text-align: right; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.b-connected, .b-completed, .b-approved { background: #dcfce7; color: #166534; }
.b-needs_planning, .b-proposed, .b-medium { background: #ffedd5; color: #9a3412; }
.b-needs_reroute, .b-rejected, .b-high { background: #fee2e2; color: #991b1b; }
.b-in_progress, .b-low { background: #dbeafe; color: #1e40af; }
.util { width: 80px; height: 6px; background: #e5e7eb; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.util i { display: block; height: 100%; background: #16a34a; }
.empty { padding: 30px; text-align: center; color: #9ca3af; }

/* settings */
.settings-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
#settingsForm fieldset { border: 0; padding: 0; margin: 0 0 14px; }
#settingsForm legend { font-weight: 600; color: #2f5aa7; margin-bottom: 6px; }
.set-row { display: grid; grid-template-columns: 1fr 150px; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px dashed #eef1f6; }
.set-row label { font-size: 13px; }
.set-row small { display: block; color: #9ca3af; font-size: 11px; }
.explain p, .explain li { line-height: 1.55; } .explain ul { padding-left: 18px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 2000; display: grid; place-items: center; }
.modal { background: #fff; border-radius: 12px; width: 640px; max-width: 95vw; max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { padding: 12px 16px; border-bottom: 1px solid #e3e7ef; display: flex; justify-content: space-between; }
.modal form { padding: 14px 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 8px; }
.form-grid label { font-size: 12px; color: #4b5563; display: flex; flex-direction: column; gap: 3px; }
#pickMap { height: 230px; border-radius: 8px; border: 1px solid #e1e6ef; margin-top: 4px; }
.form-err { color: #b91c1c; font-size: 13px; min-height: 18px; margin-top: 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
.logout { width: 100%; margin-top: 8px; }
.logout:hover { background: #dc3545; border-color: #dc3545; color: #fff; }
.login-bg { position: fixed; inset: 0; z-index: 4000; background: linear-gradient(135deg, #eef3fb, #dbe7fb); display: grid; place-items: center; }
.login-card { width: 340px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(47,90,167,.18); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.login-card img { height: 38px; object-fit: contain; }
.login-card h2 { margin: 6px 0 0; font-size: 18px; color: #24488a; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 3000; }
.toast.err { background: #b91c1c; }
.leaflet-tooltip { font-size: 12px; }
