:root {
  color-scheme: light;
  --forest: #173b33;
  --forest-soft: #2f5a4f;
  --cream: #f4f0e7;
  --paper: #fffdf8;
  --line: #ded8cc;
  --ink: #17221f;
  --muted: #68736f;
  --accent: #c56f48;
  --success: #23825b;
  --danger: #a63d3d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--cream); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; color: white; background: var(--forest); box-shadow: 0 8px 30px rgb(14 42 35 / 16%); }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand svg { width: 38px; height: 38px; fill: none; stroke: #f0e2c2; stroke-width: 2; stroke-linejoin: round; }
.brand span { display: grid; }
.brand strong { font-family: Georgia, serif; font-size: 18px; letter-spacing: .02em; }
.brand small { color: #bfcec9; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.topbar__status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #d5e1dd; }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: #9cafaa; }
.status-dot[data-state="online"] { background: #60d3a1; box-shadow: 0 0 0 4px rgb(96 211 161 / 13%); }
.status-dot[data-state="error"] { background: #ed8b83; }

.login-shell { min-height: calc(100vh - 72px); display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: min(440px, 100%); padding: 44px; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 60px rgb(32 46 41 / 12%); }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.login-card h1, .sidebar h1 { margin: 8px 0 10px; font: 500 36px/1.05 Georgia, serif; }
.login-card > p { color: var(--muted); line-height: 1.65; }
.login-form { display: grid; gap: 10px; margin-top: 28px; }
label { font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; color: var(--ink); background: #fff; border: 1px solid #cbc5b9; border-radius: 11px; outline: none; transition: border-color .15s, box-shadow .15s; }
input { height: 48px; padding: 0 14px; }
select { height: 48px; padding: 0 12px; }
textarea { padding: 12px 14px; resize: none; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--forest-soft); box-shadow: 0 0 0 4px rgb(47 90 79 / 10%); }
.button { min-height: 44px; padding: 0 18px; border: 0; border-radius: 11px; font-weight: 750; }
.button--primary { color: white; background: var(--forest); }
.button--primary:hover { background: var(--forest-soft); }
.button:disabled { cursor: wait; opacity: .55; }
.form-message { min-height: 20px; margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.form-message[data-type="error"] { color: var(--danger); }
.form-message[data-type="success"] { color: var(--success); }
.privacy-note { display: block; margin-top: 24px; color: #8a918d; }

.workspace { height: calc(100vh - 72px); display: grid; grid-template-columns: 190px minmax(0, 1fr); }
.app-nav { display: flex; flex-direction: column; justify-content: space-between; padding: 20px 12px; color: #dbe5e1; background: #102f28; border-top: 1px solid rgb(255 255 255 / 8%); }
.app-nav nav { display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 12px 13px; color: #c7d6d1; background: transparent; border: 0; border-radius: 10px; text-align: left; font-weight: 650; }
.nav-item span { width: 19px; color: #e9d7b3; font-size: 17px; text-align: center; }
.nav-item:hover { background: rgb(255 255 255 / 7%); }
.nav-item.is-active { color: white; background: rgb(255 255 255 / 12%); }
.app-nav footer { display: grid; gap: 8px; padding: 12px; color: #9eb2ab; font-size: 11px; line-height: 1.4; }
.app-nav .text-button { justify-self: start; color: #e9d7b3; }
.module-view { min-width: 0; min-height: 0; }
.inbox-module { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
.sidebar { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; background: var(--paper); border-right: 1px solid var(--line); }
.sidebar__header { display: flex; align-items: center; justify-content: space-between; padding: 28px 24px 18px; }
.sidebar h1 { margin-bottom: 0; font-size: 30px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--forest); background: white; font-size: 20px; }
.conversation-list { overflow: auto; padding: 0 12px 16px; }
.conversation-item { width: 100%; display: grid; gap: 8px; padding: 16px 14px; text-align: left; border: 0; border-bottom: 1px solid #ece7de; background: transparent; border-radius: 12px; }
.conversation-item:hover { background: #f7f3eb; }
.conversation-item.is-selected { background: #e8eee9; }
.conversation-item__top { display: flex; justify-content: space-between; gap: 8px; }
.conversation-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item time { flex: none; color: var(--muted); font-size: 11px; }
.conversation-item__preview { overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { align-self: center; padding: 32px; text-align: center; color: var(--muted); }
.empty-list span { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 50%; color: var(--success); background: #e1f1e9; }
.empty-list strong { color: var(--ink); }
.empty-list p { margin: 8px 0; font-size: 13px; line-height: 1.5; }
.text-button { padding: 0; border: 0; color: var(--forest-soft); background: transparent; font-weight: 700; }

.chat-panel { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; background: #ece9e1; }
.chat-header { min-height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 14px 28px; background: var(--paper); border-bottom: 1px solid var(--line); }
.chat-header h2 { margin: 0; font: 500 22px Georgia, serif; }
.chat-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.channel-badge { padding: 6px 10px; border-radius: 999px; color: #176943; background: #dff3e8; font-size: 11px; font-weight: 750; }
.messages { overflow: auto; display: flex; flex-direction: column; gap: 10px; padding: 28px clamp(18px, 5vw, 72px); }
.message { max-width: min(72%, 680px); padding: 11px 14px 8px; border-radius: 15px; box-shadow: 0 2px 8px rgb(20 42 34 / 5%); }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.message small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; text-align: right; }
.message--inbound { align-self: flex-start; background: white; border-bottom-left-radius: 4px; }
.message--outbound { align-self: flex-end; background: #dcebe3; border-bottom-right-radius: 4px; }
.reply-form { padding: 16px clamp(18px, 5vw, 72px) 18px; background: var(--paper); border-top: 1px solid var(--line); }
.reply-form > label { display: block; margin-bottom: 7px; }
.reply-box { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.reply-box .button { height: 48px; }
.no-selection { grid-row: 1 / -1; align-self: center; justify-self: center; max-width: 380px; padding: 30px; text-align: center; color: var(--muted); }
.no-selection__mark { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 20px; color: var(--forest); background: #dce5df; font-size: 30px; }
.no-selection h2 { margin: 0; color: var(--ink); font: 500 26px Georgia, serif; }
.no-selection p { line-height: 1.6; }

.settings-page { overflow: auto; padding: 34px clamp(22px, 4vw, 54px) 54px; background: #f1eee7; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; max-width: 1180px; margin: 0 auto 26px; }
.page-heading h1 { margin: 7px 0 8px; font: 500 36px/1.1 Georgia, serif; }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.55; }
.count-badge, .safety-badge { flex: none; margin-top: 4px; padding: 8px 12px; border-radius: 999px; color: var(--forest); background: #dce7e0; font-size: 12px; font-weight: 750; }
.safety-badge { color: #7d4a28; background: #f4dfc8; }
.settings-grid { display: grid; grid-template-columns: minmax(310px, .8fr) minmax(360px, 1.2fr); gap: 22px; max-width: 1180px; margin: 0 auto; align-items: start; }
.panel { padding: 26px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 34px rgb(32 46 41 / 7%); }
.panel h2 { margin: 0; font: 500 22px Georgia, serif; }
.panel-copy, .panel-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.form-panel { display: grid; gap: 11px; }
.form-panel .button { margin-top: 5px; }
.source-fields { display: grid; gap: 9px; }
.source-fields small { color: var(--muted); font-size: 11px; line-height: 1.5; }
input[type="file"] { height: auto; min-height: 48px; padding: 10px; }
.source-list, .number-list { display: grid; gap: 10px; margin-top: 18px; }
.source-card, .number-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px; background: #f7f4ed; border: 1px solid #e5dfd4; border-radius: 12px; }
.source-card__main { min-width: 0; display: grid; gap: 4px; }
.source-card strong, .number-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-card small, .number-card small { color: var(--muted); }
.source-status { display: inline-flex; width: fit-content; padding: 3px 7px; border-radius: 999px; color: #176943; background: #dff3e8; font-size: 10px; font-weight: 750; }
.source-status[data-state="failed"] { color: var(--danger); background: #f6dddd; }
.danger-button { flex: none; padding: 7px 9px; border: 0; border-radius: 8px; color: var(--danger); background: #f6e7e4; font-size: 12px; font-weight: 700; }
.empty-state { margin-top: 18px; padding: 28px 18px; color: var(--muted); background: #f7f4ed; border: 1px dashed #d7d0c4; border-radius: 12px; text-align: center; }
.empty-state p { margin: 7px 0 0; font-size: 12px; line-height: 1.5; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 10px; }
.toggle-row p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.switch { position: relative; flex: none; width: 48px; height: 28px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #c7cbc8; transition: .15s; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgb(0 0 0 / 18%); transition: .15s; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { transform: translateX(20px); }
.inline-form { display: grid; grid-template-columns: 1fr .8fr auto; gap: 8px; margin-top: 8px; }
.inline-form .button { height: 48px; }
code { color: var(--forest); background: #e8eee9; border-radius: 4px; padding: 1px 4px; }

@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 16px; }
  .brand small, .topbar__status span:last-child { display: none; }
  .workspace { height: calc(100vh - 62px); grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .app-nav { flex-direction: row; padding: 7px 10px; overflow-x: auto; }
  .app-nav nav { display: flex; gap: 4px; }
  .nav-item { width: auto; padding: 9px 11px; font-size: 12px; }
  .app-nav footer { display: none; }
  .inbox-module { grid-template-columns: 42% 58%; }
  .sidebar__header { padding: 20px 14px 12px; }
  .sidebar h1 { font-size: 25px; }
  .conversation-item { padding: 14px 10px; }
  .conversation-item time { display: none; }
  .chat-header { padding: 12px 16px; }
  .channel-badge { display: none; }
  .messages { padding: 18px 12px; }
  .message { max-width: 90%; }
  .reply-form { padding: 12px; }
  .reply-box { grid-template-columns: 1fr; }
  .settings-page { padding: 24px 15px 40px; }
  .settings-grid { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; }
  .inline-form { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .workspace { overflow: hidden; }
  .inbox-module { display: block; overflow: auto; }
  .sidebar { min-height: 38vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-panel { min-height: 60vh; }
  .login-card { padding: 30px 24px; }
  .page-heading { display: grid; }
  .panel { padding: 20px; }
}
