@font-face{font-family:'Inter';font-style:normal;font-weight:400;font-display:swap;src:url('../fonts/inter-v20-latin_latin-ext-regular.woff2') format('woff2')}
@font-face{font-family:'Inter';font-style:normal;font-weight:500;font-display:swap;src:url('../fonts/inter-v20-latin_latin-ext-500.woff2') format('woff2')}
@font-face{font-family:'Inter';font-style:normal;font-weight:600;font-display:swap;src:url('../fonts/inter-v20-latin_latin-ext-600.woff2') format('woff2')}
@font-face{font-family:'Inter';font-style:normal;font-weight:700;font-display:swap;src:url('../fonts/inter-v20-latin_latin-ext-700.woff2') format('woff2')}
@font-face{font-family:'Newsreader';font-style:normal;font-weight:400;font-display:swap;src:url('../fonts/newsreader-v26-latin_latin-ext-regular.woff2') format('woff2')}
@font-face{font-family:'Newsreader';font-style:normal;font-weight:500;font-display:swap;src:url('../fonts/newsreader-v26-latin_latin-ext-500.woff2') format('woff2')}
@font-face{font-family:'Newsreader';font-style:italic;font-weight:400;font-display:swap;src:url('../fonts/newsreader-v26-latin_latin-ext-italic.woff2') format('woff2')}
:root {
  --paper: #F6F4EF; --surface: #FFFFFF; --ink: #211F1B; --line: #E7E3DA;
  --faint: #FBFAF7; --muted: #9A958C; --mid: #6E6A63; --warm: #A8A299;
  --seal: #B23A2E; --seal-dark: #8F2C22; --jade: #3E7C68; --lacquer: #23211C;
  --amber: #9A6A12; --amber-tint: #FBF1DC;
  --r: 8px; --r-lg: 12px;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
a { color: var(--seal); text-decoration: none; }
a:hover { color: var(--seal-dark); }
#root { min-height: 100vh; }

/* ─── TABLE ─── */
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11.5px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding: 0 14px 11px; }
tbody tr { border-top: 1px solid var(--line); }
tbody tr:hover { background: var(--faint); }
tbody td { padding: 13px 14px; font-size: 13.5px; vertical-align: middle; }

/* ─── PILLS ─── */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.pill-open { background: #F6E7E3; color: var(--seal-dark); }
.pill-progress { background: #CCE5FF; color: #004085; }
.pill-wait { background: var(--faint); color: var(--mid); border: 1px solid var(--line); }
.pill-resolved { background: #D4EDDA; color: #155724; }
.pill-active { background: #D4EDDA; color: #155724; }
.pill-neutral { background: var(--faint); color: var(--mid); border: 1px solid var(--line); }
.pill-jade { background: #e6f4ea; color: var(--jade); }
.pill-amber { background: var(--amber-tint); color: var(--amber); }
.pill-seal { background: #fce8e6; color: var(--seal); }

/* ─── CHIPS ─── */
.chip { font-size: 11.5px; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.chip-bug { background: #F3E8E8; color: var(--seal-dark); }
.chip-feature { background: #E1EEDD; color: var(--jade); }
.chip-account { background: #ECE7DD; color: var(--mid); }
.chip-ent { background: #E1EEDD; color: var(--jade); font-weight: 500; }
.chip-perm { font-size: 9.5px; padding: 1px 5px; border-radius: 3px; background: #ECE7DD; color: var(--mid); }

/* ─── DOTS ─── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-urgent { background: #c0392b; }
.dot-high { background: var(--seal); }
.dot-normal { background: #D4A843; }
.dot-low { background: var(--muted); }

.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; }

/* ─── AVATARS ─── */
.av { width: 32px; height: 32px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.av-sm { width: 22px; height: 22px; font-size: 9px; }
.av-seal { background: var(--seal); }
.av-jade { background: var(--jade); }
.av-muted { background: var(--muted); }

/* ─── BUTTONS ─── */
.btn { padding: 9px 18px; border-radius: var(--r); border: none; font-weight: 600; font-size: 13px; font-family: var(--sans); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--seal); color: #fff; }
.btn-primary:hover { background: var(--seal-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-outline { background: var(--surface); border: 1px solid #D9D4C9; color: var(--ink); }
.btn-outline:hover { background: var(--faint); }

/* ─── INPUTS ─── */
.input { width: 100%; padding: 9px 12px; border: 1px solid #D9D4C9; border-radius: var(--r); outline: none; font-family: var(--sans); font-size: 13px; color: var(--ink); background: var(--surface); }
.input:focus { border-color: var(--seal); box-shadow: 0 0 0 2px rgba(178,58,46,0.12); }
select.input { cursor: pointer; }
textarea.input { line-height: 1.6; }

/* ─── CARDS ─── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-pad { padding: 22px 24px; }

/* ─── LABELS ─── */
.label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.section-label { font-size: 10.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--warm); padding: 14px 10px 7px; }

/* ─── RAIL ─── */
.rail { width: 250px; flex-shrink: 0; background: var(--lacquer); color: #EDE9E0; display: flex; flex-direction: column; padding: 20px 14px; }
.rail-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 22px; }
.rail-brand .qi { width: 34px; height: 34px; border-radius: 7px; background: var(--seal); color: #fff; display: grid; place-items: center; font-size: 19px; font-family: var(--serif); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.rail-brand .name { font-size: 15px; font-weight: 500; letter-spacing: 0.02em; line-height: 1.15; }
.rail-brand small { font-size: 11px; font-weight: 400; color: var(--warm); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; display: block; }
.rail-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r); color: #EDE9E0; font-size: 13.5px; opacity: 0.82; cursor: pointer; transition: opacity .15s, background .15s; }
.rail-item:hover { opacity: 1; background: rgba(255,255,255,.04); }
.rail-item.active { font-weight: 500; background: rgba(255,255,255,.07); opacity: 1; position: relative; }
.rail-item.active::before { content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; background: var(--seal); border-radius: 0 3px 3px 0; }
.rail-item .badge { margin-left: auto; background: var(--seal); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.rail-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.rail-foot { margin-top: auto; padding: 14px 8px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.rail-user { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--warm); }
.rail-user .nm { color: #EDE9E0; font-size: 12.5px; font-weight: 500; }
.rail-user .role { font-size: 11px; color: var(--warm); }

/* ─── MINI RAIL ─── */
.rail-mini { width: 58px; flex-shrink: 0; background: var(--lacquer); color: #EDE9E0; display: flex; flex-direction: column; align-items: center; padding: 16px 0; }
.rail-mini .qi { width: 34px; height: 34px; border-radius: 7px; background: var(--seal); color: #fff; display: grid; place-items: center; font-size: 19px; font-family: var(--serif); margin-bottom: 24px; }
.rail-mini-item { width: 36px; height: 36px; border-radius: var(--r); display: grid; place-items: center; opacity: 0.6; margin-bottom: 4px; cursor: pointer; transition: opacity .15s; }
.rail-mini-item:hover { opacity: 1; }
.rail-mini-item.active { background: rgba(255,255,255,.07); opacity: 1; position: relative; }
.rail-mini-item.active::before { content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; background: var(--seal); border-radius: 0 3px 3px 0; }
.rail-mini-item svg { width: 18px; height: 18px; }

/* ─── TOPBAR ─── */
.topbar { height: 60px; flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; }

/* ─── APP LAYOUT ─── */
.app-layout { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--paper); }
.app-content { padding: 28px; max-width: 1080px; width: 100%; }

/* ─── KPI CARDS ─── */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { padding: 20px 22px; }
.kpi .kpi-label { font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.kpi .kpi-val { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; }
.kpi .kpi-sub { font-size: 12px; margin-top: 4px; }

/* ─── CONVERSATION ─── */
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.msg-time { font-size: 11.5px; color: var(--muted); }
.msg-tag { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; font-weight: 500; }
.msg-tag-customer { background: #E1EEDD; color: var(--jade); }
.msg-tag-agent { background: #ECE7DD; color: var(--mid); }
.msg-tag-internal { background: #F6E7E3; color: var(--seal); }
.msg-bubble { border-radius: 0 12px 12px 12px; padding: 14px 18px; font-size: 13.5px; line-height: 1.6; }
.msg-bubble-customer { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.msg-bubble-agent { background: var(--faint); border: 1px solid var(--line); color: var(--ink); }
.msg-bubble-internal { background: #FDF6F4; border: 1px dashed #D9A9A3; color: var(--mid); font-style: italic; }

/* ─── ENTITLEMENTS ─── */
.ent-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r); }
.ent-on { background: #E1EEDD; border: 1px solid #C3DEB9; }
.ent-off { background: var(--faint); border: 1px dashed #D9D4C9; }
.ent-on span { font-size: 13px; font-weight: 500; color: var(--jade); }
.ent-off span { font-size: 13px; color: var(--muted); }

/* ─── SIDEBAR ─── */
.sidebar { width: 280px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--line); padding: 24px 20px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }

/* ─── TIMELINE ─── */
.timeline { display: flex; flex-direction: column; gap: 10px; font-size: 12px; color: var(--mid); position: relative; padding-left: 16px; }
.timeline::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.timeline-item { position: relative; }
.timeline-dot { position: absolute; left: -16px; top: 4px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid #fff; }
.timeline-dot-first { background: var(--seal); }
.timeline-dot-rest { background: #D9D4C9; }

/* ─── ALERTS ─── */
.alert-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); font-size: 13px; }
.alert-warn { background: #FFF3CD; }
.alert-err { background: #F6E7E3; }

/* ─── PRIORITY TOGGLE ─── */
.prio-toggle { display: flex; gap: 6px; }
.prio-toggle span { padding: 5px 10px; border-radius: 6px; font-size: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--mid); cursor: pointer; transition: all .15s; }
.prio-toggle span:hover { border-color: var(--seal); }
.prio-toggle .prio-active { border: 2px solid #c0392b; background: #FFF5F5; color: #c0392b; font-weight: 600; }

/* ─── SEPARATOR ─── */
hr.sep { border: none; border-top: 1px solid var(--line); margin: 0; }

/* ─── TOAST ─── */
#toast-box { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { padding: 12px 20px; border-radius: var(--r); font-size: 13px; font-weight: 500; color: #fff; opacity: 1; transition: opacity .3s; box-shadow: 0 4px 20px rgba(0,0,0,.15); }
.toast-info { background: var(--jade); }
.toast-error { background: var(--seal); }

/* ─── MODAL ─── */
#modal-overlay { display: none; position: fixed; inset: 0; background: rgba(35,33,28,.4); z-index: 1000; justify-content: center; align-items: center; }
.modal-card { background: var(--surface); border-radius: var(--r-lg); padding: 28px; width: 520px; max-width: 90vw; max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(35,33,28,.2); }

/* ─── VERSION FOOTER ─── */
.version-footer { text-align: center; padding: 24px 0 12px; font-size: 11px; color: var(--muted); }

/* ─── SYSTEM-MONITOR ─── */
.monitor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.monitor-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.monitor-head-right { display: flex; align-items: center; gap: 14px; }
.monitor-updated { font-size: 12.5px; color: var(--muted); }
.monitor-layout { display: flex; gap: 20px; align-items: flex-start; }
.monitor-main { flex: 1; min-width: 0; }
.monitor-side { width: 260px; flex-shrink: 0; }
.monitor-grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.monitor-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 16px; }
.monitor-card { margin-bottom: 16px; }
.monitor-grid-2 .monitor-card { margin-bottom: 0; }
.monitor-card-title { font-size: 15px; font-weight: 500; margin-bottom: 14px; }
.monitor-muted { color: var(--muted); font-size: 13px; }
.monitor-hint { margin-top: 10px; font-size: 12px; color: var(--muted); }
.monitor-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 4px; }
.monitor-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.monitor-stats > div { display: flex; flex-direction: column; gap: 2px; }
.monitor-stats span { font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.monitor-stats strong { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; min-height: 33px; display: flex; align-items: center; }
.monitor-scroll { overflow-x: auto; margin-top: 8px; }
.monitor-query { word-break: break-all; min-width: 220px; }
.monitor-msg { color: var(--mid); font-size: 12.5px; max-width: 240px; word-break: break-word; }

.gauge { padding: 16px 14px 14px; text-align: center; }
.gauge-label { font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.gauge-dial { position: relative; width: 112px; height: 112px; margin: 12px auto 4px; }
.gauge-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 210deg,
    var(--gauge-color, var(--muted)) 0deg,
    var(--gauge-color, var(--muted)) calc(var(--gauge-pct, 0) * 2.4deg),
    var(--line) calc(var(--gauge-pct, 0) * 2.4deg),
    var(--line) 240deg,
    transparent 240deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 11px), #000 calc(100% - 10px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 11px), #000 calc(100% - 10px));
}
.gauge-val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 19px; font-weight: 600; letter-spacing: -0.02em; padding-bottom: 4px; }
.gauge-sub { font-size: 12px; color: var(--mid); min-height: 18px; }

.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.status-dot-ok { background: var(--jade); }
.status-dot-warn { background: var(--amber); }
.status-dot-err { background: var(--seal); }

.monitor-alerts { display: flex; flex-direction: column; gap: 10px; }
.monitor-alert { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); font-size: 13px; }
.monitor-alert-ok { background: #e6f4ea; color: var(--jade); }
.monitor-alert-warn { background: var(--amber-tint); color: var(--amber); }
.monitor-alert-err { background: #F6E7E3; color: var(--seal-dark); }

.mailbox-list { display: flex; flex-direction: column; gap: 10px; }
.mailbox-tile { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--faint); cursor: pointer; transition: border-color .15s, background .15s; }
.mailbox-tile:hover { border-color: var(--seal); background: var(--surface); }
.mailbox-info { min-width: 0; }
.mailbox-addr { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-note { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.mailbox-badge { flex-shrink: 0; min-width: 24px; text-align: center; background: var(--seal); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.mailbox-badge-zero { background: none; color: var(--muted); }
.mailbox-badge-off { background: none; color: var(--muted); }
.mailbox-foot { margin-top: 12px; font-size: 11.5px; color: var(--muted); }

@media (max-width: 1280px) {
  .monitor-layout { flex-direction: column; align-items: stretch; }
  .monitor-side { width: 100%; }
  .mailbox-list { flex-direction: row; flex-wrap: wrap; }
  .mailbox-tile { flex: 1 1 220px; }
}
