:root {
  color-scheme: light;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #252921;
  background: #f7f5f0;
  --ink: #252921;
  --muted: #5c6357;
  --paper: #fffefa;
  --line: #e5e3d9;
  --green: #284d39;
  --plant: #dcebcf;
  --rust: #8e3a26;
  --clay: #f4dfd3;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; display: grid; grid-template-columns: 225px minmax(0, 1fr); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: var(--green); }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid #476e45; outline-offset: 3px; }

.sidebar { background: #edeee2; border-right: 1px solid #e0e2d4; position: sticky; top: 0; align-self: start; height: 100dvh; padding: 28px 20px 22px; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 6px; color: var(--ink); text-decoration: none; font-size: 1.13rem; font-weight: 760; line-height: 1.05; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: .82rem; font-weight: 540; }
.brand-icon { display: flex; gap: 3px; align-items: flex-end; justify-content: center; width: 40px; height: 40px; padding: 11px 8px; border-radius: 12px; background: var(--green); }
.brand-icon span { width: 4px; border-radius: 3px; background: #d9e8ae; height: 8px; }
.brand-icon span:nth-child(2) { height: 18px; }
.brand-icon span:nth-child(3) { height: 12px; }
nav { display: grid; gap: 5px; margin-top: 48px; }
nav a { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 650; font-size: .94rem; white-space: nowrap; }
nav a:hover, nav a[aria-current="page"] { color: #243e2a; background: #dce4d2; }
.nav-icon { position: relative; flex: 0 0 16px; height: 14px; border: 1.5px solid currentColor; border-radius: 3px; }
.nav-icon[data-icon="rooms"]::before, .nav-icon[data-icon="calc"]::before { content: ''; position: absolute; left: 3px; right: 3px; top: 4px; border-top: 1.5px solid currentColor; }
.nav-icon[data-icon="rooms"]::after { content: ''; position: absolute; left: 2px; bottom: -4px; width: 4px; height: 4px; background: #edeee2; border-left: 1.5px solid currentColor; transform: skewY(-35deg); }
.nav-icon[data-icon="calc"] { height: 17px; }
.nav-icon[data-icon="calc"]::after { content: '··'; position: absolute; top: 3px; left: 2px; font-weight: 800; letter-spacing: 1px; }
.nav-icon[data-icon="link"] { transform: rotate(-35deg); border-radius: 6px; height: 8px; }
.nav-icon[data-icon="link"]::before { content: ''; position: absolute; width: 7px; left: 3px; top: 2px; border-top: 1px solid currentColor; }
.nav-icon[data-icon="activity"]::before { content: ''; position: absolute; inset: 3px 2px; background: currentColor; clip-path: polygon(0 62%, 24% 62%, 43% 6%, 66% 85%, 82% 45%, 100% 45%, 100% 65%, 87% 65%, 63% 100%, 42% 42%, 30% 81%, 0 81%); }
.providers { margin-top: auto; padding: 16px 6px 0; border-top: 1px solid #dbdfd0; display: grid; gap: 10px; }
.provider-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .84rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9c998d; flex: 0 0 8px; }
.dot.online { background: #4a7640; }

main { min-width: 0; width: 100%; max-width: 1550px; margin: 0 auto; padding: 0 42px 44px; }
.topbar { height: 76px; border-bottom: 1px solid #e4e2d9; display: flex; align-items: center; gap: 13px; }
.room-picker { display: flex; flex-direction: row; gap: 10px; align-items: center; white-space: nowrap; }
.room-picker select { width: min(260px, 51vw); }
.view { margin-top: 35px; }
.hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 26px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4.5vw, 3.35rem); font-weight: 740; letter-spacing: -.05em; line-height: 1.06; overflow-wrap: anywhere; }
.hero p { margin-top: 10px; color: var(--muted); line-height: 1.55; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button { border-radius: 9px; min-height: 40px; padding: 8px 14px; border: 1px solid transparent; font-weight: 650; font-size: .9rem; color: var(--ink); white-space: nowrap; }
.button.primary { color: white; background: var(--green); border-color: var(--green); }
.button.primary:hover { background: #365f46; }
.button.quiet { background: var(--paper); border-color: var(--line); }
.button.quiet:hover { background: #f0f2e8; }
.button.danger { color: var(--rust); }
.button.compact { padding: 5px 10px; min-height: 35px; }
.button:disabled { opacity: .55; cursor: default; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { border-radius: 14px; min-height: 122px; background: var(--paper); border: 1px solid var(--line); padding: 16px 19px; display: grid; gap: 4px; align-content: center; }
.metric:first-child { background: #e3ecd9; border-color: #e3ecd9; }
.metric:nth-child(2) { background: #f5e8dd; border-color: #f5e8dd; }
.metric-label { color: var(--muted); font-size: .875rem; font-weight: 650; }
.metric strong { font-size: clamp(1.35rem, 3.2vw, 2rem); font-weight: 720; letter-spacing: -.045em; overflow-wrap: anywhere; }
.metric-detail { color: var(--muted); font-size: .82rem; }
.room-grid { display: grid; grid-template-columns: minmax(270px, .85fr) minmax(320px, 1.35fr); gap: 20px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 15px; min-width: 0; }
.panel-header { padding: 17px 19px; display: flex; gap: 12px; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); min-height: 70px; }
h2 { font-size: 1.16rem; letter-spacing: -.025em; }
#session-select { width: min(49%, 210px); }
.bot { padding: 17px 19px; display: grid; gap: 12px; border-bottom: 1px solid var(--line); }
.bot:last-child { border-bottom: 0; }
.bot-head { display: flex; align-items: center; gap: 11px; }
.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto; background: var(--plant); color: #2d4330; font-weight: 730; font-size: .88rem; }
.avatar.clay { background: var(--clay); color: #65362a; }
.bot-name { min-width: 0; flex: 1; }
.bot h3 { font-size: .99rem; font-weight: 700; overflow-wrap: anywhere; }
.bot-name p { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; margin-top: 4px; }
.bot-goal { color: var(--muted); line-height: 1.5; font-size: .91rem; overflow-wrap: anywhere; }
.bot-footer { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.pill { border-radius: 100px; padding: 4px 9px; background: #f1f0e8; color: var(--muted); font-weight: 650; font-size: .77rem; }
.pill.good { background: var(--plant); color: #305237; }
.pill.warn { background: #f5e2d5; color: var(--rust); }
.bot-footer .actions { gap: 5px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; font-size: .82rem; }
.toggle input { appearance: none; border: 1px solid #a9aa9c; margin: 0; border-radius: 20px; width: 32px; height: 19px; background: #e9e8e0; padding: 2px; cursor: pointer; }
.toggle input::before { display: block; content: ''; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #1827183b; }
.toggle input:checked { background: var(--green); border-color: var(--green); }
.toggle input:checked::before { transform: translateX(13px); }

.session-strip { display: grid; gap: 10px; padding: 14px 19px; border-bottom: 1px solid var(--line); }
.session-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 7px; }
.session-head strong { overflow-wrap: anywhere; }
.session-meta { color: var(--muted); font-size: .86rem; }
.session-alert { color: var(--rust); font-size: .91rem; line-height: 1.4; }
.chat { display: grid; align-content: start; gap: 15px; min-height: 268px; max-height: 570px; overflow: auto; padding: 20px; background: #fbfaf5; border-radius: 0 0 15px 15px; }
.empty { color: var(--muted); font-size: .95rem; line-height: 1.55; padding: 16px 19px; }
.chat .empty { align-self: center; text-align: center; padding: 0; }
.chat:has(.empty:only-child) { align-content: center; }
.message { display: flex; gap: 10px; align-items: start; }
.message-content { min-width: 0; }
.message-meta { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 4px; font-size: .83rem; color: var(--muted); align-items: baseline; }
.message-meta strong { color: var(--ink); overflow-wrap: anywhere; }
.bubble { background: #fffefa; border: 1px solid var(--line); padding: 10px 12px; border-radius: 3px 12px 12px; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.52; }
.message-note { color: var(--muted); margin-top: 4px; font-size: .78rem; }

.cost-grid, .setup-grid { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.cost-form, .cost-result, .setup-card { padding: 23px; display: grid; gap: 16px; }
.cost-result { background: #e9f0e0; border-color: #dce5d3; }
.cost-result .total { display: block; font-size: clamp(1.7rem, 4vw, 2.8rem); font-weight: 730; letter-spacing: -.05em; margin-top: 4px; }
.cost-result .helper { color: var(--muted); font-size: .88rem; }
.cost-result dl { display: grid; margin: 0; }
.cost-result dl div { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 7px 15px; border-top: 1px solid #d2ddc9; padding: 10px 0; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 640; overflow-wrap: anywhere; }
.setup-card p, .setup-card li { color: var(--muted); line-height: 1.6; }
.setup-card ol { margin: 0; padding-left: 23px; display: grid; gap: 10px; }
.provider-setup { display: grid; gap: 14px; margin-bottom: 24px; }
.provider-form { gap: 12px; }
.provider-form header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.provider-form h3 { font-size: 1.06rem; }
.provider-form a { justify-self: start; font-size: .88rem; }
.form-result { border-radius: 8px; padding: 8px 10px; background: var(--plant); font-size: .88rem; overflow-wrap: anywhere; }
.form-result.error { background: var(--clay); color: var(--rust); }
code { font-size: .87rem; }

.operations-grid { display: grid; grid-template-columns: minmax(235px, .78fr) minmax(320px, 1.6fr); align-items: start; gap: 20px; }
.operation-bot { text-align: left; width: 100%; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 9px; padding: 14px; background: transparent; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.operation-bot:last-child { border-bottom: 0; border-radius: 0 0 15px 15px; }
.operation-bot:hover, .operation-bot[aria-pressed="true"] { background: #edf2e6; }
.operation-bot-name { flex: 1 1 92px; display: grid; gap: 3px; font-size: .9rem; overflow-wrap: anywhere; }
.operation-bot-name small { color: var(--muted); font-size: .79rem; }
.operation-header { align-items: start; }
.operation-header h2, .operation-header p { overflow-wrap: anywhere; }
.operation-header .pill { flex-shrink: 0; }
.operation-content { display: grid; gap: 13px; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.operation-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.operation-metrics > div { min-width: 0; padding: 11px; display: grid; align-content: start; gap: 3px; border: 1px solid var(--line); border-radius: 10px; background: #f9f8f1; overflow-wrap: anywhere; }
.operation-metrics span { color: var(--muted); font-size: .83rem; font-weight: 650; }
.operation-metrics strong { font-size: clamp(1.05rem, 3vw, 1.45rem); }
.operation-metrics small { color: var(--muted); font-size: .77rem; }
.budget-summary { display: grid; gap: 9px; padding: 12px; background: #edf2e6; border-radius: 10px; }
.budget-summary > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px 14px; }
.budget-summary h3 { font-size: .91rem; }
.budget-summary strong { font-size: .9rem; }
.budget-summary progress { accent-color: var(--green); width: 100%; height: 13px; }
.operation-messages { list-style: none; padding: 0; margin: 0; }
.operation-messages li { padding: 13px 19px; border-bottom: 1px solid var(--line); }
.operation-messages li:last-child { border-bottom: 0; }
.operation-messages .bubble { background: #f9f8f1; }
.operation-page { padding: 12px 19px; border-top: 1px solid var(--line); }

label { display: grid; gap: 6px; color: var(--ink); font-weight: 650; font-size: .89rem; }
input:not([type="checkbox"]), select, textarea { border-radius: 8px; min-width: 0; width: 100%; border: 1px solid #dadbd0; background: #fffefa; min-height: 40px; padding: 8px 10px; color: var(--ink); font-weight: 460; }
select { appearance: none; padding-right: 29px; background-image: linear-gradient(45deg, transparent 50%, #5c6357 50%), linear-gradient(135deg, #5c6357 50%, transparent 50%); background-size: 5px 5px; background-position: calc(100% - 16px) center, calc(100% - 11px) center; background-repeat: no-repeat; }
textarea { resize: vertical; }
input[type="file"] { padding: 7px 9px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.helper { line-height: 1.5; color: var(--muted); font-weight: 460; font-size: .83rem; }
.knowledge-panel { display: grid; gap: 10px; min-width: 0; }
.knowledge-panel details { display: grid; padding-top: 6px; }
.knowledge-panel summary { cursor: pointer; font-weight: 620; margin-bottom: 8px; }
.knowledge-documents { display: grid; gap: 6px; list-style: none; margin: 0; padding: 0; }
.knowledge-documents li, .knowledge-results article { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.knowledge-doc-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.knowledge-documents .actions { margin-top: 5px; }
.knowledge-results { display: grid; gap: 6px; margin-top: 8px; }
.knowledge-results p { margin: 4px 0; white-space: pre-wrap; }
.knowledge-warning { color: var(--ink); }
dialog { inset: 0; max-width: min(560px, 95vw); width: 100%; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); padding: 0; color: var(--ink); box-shadow: 0 20px 65px #23291b30; }
dialog::backdrop { background: #252c224d; }
dialog header, dialog footer { padding: 15px 20px; display: flex; align-items: center; gap: 8px; }
dialog header { border-bottom: 1px solid var(--line); justify-content: space-between; }
dialog footer { border-top: 1px solid var(--line); justify-content: flex-end; }
#dialog-content { display: grid; padding: 16px 20px; gap: 14px; }
.group-lookup { display: grid; gap: 9px; padding-top: 14px; border-top: 1px solid var(--line); }
.group-lookup h3 { font-size: .96rem; }
.group-lookup-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.group-lookup-fields label { flex: 1 1 220px; }
.group-lookup-list { list-style: none; margin: 0; padding: 0; max-height: 215px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.group-lookup-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.group-lookup-list li:last-child { border-bottom: 0; }
.group-lookup-list strong, .group-lookup-list small { display: block; overflow-wrap: anywhere; }
.group-lookup-list small { color: var(--muted); }
.close { font-size: 1.25rem; line-height: 1; }
.form-error { padding: 0 20px 12px; color: var(--rust); font-size: .91rem; }
.toast { position: fixed; bottom: 19px; right: 20px; max-width: min(420px, 92vw); z-index: 5; border-radius: 10px; padding: 12px 17px; background: var(--green); color: white; font-weight: 580; box-shadow: 0 4px 24px #25292124; }
.toast.error { background: var(--rust); }

@media (max-width: 1130px) {
  body { grid-template-columns: 175px minmax(0, 1fr); }
  .sidebar { padding-inline: 14px; }
  main { padding-inline: 23px; }
  .room-grid { gap: 14px; }
}
@media (max-width: 865px) {
  .room-grid { grid-template-columns: minmax(0, 1fr); }
  .operations-grid { grid-template-columns: minmax(0, 1fr); }
  .cost-grid, .setup-grid { gap: 12px; }
  .cost-form, .cost-result, .setup-card { padding: 16px; }
}
@media (max-width: 650px) {
  body { display: block; }
  .sidebar { height: auto; position: static; padding: 13px; border-right: none; border-bottom: 1px solid var(--line); display: flex; flex-direction: row; gap: 10px; flex-wrap: wrap; justify-content: space-between; align-items: center; }
  .brand { font-size: 1rem; padding: 0; gap: 7px; }
  .brand small { display: none; }
  .brand-icon { width: 29px; height: 29px; padding: 5px; border-radius: 8px; }
  nav { margin-top: 0; display: flex; flex-wrap: wrap; gap: 3px; }
  nav a { font-size: .8rem; padding: 7px 8px; }
  .nav-icon, .providers { display: none; }
  main { padding: 0 12px 28px; }
  .topbar { height: 62px; }
  .view { margin-top: 24px; }
  .metrics { gap: 6px; }
  .metric { padding: 10px 8px; min-height: 96px; border-radius: 10px; }
  .metric strong { font-size: 1.28rem; }
  .metric-detail { font-size: .75rem; }
  .cost-grid, .setup-grid { grid-template-columns: minmax(0, 1fr); }
  .panel-header, .bot, .session-strip { padding-inline: 13px; }
  .chat { padding: 13px; }
  .operation-content, .operation-messages li { padding-inline: 13px; }
  .operation-metrics > div { padding: 8px; }
}

.login-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-height: 100dvh;
  padding: 24px clamp(16px, 4vw, 32px);
  background: radial-gradient(ellipse at 20% 0%, #e5ebd9, transparent 55%), #f7f5f0;
}
.login-main { width: 100%; max-width: 440px; margin: 0; padding: 0; }
.login-card { display: grid; gap: 22px; padding: clamp(22px, 5vw, 36px); box-shadow: 0 16px 45px #343e2920; }
.login-card h1 { font-size: clamp(1.5rem, 4.2vw, 2rem); line-height: 1.18; letter-spacing: -.035em; }
.login-brand { gap: 12px; padding: 0; }
.login-brand small { display: block; }
.login-brand .brand-icon { flex: 0 0 40px; height: 40px; padding: 11px 8px; border-radius: 12px; }
.login-card form { display: grid; gap: 15px; }
.login-card input, .login-card button { min-height: 44px; }
.login-card button { margin-top: 4px; }
.logout-button { margin-top: 12px; align-self: start; }
.nav-icon[data-icon="inbox"] { height: 12px; }
.nav-icon[data-icon="inbox"]::before { content: ''; position: absolute; top: -1px; left: 3px; width: 7px; height: 7px; border: 1.5px solid currentColor; border-top: 0; border-left: 0; transform: rotate(45deg); }
.inbox-badge { margin-left: auto; min-width: 20px; border-radius: 20px; padding: 2px 5px; text-align: center; color: #fff; background: var(--green); font-size: .75rem; }
.inbox-grid { display: grid; grid-template-columns: minmax(250px, .85fr) minmax(300px, 1.35fr); gap: 20px; align-items: start; }
.inbox-filter { display: flex; flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.inbox-channel { display: flex; flex-flow: row wrap; align-items: center; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.inbox-channel select { width: auto; flex: 1; }
.inbox-message-button { display: grid; gap: 5px; width: 100%; color: var(--ink); padding: 14px 18px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; }
.inbox-message-button:hover, .inbox-message-button[aria-pressed="true"] { background: #eef2e6; }
.inbox-line { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; align-items: start; }
.inbox-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: .89rem; line-height: 1.45; overflow-wrap: anywhere; }
.inbox-pagination { display: flex; justify-content: space-between; gap: 8px; padding: 12px 18px; }
.inbox-original, .inbox-compose { display: grid; gap: 8px; padding: 17px 19px; }
.inbox-target { color: var(--muted); font-size: .89rem; }
.inbox-original .bubble { margin: 2px 0; }
.inbox-replies { display: grid; gap: 12px; padding: 0 19px; }
.inbox-reply { display: grid; justify-items: start; gap: 5px; border-top: 1px solid var(--line); padding: 12px 0 0; }
.inbox-reply .bubble { background: #e9f0e3; }
.inbox-original .bubble, .inbox-reply .bubble { white-space: pre-wrap; overflow-wrap: anywhere; }
.inbox-compose button { justify-self: start; }
#inbox-result { margin: 0 19px 17px; }
.inbox-settings { margin-top: 20px; padding: 14px 19px; }
.inbox-settings summary { cursor: pointer; font-weight: 640; }
.inbox-settings ul { padding: 0; margin: 10px 0 0; list-style: none; }
.inbox-settings li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding: 11px 0; }
@media (max-width: 830px) { .inbox-grid { grid-template-columns: minmax(0, 1fr); } .logout-button { margin-top: 0; } }

.schedule-rule { display: grid; gap: 10px; padding: 12px; min-width: 0; border: 1px solid var(--line); border-radius: 8px; }
.schedule-rule legend { padding-inline: 4px; }
.schedule-rule button { justify-self: start; }
#schedule-rules { display: grid; gap: 8px; }

.inbox-health { padding: 12px 16px; margin: 16px 0; border-color: #b38a4d; }
.inbox-resolve { margin: 0 19px 12px; }
#inbox-storage-form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-block: 14px; }
