/* ═══════════════════════════════════════
   [SECTION: CSS - VARIABLES & BASE (CORPORATE THEME)]
   ═══════════════════════════════════════ */
:root {
  --bg: #F9FAFC;
  --bg2: #F1F5F9;
  --panel: #FFFFFF;
  --border: #E2E8F0;
  --border2: #CBD5E1;
  --accent: #328CC1;
  --accent2: #0B3C5D;
  --red: #E53E3E;
  --gold: #D69E2E;
  --purple: #805AD5;
  --dim: #64748B;
  --text: #475569;
  --texthi: #1D2731;
  --sans: 'Inter', sans-serif;
}

* {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: normal !important;
}

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 13px; overflow-x: hidden;
}

body::after { display: none !important; }
#auth-canvas { display: none !important; }

/* ═══════════════════════════════════════
   [SECTION: CSS - PRINT]
   ═══════════════════════════════════════ */
@media print {
  .topbar, .nav-tabs, .btn, .filter-bar, .td-del, #modal { display: none !important; }
  #content { padding: 0; }
  .dp, .sum-card { border: none !important; box-shadow: none !important; }
  body { background: white; color: black; }
  .sc-val, .sc-label { color: black !important; }
  .modal-overlay { display: none !important; }
  table { font-size: 11px; }
  thead th, tbody td { padding: 6px 8px; }
  .item-line, .jd-row { display: grid !important; }
}

/* ═══════════════════════════════════════
   [SECTION: CSS - AUTH & ONBOARDING]
   ═══════════════════════════════════════ */
#auth-screen {
  position: fixed; inset: 0; z-index: 1000; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.auth-box {
  position: relative; z-index: 2; width: 100%; max-width: 420px;
  padding: 0 24px; display: flex; flex-direction: column;
  align-items: center; gap: 24px;
}
.t-logo { font-weight: 800; font-size: 18px; color: #fff; }
.t-logo span { color: var(--accent); }
.auth-sub { font-size: 13px; color: var(--dim); text-align: center; margin-top: -5px; font-weight: 500; }
.auth-card {
  width: 100%; background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 10px 25px rgba(0,0,0,0.05); padding: 32px 28px;
  border-radius: 12px; display: flex; flex-direction: column; gap: 16px;
}
.auth-card-title { font-size: 12px; font-weight: 600; color: var(--texthi); text-align: center; text-transform: uppercase; }
.auth-google-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; background: #fff; border: 1px solid var(--border2);
  color: var(--texthi); font-size: 13px; font-weight: 600; padding: 12px;
  cursor: pointer; border-radius: 6px; transition: all .2s;
}
.auth-google-btn:hover { background: var(--bg2); border-color: var(--dim); }
.auth-google-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.auth-note { font-size: 12px; color: var(--dim); text-align: center; line-height: 1.8; margin-top: 10px; }
.auth-tab-active {
  background: var(--bg2) !important; color: var(--accent2) !important;
  border-color: var(--border) !important; font-weight: 600;
}

#onboarding {
  position: fixed; inset: 0; z-index: 999; background: var(--bg);
  display: none; align-items: center; justify-content: center;
  overflow-y: auto; padding: 20px;
}
.ob-box {
  width: 100%; max-width: 580px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.05); padding: 32px;
}
.ob-title { font-size: 20px; font-weight: 800; color: var(--accent2); margin-bottom: 8px; }
.ob-sub {
  font-size: 13px; color: var(--dim); font-weight: 500;
  margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 16px;
}
.ob-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media(max-width:500px) { .ob-grid, .form-grid { grid-template-columns: 1fr; } }
.ob-full, .form-full { grid-column: 1 / -1; }

/* ═══════════════════════════════════════
   [SECTION: CSS - APP LAYOUT]
   ═══════════════════════════════════════ */
#app { display: none; min-height: 100vh; flex-direction: column; }
#app.visible { display: flex; }

.topbar {
  background: var(--accent2); height: 56px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.t-left { display: flex; align-items: center; gap: 16px; }
.t-biz {
  font-size: 13px; font-weight: 600; color: #e2e8f0;
  border-left: 1px solid rgba(255,255,255,0.2); padding-left: 16px;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.t-right { display: flex; align-items: center; gap: 16px; }
.t-user {
  font-size: 13px; color: #cbd5e1; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500;
}
.t-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: #fff; font-size: 12px; font-weight: 600; padding: 6px 14px;
  cursor: pointer; border-radius: 4px; transition: all .2s;
}
.t-btn:hover { background: var(--red); border-color: var(--red); }

.nav-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  background: var(--panel); flex-shrink: 0;
  overflow-x: auto; padding: 0 10px;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 0 0 auto; background: none; border: none; color: var(--dim);
  font-size: 12px; font-weight: 600; padding: 14px 16px; cursor: pointer;
  border-bottom: 3px solid transparent; transition: all .2s;
  white-space: nowrap; text-transform: uppercase;
}
.tab-btn.active { color: var(--accent2); border-bottom-color: var(--accent2); }
.tab-btn:hover:not(.active) { color: var(--accent); }
.tab-sep { width: 1px; background: var(--border); margin: 10px 8px; flex-shrink: 0; }

#content { flex: 1; overflow-y: auto; padding: 24px; }
#content::-webkit-scrollbar { width: 6px; }
#content::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ═══════════════════════════════════════
   [SECTION: CSS - COMPONENTS]
   ═══════════════════════════════════════ */
.sum-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
@media(min-width:600px) { .sum-grid { grid-template-columns: repeat(4, 1fr); } }

.sum-card {
  background: var(--panel); border: 1px solid var(--border);
  padding: 20px; border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  position: relative; overflow: hidden;
}
.sum-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.sum-card.blue::before   { background: var(--accent); }
.sum-card.green::before  { background: var(--accent2); }
.sum-card.gold::before   { background: var(--gold); }
.sum-card.purple::before { background: var(--purple); }
.sum-card.red::before    { background: var(--red); }

.sc-label { font-size: 11px; font-weight: 700; color: var(--dim); margin-bottom: 8px; text-transform: uppercase; }
.sc-val { font-size: clamp(20px, 3vw, 26px); font-weight: 800; color: var(--texthi); line-height: 1.2; }
.sc-val.blue   { color: var(--accent); }
.sc-val.green  { color: var(--accent2); }
.sc-val.gold   { color: var(--gold); }
.sc-val.purple { color: var(--purple); }
.sc-val.red    { color: var(--red); }
.sc-sub { font-size: 12px; color: var(--dim); margin-top: 6px; font-weight: 500; }

.dp {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  margin-bottom: 24px; overflow: hidden;
}
.dp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg2); flex-wrap: wrap; gap: 10px;
}
.dp-title { font-size: 14px; font-weight: 700; color: var(--accent2); text-transform: uppercase; }
.dp-sub { font-size: 12px; color: var(--dim); font-weight: 500; }
.dp-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 11px; font-weight: 700; color: var(--texthi); text-transform: uppercase; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .form-group { flex: 1; min-width: 140px; }

.form-input {
  width: 100%; background: #fff; border: 1px solid var(--border2);
  color: var(--texthi); font-family: var(--sans); font-size: 13px;
  padding: 10px 14px; border-radius: 6px; outline: none;
  transition: border-color .2s, box-shadow .2s;
  appearance: none; -webkit-appearance: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(50, 140, 193, 0.15); }
.form-input::placeholder { color: #94A3B8; }
select.form-input {
  cursor: pointer;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%2364748B" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}

.btn {
  background: #fff; border: 1px solid var(--border2); color: var(--text);
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  padding: 8px 16px; cursor: pointer; border-radius: 6px; transition: all .2s;
  white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,0.05); text-transform: uppercase;
}
.btn:hover { background: var(--bg2); color: var(--texthi); border-color: var(--dim); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #2673a0; border-color: #2673a0; }
.btn.success { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.btn.success:hover { background: #082d46; border-color: #082d46; }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.danger:hover { background: #c53030; border-color: #c53030; }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.gold:hover { background: #b7791f; border-color: #b7791f; }
.btn.red { background: var(--red); color: #fff; border-color: var(--red); }
.btn.red:hover { background: #c53030; border-color: #c53030; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 13px; }
thead th {
  padding: 12px 16px; text-align: left; color: var(--dim);
  font-size: 11px; font-weight: 700; border-bottom: 2px solid var(--border);
  border-top: 1px solid var(--border); background: var(--bg2);
  white-space: nowrap; text-transform: uppercase;
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--texthi); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); cursor: pointer; }
.td-name { font-weight: 600; color: var(--accent2); }
.td-code { color: var(--dim); font-size: 11px; font-weight: 500; }
.td-del {
  background: #FEE2E2; border: none; color: var(--red); cursor: pointer;
  font-size: 12px; width: 24px; height: 24px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center; transition: background .2s;
}
.td-del:hover { background: var(--red); color: #fff; }

.status-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 20px; text-transform: uppercase;
}
.s-Draft                        { background: #E2E8F0; color: #475569; }
.s-Confirmed, .s-Sent           { background: #E0F2FE; color: #0284C7; }
.s-Invoiced, .s-Received, .s-Posted { background: #DCFCE7; color: #0D9488; }
.s-Paid, .s-Billed              { background: #FEF9C3; color: #D97706; }
.s-Cancelled, .s-Overdue        { background: #FEE2E2; color: #DC2626; }

.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 12px; text-transform: uppercase; background: var(--bg2); color: var(--dim); border: 1px solid var(--border); }
.badge.green  { background: #DCFCE7; color: #0D9488; border-color: #0D9488; }
.badge.blue   { background: #E0F2FE; color: #0284C7; border-color: #0284C7; }
.badge.gold   { background: #FEF9C3; color: #D97706; border-color: #D97706; }
.badge.red    { background: #FEE2E2; color: #DC2626; border-color: #DC2626; }
.badge.purple { background: #F3E8FF; color: #7E22CE; border-color: #7E22CE; }

.filter-bar {
  display: flex; gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; background: #fff;
}
.search-input {
  flex: 1; min-width: 200px; background: #fff; border: 1px solid var(--border2);
  color: var(--texthi); font-size: 13px; padding: 8px 14px;
  border-radius: 6px; outline: none; transition: border-color .2s;
}
.search-input:focus, .filter-select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(50, 140, 193, 0.15);
}
.filter-select {
  background: #fff; border: 1px solid var(--border2); color: var(--texthi);
  font-size: 13px; font-weight: 500; padding: 8px 14px;
  border-radius: 6px; outline: none; cursor: pointer;
}

/* ═══════════════════════════════════════
   [SECTION: CSS - MODALS & CHARTS]
   ═══════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal {
  background: #fff; border: none; width: 100%; max-width: 680px;
  max-height: 90vh; overflow-y: auto; border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.modal::-webkit-scrollbar { width: 6px; }
.modal::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #fff; z-index: 10;
  border-radius: 12px 12px 0 0;
}
.modal-title { font-size: 16px; font-weight: 800; color: var(--accent2); text-transform: uppercase; }
.modal-close { background: none; border: none; color: var(--dim); font-size: 20px; cursor: pointer; font-weight: 700; }
.modal-close:hover { color: var(--red); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 18px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap;
  background: #F8FAFC; border-radius: 0 0 12px 12px;
}

.item-lines {
  margin-top: 20px; border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; background: var(--bg);
}
.item-line {
  display: grid; grid-template-columns: 1fr 80px 120px 80px 120px 30px;
  gap: 10px; align-items: center; margin-bottom: 10px;
}
@media(max-width:600px) { .item-line { grid-template-columns: 1fr 60px 90px 40px; } }
.item-line-head { font-size: 11px; font-weight: 700; color: var(--dim); text-transform: uppercase; padding: 0 0 8px; }
.item-line-total { font-size: 13px; font-weight: 800; color: var(--accent2); text-align: right; }
.item-del-btn {
  background: #FEE2E2; border: none; color: var(--red); cursor: pointer;
  font-size: 14px; width: 28px; height: 28px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center; transition: background .2s;
}
.item-del-btn:hover { background: var(--red); color: #fff; }

.jh-row { padding: 16px 20px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.jh-row:hover { background: var(--bg2); }
.jh-ref { font-size: 14px; font-weight: 700; color: var(--texthi); }
.jh-desc { font-size: 13px; color: var(--dim); margin-top: 4px; font-weight: 500; }
.jd-row {
  display: grid; grid-template-columns: 100px 1fr 120px 120px;
  gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border);
  font-size: 13px; align-items: center;
}
.jd-row:last-child { border-bottom: none; }

.coa-group-tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 4px 8px; border-radius: 4px; text-transform: uppercase; border: none;
}
.coa-Aset       { background: #E0F2FE; color: #0284C7; }
.coa-Liabilitas { background: #FEE2E2; color: #DC2626; }
.coa-Ekuitas    { background: #F3E8FF; color: #7E22CE; }
.coa-Pendapatan { background: #DCFCE7; color: #0D9488; }
.coa-Beban      { background: #FEF9C3; color: #D97706; }

.log-row {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 16px;
}
.log-time { font-size: 12px; color: var(--dim); white-space: nowrap; margin-top: 2px; min-width: 90px; font-weight: 600; }
.log-activity { font-size: 14px; font-weight: 700; color: var(--accent2); }
.log-detail { font-size: 13px; color: var(--text); margin-top: 4px; }

.chart-container {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.chart-inner { padding: 20px; }
canvas.achart { width: 100%; display: block; }
.analytics-2col { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 20px; }
@media(min-width:700px) { .analytics-2col { grid-template-columns: 1fr 1fr; } }

.aging-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.aging-label { font-size: 13px; font-weight: 600; color: var(--text); min-width: 120px; }
.aging-bar-track { flex: 1; height: 12px; background: var(--border); border-radius: 6px; overflow: hidden; }
.aging-bar-fill { height: 100%; border-radius: 6px; }
.aging-amount { font-size: 13px; font-weight: 700; min-width: 100px; text-align: right; }

.empty-state {
  padding: 60px 20px; text-align: center; font-size: 14px;
  color: var(--dim); font-weight: 600; display: flex;
  flex-direction: column; align-items: center; justify-content: center; line-height: 1.6;
}

.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.9);
  z-index: 9998; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px; backdrop-filter: blur(2px);
}
.loading-spinner {
  width: 40px; height: 40px; border: 4px solid var(--border);
  border-top-color: var(--accent2); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; font-weight: 700; color: var(--accent2); text-transform: uppercase; }

.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--texthi); border: none; font-size: 13px; font-weight: 600;
  color: #fff; padding: 14px 24px; border-radius: 8px; z-index: 9999;
  animation: toastIn .3s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.toast.success { background: #10B981; }
.toast.error   { background: var(--red); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ═══════════════════════════════════════
   [SECTION: CSS - AI CHAT WIDGET]
   ═══════════════════════════════════════ */
@keyframes popIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.ai-btn {
  position: fixed; bottom: 20px; right: 20px;
  width: 54px; height: 54px; border-radius: 27px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 24px; display: flex;
  align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 15px rgba(11, 60, 93, 0.3);
  z-index: 9900; transition: transform 0.2s; border: none;
}
.ai-btn:hover { transform: scale(1.1); }

.ai-menu {
  position: fixed; bottom: 85px; right: 20px; width: 220px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  z-index: 9900; display: none; flex-direction: column; overflow: hidden;
  transform-origin: bottom right;
  animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.ai-menu-btn {
  background: none; border: none; padding: 16px; text-align: left;
  font-family: var(--sans); font-size: 12px; font-weight: 700;
  color: var(--texthi); cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background 0.2s; display: flex; align-items: center; gap: 10px;
}
.ai-menu-btn:last-child { border-bottom: none; }
.ai-menu-btn:hover { background: var(--bg2); color: var(--accent2); }

/* AI Window — Mobile First (fullscreen kayak WhatsApp) */
.ai-window {
  position: fixed;
  z-index: 9900;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);

  /* Mobile: fullscreen */
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
}

/* Tablet & Desktop: popup pojok kanan */
@media (min-width: 600px) {
  .ai-window {
    inset: auto;
    bottom: 85px;
    right: 20px;
    width: 360px;
    height: 500px;
    border-radius: 12px;
    transform-origin: bottom right;
  }
}

.ai-head {
  background: var(--accent2); color: #fff;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  font-weight: 800; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.ai-head span { color: var(--accent); }

.ai-close { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; opacity: 0.8; line-height: 1; }
.ai-close:hover { opacity: 1; }

.ai-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

.ai-msg {
  max-width: 85%; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.6;
  word-wrap: break-word; word-break: break-word;
}
.ai-msg.user {
  align-self: flex-end; background: var(--accent);
  color: #fff; border-bottom-right-radius: 2px;
}
.ai-msg.bot {
  align-self: flex-start; background: #fff;
  border: 1px solid var(--border); color: var(--texthi);
  border-bottom-left-radius: 2px; box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.ai-foot {
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
  flex-shrink: 0;
}
.ai-input {
  flex: 1; border: 1px solid var(--border2); border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px; /* 14px = tidak trigger zoom di iOS */
  outline: none; font-family: var(--sans); color: var(--texthi);
  -webkit-text-size-adjust: 100%;
}
.ai-input:focus { border-color: var(--accent); }
.ai-send {
  background: var(--accent); color: #fff; border: none;
  border-radius: 20px; padding: 10px 18px; font-weight: 700;
  cursor: pointer; font-size: 12px; transition: background 0.2s;
  white-space: nowrap;
}
.ai-send:hover { background: var(--accent2); }

/* ═══════════════════════════════════════
   [SECTION: CSS - SIBYL TERMINAL MODAL]
   ═══════════════════════════════════════ */
.sibyl-modal-backdrop {
  display: none; position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
  z-index: 10000; justify-content: center; align-items: center;
}
.sibyl-modal-window {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
  width: 90%; max-width: 1100px; height: 80vh;
  border-radius: 8px; display: flex; flex-direction: column;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3); overflow: hidden;
}
.sibyl-modal-header {
  padding: 15px 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(0, 0, 0, 0.05);
}
.sibyl-modal-body {
  flex: 1; padding: 20px; overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media(max-width: 700px) { .sibyl-modal-body { grid-template-columns: 1fr; } }

.sibyl-modal-panel {
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  padding: 15px; display: flex; flex-direction: column;
  background: rgba(0, 0, 0, 0.02);
}
.sibyl-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 15px; padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sibyl-scroll-box {
  flex: 1; overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px; max-height: 420px;
}
.sibyl-tag {
  padding: 2px 6px; border-radius: 4px;
  font-size: 11px; font-weight: bold;
  border: 1px solid rgba(255,255,255,0.2);
}

/* ═══════════════════════════════════════
   [SECTION: CSS - FORM LINE ROWS]
   ═══════════════════════════════════════ */
.form-line-row {
  display: grid;
  grid-template-columns: 1fr 70px 60px 90px 60px 30px;
  gap: 8px; align-items: center;
  background: var(--bg2); padding: 8px;
  border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px;
}
.mj-line-row {
  display: grid;
  grid-template-columns: 1fr 100px 100px 30px;
  gap: 8px; align-items: center;
  background: var(--bg2); padding: 8px;
  border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px;
}
.so-to-inv-row {
  display: grid;
  grid-template-columns: 1fr 55px 85px 55px auto;
  gap: 8px; align-items: center;
  background: var(--bg2); padding: 10px;
  border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 8px; font-size: 11px;
}

/* ═══════════════════════════════════════
   [SECTION: CSS - RESPONSIVE MOBILE]
   ═══════════════════════════════════════ */
@media(max-width: 650px) {
  /* Content padding lebih kecil di HP */
  #content { padding: 12px; }

  /* Topbar: sembunyikan email user di HP */
  .t-user { display: none; }

  /* Form line rows */
  .form-line-row { grid-template-columns: 1fr 1fr 30px; }
  .form-line-row > *:nth-child(1) { grid-column: 1 / 3; }
  .form-line-row > *:nth-child(6) { grid-column: 3 / 4; grid-row: 1 / 2; }
  .form-line-row > *:nth-child(2) { grid-column: 1 / 2; }
  .form-line-row > *:nth-child(3) { grid-column: 2 / 4; }
  .form-line-row > *:nth-child(4) { grid-column: 1 / 2; }
  .form-line-row > *:nth-child(5) { grid-column: 2 / 4; }

  .mj-line-row { grid-template-columns: 1fr 1fr 30px; }
  .mj-line-row > *:nth-child(1) { grid-column: 1 / 3; }
  .mj-line-row > *:nth-child(4) { grid-column: 3 / 4; grid-row: 1 / 2; }
  .mj-line-row > *:nth-child(2) { grid-column: 1 / 2; }
  .mj-line-row > *:nth-child(3) { grid-column: 2 / 4; }

  .so-to-inv-row { grid-template-columns: 1fr 1fr; }
  .so-to-inv-row > *:nth-child(1) { grid-column: 1 / -1; font-weight: 700; color: var(--accent2); }
  .so-to-inv-row > *:nth-child(2) { grid-column: 1 / 2; }
  .so-to-inv-row > *:nth-child(3) { grid-column: 2 / 3; }
  .so-to-inv-row > *:nth-child(4) { grid-column: 1 / 2; }
  .so-to-inv-row > *:nth-child(5) { grid-column: 2 / 3; font-weight: 700; font-size: 13px; }

  /* Modal: fullscreen di mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%; max-height: 95vh;
    border-radius: 16px 16px 0 0;
  }

  /* Toast: lebih lebar di mobile */
  .toast { white-space: normal; text-align: center; width: 90%; }

  /* Sibyl modal: fullscreen di mobile */
  .sibyl-modal-window { width: 100%; height: 100%; border-radius: 0; }
}
