:root {
  --bg: #f6f7f9; --panel: #fff; --line: #e3e6ea; --ink: #14181d;
  --muted: #667085; --accent: #0b7a4b; --danger: #b42318; --mine: #d9fdd3;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
       background: var(--bg); color: var(--ink); }
.login { max-width: 340px; margin: 12vh auto; background: var(--panel);
         padding: 28px; border: 1px solid var(--line); border-radius: 12px; }
.login h1 { font-size: 20px; margin: 0 0 18px; }
input, textarea, button { font: inherit; }
input[type=text], input[type=password] { width: 100%; padding: 10px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 8px; }
button { padding: 10px 16px; border: 0; border-radius: 8px; background: var(--accent);
         color: #fff; cursor: pointer; }
button:disabled { background: #b9c0c8; cursor: not-allowed; }
.error { color: var(--danger); min-height: 1.4em; }

.layout { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }
.sidebar { border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; }
.sidebar header { padding: 14px; border-bottom: 1px solid var(--line);
                  display: flex; gap: 8px; align-items: center; }
.contact { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.contact.active { background: #eef4ff; }
.contact .nm { font-weight: 600; }
.contact .last { color: var(--muted); font-size: 13px; white-space: nowrap;
                 overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 12px; margin-top: 4px; }
.badge.open { color: var(--accent); }
.badge.shut { color: var(--danger); }

.thread { display: flex; flex-direction: column; height: 100vh; }
.thread header { padding: 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 62%; padding: 8px 12px; border-radius: 10px; background: var(--panel);
       border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg.out { align-self: flex-end; background: var(--mine); border-color: #bfe8b6; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg .err { font-size: 12px; color: var(--danger); margin-top: 4px; }
.composer { border-top: 1px solid var(--line); padding: 12px; background: var(--panel);
            display: flex; gap: 8px; }
.composer textarea { flex: 1; resize: none; height: 44px; padding: 10px;
                     border: 1px solid var(--line); border-radius: 8px; }
.closed-note { padding: 12px; background: #fff4ed; border-top: 1px solid var(--line);
               display: flex; gap: 10px; align-items: center; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-width: 340px; max-width: 460px; }
dialog p { color: var(--muted); font-size: 14px; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.ghost:hover { background: #f0f2f5; }
button.danger { color: var(--danger); border-color: #f3c9c4; }
button.danger-solid { background: var(--danger); }
.thread header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.thread header #threadActions { display: flex; gap: 8px; }
.contact:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
