/* WAScope — utilitarian SaaS inbox.
   Palette: ink #1e2b26 · ground #f5f7f6 (green-biased neutral) · panel #ffffff
   accent #0f7a54 · accent-soft #e4f2ec · warn #d97706 · danger #dc2626 · info #2f6fdb */

:root {
  --ink: #1e2b26;
  --ink-soft: #5b6b64;
  --ground: #f5f7f6;
  --panel: #ffffff;
  --line: #e2e8e5;
  --accent: #0f7a54;
  --accent-soft: #e4f2ec;
  --warn: #d97706;
  --danger: #dc2626;
  --info: #2f6fdb;
  --note: #fdf3d0;
  --radius: 8px;
  font-size: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--ground);
  overflow: hidden;
}
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
input, select, textarea { font: inherit; color: var(--ink); }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- top bar ---------- */
#topbar {
  height: 50px; flex: 0 0 50px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-dot { color: var(--accent); margin: 0 6px; }
.brand-sub { font-weight: 400; color: var(--ink-soft); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.badge {
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.plan-badge {
  padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); background: var(--ground); color: var(--ink-soft);
}
.plan-badge.free { background: var(--ground); color: var(--ink-soft); }
.plan-badge.starter { background: #e4effc; color: var(--info); border-color: #c8dcf7; }
.plan-badge.pro { background: var(--accent-soft); color: var(--accent); border-color: #c4e6d6; }
.plan-badge.trial { background: #fdf0e0; color: var(--warn); border-color: #f5ddb8; }
.plan-badge:hover { filter: brightness(0.97); }
.me-wrap { display: flex; align-items: center; gap: 8px; }
.me-name { font-size: 13px; font-weight: 600; }
.me-label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.status-pill {
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
  background: var(--panel); font-size: 12px; font-weight: 600;
}
.status-pill.online { color: var(--accent); border-color: var(--accent); }
.status-pill.offline { color: var(--ink-soft); }
.icon-btn { background: none; border: none; font-size: 16px; position: relative; padding: 4px; }
.notif-wrap { position: relative; }
.notif-count {
  position: absolute; top: -2px; right: -4px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; padding: 1px 5px;
}
.notif-panel {
  position: absolute; right: 0; top: 32px; width: 340px; max-height: 380px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(30, 43, 38, 0.12); z-index: 60; padding: 6px;
}
.notif-item { padding: 8px 10px; border-radius: 6px; font-size: 13px; line-height: 1.4; }
.notif-item:hover { background: var(--ground); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item .when { color: var(--ink-soft); font-size: 11px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#rail {
  flex: 0 0 54px; display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding-top: 12px;
  background: var(--panel); border-right: 1px solid var(--line);
}
.rail-btn {
  width: 40px; height: 40px; border: none; background: none; border-radius: 10px;
  font-size: 18px; display: grid; place-items: center;
}
.rail-btn:hover { background: var(--ground); }
.rail-btn.active { background: var(--accent-soft); }
.rail-gear { margin-top: auto; margin-bottom: 12px; }
#view { flex: 1; display: flex; min-width: 0; }

/* ---------- inbox: chat list ---------- */
#chatlist {
  flex: 0 0 320px; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.chatlist-head { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.search-input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--ground);
}
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); font-size: 12px; color: var(--ink-soft);
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.phone-filter { font-size: 12px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; max-width: 110px; }
.bulk-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.bulk-count { font-size: 12px; font-weight: 700; color: var(--accent); margin-right: 2px; }
.chat-check { align-self: center; accent-color: var(--accent); width: 15px; height: 15px; flex: 0 0 15px; }
.chat-items { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex; gap: 10px; padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--ground);
}
.chat-item:hover { background: var(--ground); }
.chat-item.active { background: var(--accent-soft); }
.avatar {
  flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 14px;
}
.avatar-xs {
  display: inline-grid; width: 22px; height: 22px; flex: 0 0 22px; font-size: 9px;
  vertical-align: middle; margin-right: 4px;
}
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-top { display: flex; align-items: baseline; gap: 6px; }
.chat-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { margin-left: auto; font-size: 11px; color: var(--ink-soft); flex: 0 0 auto; }
.chat-preview {
  font-size: 12.5px; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.chat-item-meta { display: flex; align-items: center; gap: 5px; margin-top: 4px; flex-wrap: wrap; }
.mini-label { font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 999px; color: #fff; }
.phone-tag { font-size: 10px; color: var(--ink-soft); border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px; }
.unread-dot {
  margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px;
}
.sla-tag { font-size: 10px; font-weight: 700; color: var(--danger); }

/* ---------- inbox: conversation ---------- */
#conv { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--ground); }
.conv-head {
  height: 54px; flex: 0 0 54px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.conv-title { font-weight: 700; }
.conv-sub { font-size: 12px; color: var(--ink-soft); }
.conv-head-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 62%; align-self: flex-start; }
.msg.out { align-self: flex-end; }
.bubble {
  position: relative; padding: 8px 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
  line-height: 1.45; word-wrap: break-word; white-space: pre-wrap;
}
.msg.out .bubble { background: #dcf3e8; border-color: #c4e6d6; }
.msg .bubble.auto { background: #eef2ff; border-color: #dfe6fb; }
.msg .bubble.note { background: var(--note); border-color: #f0dfa0; }
.msg-author { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg-meta { display: flex; gap: 6px; font-size: 10.5px; color: var(--ink-soft); margin-top: 3px; padding: 0 4px; }
.msg.out .msg-meta { justify-content: flex-end; }
.msg-flag { color: var(--danger); font-weight: 700; }
.day-divider { align-self: center; font-size: 11px; color: var(--ink-soft); background: var(--panel); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; margin: 6px 0; }

.composer { flex: 0 0 auto; padding: 10px 16px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-input-wrap { position: relative; flex: 1; display: flex; }
.composer textarea {
  flex: 1; width: 100%; resize: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; min-height: 40px; max-height: 120px; background: var(--ground);
}
.composer textarea.note-mode { background: var(--note); }
.composer-side { display: flex; flex-direction: column; gap: 6px; }
.send-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 9px 18px; font-weight: 700; white-space: nowrap;
}
.send-btn:hover { filter: brightness(1.08); }
.composer-tools { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--ink-soft); flex-wrap: wrap; }
.note-toggle { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.note-toggle.on { background: var(--note); border-color: #e5c95d; font-weight: 700; }
.from-select { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.ai-btn {
  border: 1px solid var(--accent); color: var(--accent); background: var(--panel);
  border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 600;
}
.ai-btn:hover { background: var(--accent-soft); }

/* composer autocomplete (quick replies / mentions) */
.ac-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; width: min(420px, 100%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(30, 43, 38, 0.15); z-index: 70; padding: 4px;
  max-height: 240px; overflow-y: auto;
}
.ac-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; text-align: left; background: none; border: none;
  padding: 7px 10px; border-radius: 6px; font-size: 13px;
}
.ac-item:hover, .ac-item.sel { background: var(--accent-soft); }
.ac-item b { color: var(--accent); }
.ac-sub { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---------- inbox: details panel ---------- */
#details {
  flex: 0 0 300px; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--line); padding: 16px;
}
.details-section { margin-bottom: 18px; }
.details-section h4 {
  margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-soft);
}
.detail-kv { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.detail-kv .k { color: var(--ink-soft); }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.label-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.label-chip {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  color: #fff; border: none; opacity: 0.45;
}
.label-chip.on { opacity: 1; }
.assignee-select, .details select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.ticket-mini {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; font-size: 12.5px;
}
.ticket-mini .t-title { font-weight: 600; }
.ai-output {
  background: var(--ground); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px; font-size: 12.5px; white-space: pre-wrap; line-height: 1.5; margin-top: 8px;
  max-height: 260px; overflow-y: auto;
}
.spin { display: inline-block; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- generic page views ---------- */
.page { flex: 1; overflow-y: auto; padding: 22px 26px; }
.page h2 { margin: 0 0 4px; font-size: 20px; }
.page .page-sub { color: var(--ink-soft); margin-bottom: 18px; }

/* tickets kanban */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 14px; align-items: start; }
.kanban-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.kanban-col h3 { margin: 2px 6px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); display: flex; justify-content: space-between; }
.tcard { border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 8px; background: var(--ground); cursor: pointer; }
.tcard:hover { border-color: var(--accent); }
.tcard .t-num { font-size: 11px; color: var(--ink-soft); }
.tcard .t-title { font-weight: 600; margin: 2px 0 6px; }
.tcard-meta { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--ink-soft); flex-wrap: wrap; }
.prio { font-weight: 700; font-size: 10.5px; padding: 1px 7px; border-radius: 4px; }
.prio.low { background: #eef2f1; color: var(--ink-soft); }
.prio.medium { background: #e4effc; color: var(--info); }
.prio.high { background: #fdf0e0; color: var(--warn); }
.prio.urgent { background: #fdeaea; color: var(--danger); }
.due-over { color: var(--danger); font-weight: 700; }

/* rules */
.rule-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; display: flex; gap: 14px; align-items: flex-start;
}
.rule-card .r-body { flex: 1; }
.rule-card .r-name { font-weight: 700; margin-bottom: 4px; }
.rule-kind {
  font-size: 10.5px; font-weight: 600; color: var(--info); background: #e4effc;
  border-radius: 4px; padding: 1px 7px; margin-left: 6px; text-transform: none;
}
.rule-flow { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; }
.rule-flow b { color: var(--ink); }
.rule-runs { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 6px; }
.switch { position: relative; width: 40px; height: 22px; flex: 0 0 40px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #cfd8d3; border-radius: 999px; transition: 0.2s;
}
.slider:before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }

/* dashboard */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.stat .s-val { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .s-label { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.stat.alert .s-val { color: var(--danger); }
.dash-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: start; }
table.agents { width: 100%; border-collapse: collapse; font-size: 13px; }
table.agents th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.agents td { padding: 8px; border-bottom: 1px solid var(--ground); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.online { background: var(--accent); }
.dot.offline { background: #cfd8d3; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.bar { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; position: relative; min-height: 2px; }
.bar.hot { background: var(--accent); }
.bar-x { font-size: 9px; color: var(--ink-soft); text-align: center; margin-top: 3px; }

/* ticket aging (dashboard) */
.aging { display: flex; flex-direction: column; gap: 8px; }
.aging-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.aging-k { flex: 0 0 46px; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.aging-track { flex: 1; height: 10px; background: var(--ground); border-radius: 999px; overflow: hidden; }
.aging-fill { height: 100%; background: var(--accent); border-radius: 999px; min-width: 2px; }
.aging-fill.hot { background: var(--danger); }
.aging-v { flex: 0 0 26px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- settings ---------- */
.settings { flex: 1; display: flex; min-width: 0; }
.settings-nav {
  flex: 0 0 200px; background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
}
.settings-nav h3 { margin: 0 6px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-soft); }
.settings-tab {
  text-align: left; border: none; background: none; border-radius: 8px;
  padding: 8px 10px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
}
.settings-tab:hover { background: var(--ground); }
.settings-tab.active { background: var(--accent-soft); color: var(--accent); }
.settings-plan { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 6px 2px; display: flex; flex-direction: column; gap: 8px; }
.settings-plan-name { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.settings-body { flex: 1; overflow-y: auto; padding: 22px 26px; min-width: 0; }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.settings-head h2 { margin: 0; font-size: 20px; }

/* phones */
.phone-list { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.phone-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.phone-ico { font-size: 22px; }
.phone-info { flex: 1; min-width: 0; }
.phone-name { font-weight: 700; }
.phone-num { font-size: 12.5px; color: var(--ink-soft); }
.pstatus { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pstatus.ok { background: var(--accent-soft); color: var(--accent); }
.pstatus.warn { background: #fdf0e0; color: var(--warn); }
.pstatus.off { background: var(--ground); color: var(--ink-soft); }
.pstatus.err { background: #fdeaea; color: var(--danger); }

/* QR panel */
.qr-box {
  display: grid; place-items: center; min-height: 260px; margin: 6px 0 10px;
  background: var(--ground); border: 1px dashed var(--line); border-radius: 10px;
}
.qr-box img { width: 240px; height: 240px; image-rendering: pixelated; border-radius: 6px; background: #fff; padding: 8px; }
.qr-wait { color: var(--ink-soft); font-size: 13px; }
.qr-done { font-size: 20px; font-weight: 800; color: var(--accent); }
.qr-status { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }

/* team */
.team-table { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.team-table td, .team-table th { padding: 9px 10px; }
.role-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--ground); color: var(--ink-soft); }
.role-tag.owner { background: var(--accent-soft); color: var(--accent); }
.role-tag.admin { background: #e4effc; color: var(--info); }
.role-tag.readonly { background: #fdf0e0; color: var(--warn); }
.label-checks { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.check-line { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 400 !important; color: var(--ink) !important; text-transform: none !important; }
.color-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: 0 0 11px; }
.color-dot.big { width: 16px; height: 16px; flex: 0 0 16px; }

/* labels + quick replies editors */
.inline-form {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px; max-width: 720px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
}
.inline-form input[type="text"] { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; }
.inline-form input[type="color"] { width: 34px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.label-list, .qr-list { display: flex; flex-direction: column; gap: 8px; max-width: 720px; }
.label-row, .qr-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px;
}
.label-row input[type="text"], .qr-row input[type="text"] { padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; }
.label-row input[type="color"] { width: 30px; height: 28px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.label-name-input { flex: 1; }
.slash-prefix { font-weight: 800; color: var(--accent); }

/* ---------- upgrade modal / plan picker ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.plan-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 6px; background: var(--ground);
}
.plan-card.featured { border-color: var(--accent); background: var(--accent-soft); }
.plan-card.current { outline: 2px solid var(--accent); outline-offset: -2px; }
.plan-name { font-weight: 800; font-size: 15px; }
.plan-phones { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.plan-feats { list-style: none; margin: 4px 0 8px; padding: 0; font-size: 11.5px; color: var(--ink-soft); line-height: 1.7; flex: 1; }
.plan-card .btn { width: 100%; }

/* context menu + modal */
.ctx-menu {
  position: fixed; z-index: 80; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(30, 43, 38, 0.15); padding: 4px; min-width: 180px;
}
.ctx-menu button { display: flex; align-items: center; gap: 7px; width: 100%; text-align: left; background: none; border: none; padding: 8px 12px; border-radius: 5px; font-size: 13px; }
.ctx-menu button:hover { background: var(--ground); }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 30, 26, 0.4); z-index: 90;
  display: grid; place-items: center;
}
.modal {
  background: var(--panel); border-radius: 12px; padding: 20px 22px; width: 480px; max-width: 94vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(20, 30, 26, 0.3);
}
.modal h3 { margin: 0 0 14px; }
.modal .form-row, .form-row { margin-bottom: 12px; }
.modal label, .form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.modal input[type="text"], .modal input[type="email"], .modal input[type="password"], .modal select, .modal input[type="datetime-local"] {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.btn { padding: 8px 16px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--danger); border-color: #f3c8c8; }
.btn.danger:hover { background: #fdeaea; }
.btn:hover { filter: brightness(0.98); }

/* ---------- auth (login/signup) page ---------- */
.auth-body { overflow: auto; background: linear-gradient(160deg, var(--accent-soft) 0%, var(--ground) 45%); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; }
.auth-card {
  width: 400px; max-width: 94vw; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 26px 26px 22px;
  box-shadow: 0 16px 40px rgba(15, 122, 84, 0.10);
}
.auth-brand { font-weight: 800; font-size: 20px; margin-bottom: 18px; }
.auth-tabs { display: flex; gap: 6px; background: var(--ground); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.auth-tab { flex: 1; border: none; background: none; border-radius: 999px; padding: 7px 10px; font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-form input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--ground); }
.auth-form input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.auth-submit { width: 100%; padding: 10px; margin-top: 4px; }
.auth-hint { font-size: 12px; color: var(--ink-soft); text-align: center; margin-top: 10px; }
.auth-error {
  margin-top: 14px; background: #fdeaea; color: var(--danger); border: 1px solid #f3c8c8;
  border-radius: 7px; padding: 9px 12px; font-size: 13px;
}
.auth-foot { font-size: 12.5px; color: var(--ink-soft); }

/* responsive: keep the conversation usable on narrow viewports / high zoom */
#conv { min-width: 340px; }
@media (max-width: 1220px) {
  #details { display: none; }
  #chatlist { flex: 0 0 280px; }
  .plan-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #chatlist { flex: 0 0 230px; }
  .msg { max-width: 85%; }
  .dash-grid { grid-template-columns: 1fr; }
  .settings-nav { flex: 0 0 150px; }
}

.empty { display: grid; place-items: center; height: 100%; color: var(--ink-soft); text-align: center; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 13px; z-index: 100; box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
