:root {
  --ink: #0b1f2a;
  --ink-2: #12303f;
  --ink-3: #1b4253;
  --bg: #f4f6f5;
  --card: #ffffff;
  --line: #e3e8e6;
  --text: #13212b;
  --muted: #64737d;
  --accent: #f5a524;
  --accent-ink: #3b2600;
  --teal: #0f766e;
  --radius: 14px;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-color: var(--text);
  --bs-primary: #0f766e;
  --bs-primary-rgb: 15, 118, 110;
  --bs-link-color: #0f766e;
  --bs-link-color-rgb: 15, 118, 110;
  --bs-link-hover-color: #0b5c56;
}
body { background: var(--bg); font-size: 14px; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.nav-item:hover, .thread:hover, .supplier-card:hover, .btn:hover { text-decoration: none; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--ink); color: #cfe0e4;
  display: flex; flex-direction: column; gap: 6px; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 18px;
}
.brand-name { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: #8fb0b8; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: #b9cfd4; text-decoration: none; font-weight: 500;
}
.nav-item i { font-size: 16px; width: 18px; }
.nav-item:hover { background: var(--ink-2); color: #fff; }
.nav-item.active { background: var(--ink-3); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-badge { margin-left: auto; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.btn-accent { background: var(--accent); color: var(--accent-ink); font-weight: 600; border: 0; border-radius: 10px; padding: 9px 12px; }
.btn-accent:hover { background: #ffb53d; color: var(--accent-ink); }
.me-box { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; margin-top: 12px; border-top: 1px solid var(--ink-3); }
.text-muted-2 { color: #8fb0b8; }
.sidebar .icon-btn { color: #b9cfd4; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px 8px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.content { padding: 12px 28px 40px; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 4px 6px; border-radius: 8px; text-decoration: none; }
.icon-btn:hover { background: rgba(0,0,0,.05); color: var(--text); }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; z-index: 1040; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

/* ---------- components ---------- */
.card-x { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-x .card-x-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-x .card-x-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.card-x .card-x-body { padding: 18px 20px; }
.kpi { padding: 18px 20px; }
.kpi .kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .kpi-foot { font-size: 12px; color: var(--muted); }
.kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; }

.table-x { margin: 0; }
.table-x th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfb; border-bottom: 1px solid var(--line); padding: 10px 14px; white-space: nowrap; }
.table-x td { padding: 11px 14px; vertical-align: middle; border-color: var(--line); }
.table-x tr:last-child td { border-bottom: 0; }
.table-x tbody tr:hover { background: #fafcfb; }
.row-link { cursor: pointer; }

.sup-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.sup-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px;
  background: #d9ece9; color: var(--teal); flex-shrink: 0;
}
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
.dot.off { background: #cbd5d1; }

.progress-thin { height: 6px; border-radius: 999px; background: #edf1ef; }
.progress-thin .progress-bar { background: var(--teal); border-radius: 999px; }

.form-label { font-weight: 500; font-size: 13px; }
.form-control, .form-select { border-radius: 10px; border-color: #d6dedb; }
.form-control:focus, .form-select:focus { border-color: var(--teal); box-shadow: 0 0 0 .2rem rgba(15,118,110,.15); }
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { background: var(--teal); border-color: var(--teal); }
.btn-primary:hover { background: #0b5c56; border-color: #0b5c56; }
.btn-outline-primary { color: var(--teal); border-color: var(--teal); }
.btn-outline-primary:hover { background: var(--teal); border-color: var(--teal); }
.form-check-input:checked { background-color: var(--teal); border-color: var(--teal); }

.supplier-card { border-top: 4px solid var(--c); transition: transform .12s, box-shadow .12s; text-decoration: none; color: inherit; display: block; }
.supplier-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(11,31,42,.08); color: inherit; }
.supplier-logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; background: var(--c); }

.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.empty i { font-size: 30px; display: block; margin-bottom: 6px; opacity: .6; }

.chip-check { display: inline-flex; }
.chip-check input { display: none; }
.chip-check span {
  border: 1px solid #d6dedb; border-radius: 999px; padding: 6px 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-weight: 500; user-select: none;
}
.chip-check span::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c, #94a3b8); }
.chip-check input:checked + span { background: color-mix(in srgb, var(--c, #0f766e) 14%, white); border-color: var(--c, #0f766e); color: var(--text); }

.temp-pwd { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: .06em; background: #fff8e8; border: 1px dashed var(--accent); padding: 4px 10px; border-radius: 8px; }

/* ---------- chat ---------- */
.chat-wrap { display: grid; grid-template-columns: 320px 1fr; grid-template-rows: minmax(0, 1fr); height: calc(100vh - 120px); min-height: 480px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; }
.chat-search { padding: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.thread { display: flex; gap: 10px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f0f3f2; }
.thread:hover { background: #f7faf9; }
.thread.active { background: #e9f4f2; }
.thread .t-name { font-weight: 600; }
.thread .t-last { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread .t-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.thread .t-unread { background: var(--teal); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.chat-head { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; background: #f3f6f5 radial-gradient(#e2e9e6 1px, transparent 1px) 0 0 / 18px 18px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 70%; padding: 8px 12px 6px; border-radius: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.04); }
.bubble.agent { background: #fff; align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.office { background: #d6efe9; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble .meta { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; }
.day-sep { align-self: center; font-size: 11.5px; color: var(--muted); background: #fff; padding: 2px 10px; border-radius: 999px; margin: 8px 0; }
.chat-input { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 8px; background: #fff; flex-shrink: 0; }
.chat-input textarea { resize: none; max-height: 140px; }
@media (max-width: 767.98px) {
  .chat-wrap { grid-template-columns: 1fr; }
  .chat-wrap.has-thread .chat-list { display: none; }
  .chat-wrap:not(.has-thread) .chat-pane { display: none; }
}

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ''; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(245,165,36,.35), transparent 70%); }
.login-form { display: grid; place-items: center; padding: 32px; }
@media (max-width: 860px) { .login-page { grid-template-columns: 1fr; } .login-art { display: none; } }

.detail-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }
