/* ══ Sistem desain ═══════════════════════════════════════════ */

:root {
  --chrome: #0d0e12;          /* rail + latar aplikasi */
  --chrome-fg: #e8eaf0;
  --chrome-muted: #7d8494;

  --surface: #ffffff;         /* kartu utama */
  --surface-2: #f6f7f9;
  --surface-3: #f1f2f4;

  --fg: #16181d;
  --fg-muted: #656b7a;
  --fg-subtle: #98a0b0;

  --line: #e8eaee;
  --line-strong: #d6dae1;

  --accent: #1c6ef2;          /* biru bubble keluar */
  --accent-fg: #ffffff;
  --accent-soft: #e8f0fe;

  --ok: #067a4e;   --ok-soft: #d8f3e6;
  --warn: #92610b; --warn-soft: #fdf0d0;
  --danger: #c62828; --danger-soft: #fdecec;
  --bot: #6032c8;  --bot-soft: #efe9fd;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 44px rgba(9, 12, 20, .2);
}

@media (prefers-color-scheme: dark) {
  :root {
    --chrome: #08090c;
    --surface: #14161c;
    --surface-2: #191c23;
    --surface-3: #1f232b;
    --fg: #eef0f5;
    --fg-muted: #99a1b2;
    --fg-subtle: #6c7383;
    --line: #242832;
    --line-strong: #333947;
    --accent: #4b8ef7;
    --accent-fg: #08090c;
    --accent-soft: #17263f;
    --ok-soft: #0c3327;  --warn-soft: #3a2a08;
    --danger-soft: #3a1414; --bot-soft: #241a45;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--fg);
  background: var(--chrome);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }

/* ══ Login ═══════════════════════════════════════════════════ */

#login, #setup { height: 100vh; display: grid; place-items: center; padding: 24px; }
/* display:grid di atas mengalahkan atribut hidden, jadi dinyatakan sendiri. */
#login[hidden], #setup[hidden] { display: none; }
#login form, #setup form {
  background: var(--surface); border: 1px solid var(--line); padding: 34px;
  border-radius: var(--radius-lg); width: 100%; max-width: 360px; box-shadow: var(--shadow-lg);
}
#login h1, #setup h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.02em; }
.login-logo { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 0 23px; border-radius: 21px; background: #f4f8ff; border: 1px solid #dae7ff; }
.login-logo img { display: block; object-fit: contain; }
#login .lede, #setup .lede { margin: 0 0 22px; color: var(--fg-muted); font-size: 13px; line-height: 1.6; }
#loginError, #setupError { color: var(--danger); font-size: 13px; margin-top: 14px; min-height: 18px; }

/* Wizard lebih tinggi dari form login — beri ruang gulir di layar pendek. */
#setup { align-items: start; padding-block: 40px; overflow-y: auto; }
#setup form { max-width: 380px; }
#setup .field-hint { font-size: 11px; line-height: 1.6; color: var(--fg-muted); margin: 6px 0 0; }
#setup .field-hint code { font-size: 11px; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
#setupTokenField[hidden] { display: none; }

label { display: block; font-size: 12px; font-weight: 600; margin: 14px 0 5px; color: var(--fg-muted); }

input[type=text], input[type=email], input[type=password], input[type=time], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  border: 1px solid transparent; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-fg);
  padding: 9px 16px; cursor: pointer; font-weight: 550;
  transition: filter .12s, background .12s;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.wide { width: 100%; margin-top: 20px; padding: 11px; }
.btn.ghost { background: transparent; color: var(--fg-muted); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--line-strong); }

/* ══ Kerangka aplikasi ═══════════════════════════════════════ */

#app { display: none; height: 100vh; }
#app.ready { display: flex; }

.rail {
  width: 60px; flex: none; background: var(--chrome); color: var(--chrome-fg);
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0;
}
.rail-logo {
  width: 36px; height: 36px; border-radius: 10px; background: #f4f8ff;
  display: grid; place-items: center; margin-bottom: 10px; border: 1px solid #dae7ff;
}
.rail-logo img { display: block; object-fit: contain; }
.rail-btn {
  width: 40px; height: 40px; border: 0; border-radius: 11px; background: transparent;
  color: var(--chrome-muted); cursor: pointer; display: grid; place-items: center;
  font-size: 17px; text-decoration: none; transition: background .12s, color .12s;
}
.rail-btn:hover { background: rgba(255, 255, 255, .07); color: var(--chrome-fg); }
.rail-btn.on { background: rgba(255, 255, 255, .12); color: #fff; }
.rail-spacer { flex: 1; }
.rail-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Bar atas ── */

.topbar {
  height: 52px; flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 16px 0 4px; color: var(--chrome-fg);
}
.search-box {
  flex: 1; max-width: 460px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .08); border-radius: 9px; padding: 0 10px; height: 34px;
}
.search-box .search-ico { font-size: 12px; opacity: .7; }
.search-box input {
  flex: 1; border: 0; background: transparent; color: var(--chrome-fg);
  padding: 0; height: 100%; font-size: 13px; box-shadow: none !important;
}
.search-box input::placeholder { color: var(--chrome-muted); }
.search-box kbd {
  font: 600 10.5px/1 -apple-system, sans-serif; color: var(--chrome-muted);
  background: rgba(255, 255, 255, .1); border-radius: 4px; padding: 4px 5px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.me-name { font-size: 13px; font-weight: 550; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.status-select {
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 99px; padding: 4px 9px;
  font-size: 12px; background: rgba(255, 255, 255, .06); color: var(--chrome-fg);
  cursor: pointer; width: auto;
}
.status-select:focus { box-shadow: none; border-color: rgba(255, 255, 255, .3); }
.topbar .btn.ghost { border-color: rgba(255, 255, 255, .16); color: var(--chrome-muted); }
.topbar .btn.ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* ── Kartu utama ── */

.card {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  background: var(--surface);
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  margin-right: 8px;
}

.col {
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
  background: var(--surface);
  /* Batas keras: apa pun yang kelebaran dipotong di kolomnya sendiri, tidak
     merembes ke kolom sebelah lalu tertimpa latar kolom itu. Penggulung
     internal (#log, #list, #panel) punya overflow sendiri, jadi tidak terpengaruh. */
  overflow: hidden;
}
.col + .col { border-left: 1px solid var(--line); }

.bar {
  padding: 0 16px; height: 60px; flex: none;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: nowrap;
}
.bar .titles { display: flex; flex-direction: column; justify-content: center; min-width: 0; gap: 1px; }
.bar h2 {
  margin: 0; font-size: 15px; font-weight: 640; letter-spacing: -.015em; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar .sub {
  font-size: 12px; color: var(--fg-muted); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Kelompok aksi boleh menyusut. Dulu `flex: none` membuatnya tidak bisa
   mengalah sama sekali, sehingga saat ruang menyempit ia meluber keluar kolom
   dan tertimpa panel di sebelahnya. */
.bar .actions { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
.bar .btn {
  height: 32px; display: inline-flex; align-items: center;
  white-space: nowrap; flex: none; border-radius: 8px;
}
/* Dropdown yang mengalah lebih dulu — ia paling lebar dan paling tidak kritis. */
.bar .actions select {
  height: 32px; border-radius: 8px; flex: 0 1 auto; min-width: 88px; max-width: 150px;
  padding: 0 8px; border: 1px solid var(--line-strong); white-space: nowrap;
  background: var(--surface); color: var(--fg-muted); font-size: 12.5px; cursor: pointer;
}
.bar .actions select:hover { color: var(--fg); }

/* Kalau kolom percakapan mulai sempit, tombol jadi ikon saja. Judulnya tetap
   terbaca lewat atribut title, dan tidak ada lagi teks yang terpotong. */
@media (max-width: 1440px) {
  .col-chat .bar .icon-btn span { display: none; }
  .col-chat .bar .icon-btn { padding: 0 9px; }
  .col-chat .bar .actions select { max-width: 118px; }
}

/* ══ Kolom daftar ════════════════════════════════════════════ */

.tabs { display: flex; gap: 3px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--fg-muted);
  padding: 6px 4px; border-radius: 8px; cursor: pointer; font-size: 12.5px; font-weight: 550;
  transition: background .12s, color .12s;
}
.tab:hover { background: var(--surface-2); }
.tab.on { background: var(--accent-soft); color: var(--accent); }
.tab .count { font-size: 11px; opacity: .8; }

.list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px; font-size: 12.5px; font-weight: 650; color: var(--fg-muted);
}
.mini-select {
  width: auto; border: 0; background: transparent; color: var(--fg-muted);
  font-size: 12.5px; padding: 2px 4px; cursor: pointer;
}
.mini-select:focus { box-shadow: none; }

#list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }

.item {
  padding: 10px; border-radius: 10px; cursor: pointer; display: flex; gap: 10px;
  transition: background .12s;
}
.item:hover { background: var(--surface-2); }
.item.active { background: var(--surface-3); }
.item .ava-lg {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--surface-3); color: var(--fg-muted);
  display: grid; place-items: center; font-weight: 650; font-size: 13px;
}
.item.active .ava-lg { background: var(--surface); }
.item .body { flex: 1; min-width: 0; }
.item .top { display: flex; align-items: center; gap: 7px; }
.item .name {
  font-weight: 620; font-size: 13.5px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item .time { font-size: 11px; color: var(--fg-subtle); flex: none; }
.item .snippet {
  color: var(--fg-muted); font-size: 12.5px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item.unread-item .snippet { color: var(--accent); font-weight: 550; }
.item .tagline { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }

.pill {
  font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .04em; flex: none;
}
.pill.bot { background: var(--bot-soft); color: var(--bot); }
.pill.waiting { background: var(--warn-soft); color: var(--warn); }
.pill.human { background: var(--ok-soft); color: var(--ok); }
.pill.closed { background: var(--surface-3); color: var(--fg-muted); }

.unread {
  background: var(--accent); color: #fff; border-radius: 99px; min-width: 18px; height: 18px;
  font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; flex: none;
}

.chip {
  font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--fg-muted);
  display: inline-flex; align-items: center; gap: 4px;
}
.chip button { border: 0; background: none; cursor: pointer; color: var(--fg-subtle); padding: 0; font-size: 13px; line-height: 1; }
.chip button:hover { color: var(--danger); }

.empty { padding: 40px 20px; text-align: center; color: var(--fg-subtle); font-size: 13px; }
.conn-lost { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9999; padding: 10px 16px; text-align: center; font-size: 13px; font-weight: 600; background: #b42336; color: #fff; }
.truncated { padding: 10px 14px; margin: 8px; border-radius: 8px; background: var(--warn-bg, #fff7e6); color: var(--warn-fg, #7a4a00); font-size: 12px; line-height: 1.5; }

/* ══ Kolom percakapan ════════════════════════════════════════ */

#log { flex: 1; overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; }
/* Spacer lentur: percakapan pendek merapat ke bawah dekat composer, tapi
   menyusut jadi nol saat panjang — tidak memotong pesan teratas. */
#log::before { content: ""; flex: 1 1 auto; }

.row { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.row.me { flex-direction: row-reverse; }
.row .col-msg { display: flex; flex-direction: column; min-width: 0; max-width: 74%; }
.row.me .col-msg { align-items: flex-end; }

.ava {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--fg-muted); margin-bottom: 18px;
}
.row.me .ava { background: var(--accent); color: #fff; }
.row.bot .ava { background: #f4f8ff; color: var(--bot); border: 1px solid #dae7ff; }
.row.bot .ava img { display: block; width: 25px; height: 25px; object-fit: contain; }

.row .who { font-size: 11.5px; color: var(--fg-muted); margin: 0 4px 4px; }
.bubble {
  padding: 10px 15px; border-radius: 18px; white-space: pre-wrap; word-break: break-word;
  font-size: 14px; line-height: 1.5;
}
.row.them .bubble { background: var(--surface-3); border-bottom-left-radius: 5px; }
.row.me .bubble { background: var(--accent); color: var(--accent-fg); border-bottom-right-radius: 5px; }
.row.bot .bubble { background: var(--bot-soft); color: var(--fg); border-bottom-right-radius: 5px; }
.row .stamp { font-size: 10.5px; color: var(--fg-subtle); margin: 4px 5px 0; }

.sys { text-align: center; color: var(--fg-subtle); font-size: 12px; margin: 12px 0; }

.daysep { display: flex; align-items: center; gap: 12px; margin: 18px 0 16px; }
.daysep::before, .daysep::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.daysep span {
  font-size: 11px; font-weight: 620; color: var(--fg-subtle);
  background: var(--surface-2); padding: 4px 11px; border-radius: 99px;
}

.bubble img { max-width: 260px; border-radius: 10px; display: block; margin-top: 6px; }
.bubble a { color: inherit; }

#placeholder { flex: 1; display: grid; place-items: center; text-align: center; padding: 20px; }
.ph-ico { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.ph-title { font-weight: 600; margin-bottom: 3px; }
.ph-sub { color: var(--fg-subtle); font-size: 13px; }

.closed-note {
  flex: none; padding: 14px 18px; border-top: 1px solid var(--line);
  background: var(--surface-2); color: var(--fg-muted); font-size: 13px; text-align: center;
}

/* ── Composer ── */

#composer { flex: none; border-top: 1px solid var(--line); padding: 12px 16px 10px; position: relative; }

.suggestions { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 9px; }
.suggestion {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
  border-radius: 99px; padding: 6px 13px; font-size: 12.5px; cursor: pointer;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.suggestion:hover { background: var(--accent-soft); border-color: var(--accent); }

.composer-box {
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface);
  position: relative; transition: border-color .12s, box-shadow .12s;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-box textarea {
  width: 100%; border: 0; background: transparent; resize: none; outline: none;
  padding: 12px 14px 4px; max-height: 160px; box-shadow: none !important;
}
.composer-tools { display: flex; align-items: center; gap: 3px; padding: 6px 8px 8px 10px; }
.tool {
  border: 0; background: transparent; cursor: pointer; font-size: 15px;
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  transition: background .12s;
}
.tool:hover { background: var(--surface-2); }
.tool-hint { flex: 1; text-align: right; font-size: 11.5px; color: var(--fg-subtle); margin-right: 8px; }
.composer-tools .btn { height: 32px; padding: 0 16px; display: inline-flex; align-items: center; }

.canned-pop, .emoji-pop {
  position: absolute; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 20; display: none;
}
.canned-pop { bottom: 100%; left: 16px; right: 16px; margin-bottom: 8px; max-height: 260px; overflow-y: auto; }
.canned-pop.show { display: block; }
.canned-item { padding: 10px 13px; cursor: pointer; border-bottom: 1px solid var(--line); }
.canned-item:last-child { border-bottom: 0; }
.canned-item:hover, .canned-item.on { background: var(--accent-soft); }
.canned-item .sc { font-weight: 650; color: var(--accent); font-size: 12.5px; }
.canned-item .bd { color: var(--fg-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.emoji-pop { bottom: calc(100% + 8px); left: 8px; padding: 8px; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-pop.show { display: grid; }
.emoji-pop button { border: 0; background: none; font-size: 18px; cursor: pointer; padding: 6px; border-radius: 8px; }
.emoji-pop button:hover { background: var(--surface-2); }

.tagbar { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tagbar-label { font-size: 12px; color: var(--fg-muted); flex: none; }
.tagbar-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.tagbar-input {
  width: 130px; padding: 4px 10px; font-size: 12px; border-radius: 99px;
  border: 1px dashed var(--line-strong); background: transparent;
}
.tagbar-input:focus { border-style: solid; box-shadow: none; border-color: var(--accent); }

/* ══ Kolom info ══════════════════════════════════════════════ */

#panel { flex: 1; overflow-y: auto; }

.profile { padding: 22px 18px 18px; text-align: center; border-bottom: 1px solid var(--line); }
.profile-ava {
  width: 62px; height: 62px; border-radius: 50%; margin: 0 auto 10px;
  background: var(--surface-3); color: var(--fg-muted);
  display: grid; place-items: center; font-size: 21px; font-weight: 700;
}
.profile-name { font-size: 15.5px; font-weight: 640; letter-spacing: -.01em; }
.profile-mail { font-size: 12.5px; color: var(--fg-muted); margin-top: 2px; word-break: break-all; }
.profile-pills { display: flex; justify-content: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

details.sect { border-bottom: 1px solid var(--line); }
details.sect > summary {
  padding: 14px 18px; cursor: pointer; font-size: 13px; font-weight: 620;
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
details.sect > summary::-webkit-details-marker { display: none; }
details.sect > summary::after { content: "⌄"; color: var(--fg-subtle); transition: transform .15s; }
details.sect[open] > summary::after { transform: rotate(180deg); }
details.sect > summary:hover { background: var(--surface-2); }
.sect-body { padding: 0 18px 16px; }

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 7px 10px; font-size: 12.5px; margin: 0; }
.kv dt { color: var(--fg-muted); }
.kv dd { margin: 0; word-break: break-word; }
.intake-state { color: var(--accent); font-size: 12px; font-weight: 600; margin: 0 0 12px; }
#intakeSummary .muted { margin: 12px 0 0; font-size: 11px; line-height: 1.5; }

.note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 12.5px; }
.note .meta { font-size: 10.5px; opacity: .75; margin-top: 5px; }
.hist { font-size: 12.5px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--fg-muted); }
.hist:last-child { border-bottom: 0; }

.hidden { display: none !important; }

/* ══ Responsif ═══════════════════════════════════════════════ */

@media (max-width: 1180px) {
  .card { grid-template-columns: 280px minmax(0, 1fr); }
  .col-info { display: none; }
}
@media (max-width: 760px) {
  .rail { display: none; }
  .card { grid-template-columns: 1fr; margin-right: 0; }
  .col-list { display: none; }
  #app.show-list .col-list { display: flex; }
  #app.show-list .col-chat { display: none; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid var(--surface); }
::-webkit-scrollbar-track { background: transparent; }

/* ══ Ikon ════════════════════════════════════════════════════ */

.ico { width: 18px; height: 18px; flex: none; display: block; }
.rail-btn .ico { width: 20px; height: 20px; }
.search-ico { width: 15px; height: 15px; opacity: .65; }
.tool .ico { width: 17px; height: 17px; }
.tagbar-label .ico { width: 13px; height: 13px; }
.ph-ico { width: 44px; height: 44px; margin: 0 auto 12px; opacity: .35; stroke-width: 1.5; }

/* Tombol ikon+teks: satu baris, ikon tidak pernah meregang. */
.icon-btn { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn .ico { width: 15px; height: 15px; }
.btn.danger.sm.icon-btn { padding: 5px 8px; }

/* ══ Tampilan halaman penuh (laporan & pengaturan) ═══════════ */

.page-view { display: block; overflow-y: auto; }
.page { max-width: 1000px; margin: 0 auto; padding: 28px 28px 60px; }
.page h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.page-sub { color: var(--fg-muted); font-size: 13px; margin-top: 2px; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; }
.tile .label { font-size: 11.5px; color: var(--fg-muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 30px; font-weight: 640; letter-spacing: -.03em; margin-top: 6px; line-height: 1.1; }
.tile .hint { font-size: 12px; color: var(--fg-subtle); margin-top: 3px; }

.panel-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 16px; }
.panel-card h2 { margin: 0 0 2px; font-size: 15px; letter-spacing: -.01em; }
.panel-sub { font-size: 12.5px; color: var(--fg-muted); margin-bottom: 15px; }

/* Token viz — dua hue kategorikal yang lolos validasi di terang & gelap */
.viz { --series-bot: #2a78d6; --series-human: #eb6834; --grid: var(--line); }
@media (prefers-color-scheme: dark) {
  .viz { --series-bot: #3987e5; --series-human: #d95926; }
}

.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--fg-muted); margin-bottom: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.panel-card svg { display: block; width: 100%; overflow: visible; }
/* Kelas khusus grafik. JANGAN pakai .bar di sini — .bar sudah dipakai
   bar header kolom dengan height:60px, dan di SVG2 properti geometri
   bisa diatur lewat CSS sehingga menimpa atribut height batang. */
.vbar { pointer-events: none; }
.vhit { fill: transparent; transition: fill .1s; }
.vhit:hover { fill: var(--surface-3); }

.chart { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; }
.chart-y {
  display: flex; flex-direction: column; justify-content: space-between;
  align-items: flex-end; height: 170px; font-size: 10.5px; color: var(--fg-subtle);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.chart-plot { height: 170px; }
.chart-x {
  display: flex; justify-content: space-between; font-size: 11px;
  color: var(--fg-subtle); margin-top: 9px; padding-left: 44px;
}
.split-x { padding-left: 0; font-size: 12.5px; color: var(--fg-muted); }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--fg-subtle); margin-top: 8px; }

.tip {
  position: fixed; pointer-events: none; background: var(--fg); color: var(--surface);
  font-size: 12px; padding: 6px 9px; border-radius: 7px; opacity: 0;
  transition: opacity .1s; z-index: 200; white-space: nowrap;
}
.tip.show { opacity: 1; }

.panel-card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.panel-card th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-subtle); padding: 0 10px 8px 0; font-weight: 700; }
.panel-card td { padding: 9px 10px 9px 0; border-top: 1px solid var(--line); vertical-align: top; }
.panel-card td.num, .panel-card th.num { text-align: right; font-variant-numeric: tabular-nums; }
.panel-card td.mono { font-weight: 650; color: var(--accent); }
.panel-card td.muted-cell { color: var(--fg-muted); }

.topic { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; margin-bottom: 7px; font-size: 13px; }
.topic-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic .track { background: var(--surface-3); border-radius: 4px; height: 20px; overflow: hidden; }
.topic .fill { height: 100%; border-radius: 4px; background: var(--series-bot); }
.topic .n { text-align: right; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.muted { color: var(--fg-subtle); font-size: 13px; }

/* ── Pengaturan ── */

.day { display: grid; grid-template-columns: 96px 26px 1fr 12px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.day .name { font-size: 13px; }
.day .dash { text-align: center; color: var(--fg-subtle); }
.day input[type=time] { padding: 6px 9px; font-size: 13px; }
.day.off input[type=time] { opacity: .35; pointer-events: none; }

.grid2 { display: grid; grid-template-columns: 160px 1fr; gap: 8px; margin-top: 14px; }
.panel-card textarea { margin-top: 8px; }
.save-row { display: flex; align-items: center; margin-top: 12px; }
.saved { color: var(--ok); font-size: 13px; margin-left: 10px; opacity: 0; transition: opacity .2s; }
.saved.show { opacity: 1; }

/* ── Pengelolaan tim ── */

.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fg-muted); margin: 0; font-weight: 400; }
.inline-check input { width: auto; }
.err-inline { color: var(--danger); font-size: 12.5px; margin-left: 10px; }

.member { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.member:first-child { border-top: 0; }
.member .ava-sm {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--surface-3); color: var(--fg-muted);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.member .who { flex: 1; min-width: 0; }
.member .nm { font-weight: 600; font-size: 13px; }
.member .em { font-size: 12px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .acts { display: flex; gap: 6px; flex: none; }
.member.off { opacity: .55; }
.badge-role { font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.badge-role.admin { background: var(--accent-soft); color: var(--accent); }
.badge-role.agent { background: var(--surface-3); color: var(--fg-muted); }
.badge-role.off { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
}

/* ══ Basis pengetahuan ═══════════════════════════════════════ */

.kb-search {
  width: 260px; padding: 8px 12px; font-size: 13px; border-radius: var(--radius);
}
.count-badge {
  font-size: 11.5px; font-weight: 600; color: var(--fg-muted);
  background: var(--surface-3); border-radius: 99px; padding: 2px 9px; margin-left: 6px;
}

.kb-item { border-top: 1px solid var(--line); padding: 14px 0; }
.kb-item:first-child { border-top: 0; padding-top: 4px; }
.kb-head { display: flex; align-items: baseline; gap: 12px; }
.kb-q { font-weight: 620; font-size: 13.5px; flex: 1; min-width: 0; }
.kb-uses {
  font-size: 11px; color: var(--fg-subtle); flex: none;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.kb-a { font-size: 13px; color: var(--fg-muted); margin-top: 5px; white-space: pre-wrap; }
.kb-meta { font-size: 11.5px; color: var(--fg-subtle); margin-top: 7px; }
.kb-acts { display: flex; gap: 6px; margin-top: 9px; }
.kb-item input, .kb-item textarea { margin-bottom: 7px; }

/* Tombol angkat jawaban agent jadi pengetahuan — muncul saat baris disorot,
   supaya tidak meramaikan percakapan yang sedang dibaca. */
.promote {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg-muted);
  border-radius: 99px; padding: 2px 9px; font-size: 11px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; margin-left: 8px;
  opacity: 0; transition: opacity .12s, border-color .12s, color .12s;
}
.row:hover .promote, .promote:focus-visible { opacity: 1; }
.promote:hover { border-color: var(--accent); color: var(--accent); }
.promote .ico { width: 12px; height: 12px; }
.promote.done { opacity: 1; border-color: var(--ok); color: var(--ok); }
.promote:disabled { cursor: default; }

