:root {
  --bg: #0b141a;
  --panel: #111b21;
  --panel-2: #202c33;
  --accent: #00a884;
  --accent-dark: #008069;
  --in-bubble: #202c33;
  --out-bubble: #005c4b;
  --text: #e9edef;
  --muted: #8696a0;
  --danger: #f15c6d;
  --border: #2a3942;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ============ AUTH PAGES ============ */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #0b141a 0%, #14352f 100%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.brand {
  text-align: center;
  margin-bottom: 24px;
}
.brand .logo {
  width: 60px; height: 60px;
  border-radius: 16px;
  background: var(--accent);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 30px;
  margin-bottom: 12px;
}
.brand h1 { font-size: 22px; font-weight: 600; }
.brand p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
}
.field input:focus { outline: none; border-color: var(--accent); }

.btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:hover { opacity: .9; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-google {
  background: #fff; color: #333;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 12px;
}
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 12px; margin: 18px 0;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.auth-alt a { color: var(--accent); text-decoration: none; font-weight: 600; }
.msg-err {
  background: rgba(241,92,109,.12);
  border: 1px solid rgba(241,92,109,.4);
  color: var(--danger);
  padding: 10px 12px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px; display: none;
}

/* ============ CHAT APP ============ */
.app-shell { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 320px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.side-head {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.side-head .info { min-width: 0; }
.side-head .info .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-head .info .email { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-scroll { flex: 1; overflow-y: auto; padding: 14px; }
.side-title { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 6px 2px 10px; }
.total-card {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  border-radius: 14px; padding: 18px; margin-bottom: 18px;
}
.total-card .label { font-size: 12px; opacity: .85; }
.total-card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }

.rek-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 12px; background: var(--panel-2);
  border-radius: 10px; margin-bottom: 8px;
}
.rek-item .rn { font-size: 14px; }
.rek-item .rv { font-size: 14px; font-weight: 600; }
.rek-item .rv.neg { color: var(--danger); }
.empty-note { color: var(--muted); font-size: 13px; text-align: center; padding: 20px 0; }

.side-foot { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.side-foot button {
  flex: 1; padding: 9px; font-size: 13px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); cursor: pointer;
}
.side-foot button:hover { background: #2a3942; }
.side-foot .danger { color: var(--danger); }

/* Chat area */
.chat {
  flex: 1; display: flex; flex-direction: column;
  background: #0b141a;
  background-image: linear-gradient(rgba(11,20,26,.95), rgba(11,20,26,.95));
}
.chat-head {
  padding: 14px 20px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.chat-head .bot-ava {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.chat-head .t { flex: 1; }
.chat-head .t .n { font-weight: 600; }
.chat-head .t .s { font-size: 12px; color: var(--muted); }
.hamburger { display: none; background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer; }
.head-nav {
  margin-left: auto; text-decoration: none;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.head-nav:hover { background: #2a3942; }

/* ============ HALAMAN RIWAYAT / TABEL ============ */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.page-head {
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
}
.page-head .logo-sm {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.page-head h1 { font-size: 18px; font-weight: 600; flex: 1; }
.page-body { flex: 1; padding: 20px 24px; max-width: 1100px; width: 100%; margin: 0 auto; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button {
  background: none; border: none; color: var(--muted); padding: 9px 16px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.seg button.active { background: var(--accent); color: #fff; }
.custom-range { display: none; gap: 8px; align-items: center; flex-wrap: wrap; }
.custom-range.show { display: flex; }
.custom-range input[type=date] {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; color-scheme: dark;
}
.custom-range .sep { color: var(--muted); font-size: 13px; }
.btn-sm { padding: 8px 14px; border-radius: 8px; border: none; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-sm.apply { background: var(--accent); color: #fff; }
.btn-sm.ghost { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }

.summary-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.sum-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.sum-card .lbl { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sum-card .val { font-size: 20px; font-weight: 700; margin-top: 6px; }
.sum-card.in .val { color: #4ad991; }
.sum-card.out .val { color: var(--danger); }
.sum-card.net .val { color: var(--text); }

.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
table.trx { width: 100%; border-collapse: collapse; min-width: 640px; }
table.trx th, table.trx td { padding: 12px 14px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--border); }
table.trx th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; position: sticky; top: 0; background: var(--panel); }
table.trx tbody tr:hover { background: var(--panel-2); }
table.trx td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill.in { background: rgba(74,217,145,.15); color: #4ad991; }
.pill.out { background: rgba(241,92,109,.15); color: var(--danger); }
.trx td .amt-in { color: #4ad991; }
.trx td .amt-out { color: var(--danger); }
.del-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.del-btn:hover { background: rgba(241,92,109,.15); color: var(--danger); }
.tbl-empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.cat-cell { display: flex; flex-direction: column; }
.cat-cell .memo { font-size: 12px; color: var(--muted); margin-top: 2px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 780px) {
  .page-body { padding: 14px; }
  .summary-row { grid-template-columns: 1fr; }
  .page-head { padding: 12px 14px; }
}

.messages { flex: 1; overflow-y: auto; padding: 20px 8%; display: flex; flex-direction: column; gap: 8px; }
.bubble {
  max-width: 78%; padding: 8px 12px; border-radius: 10px;
  font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
  position: relative;
}
.bubble .time { font-size: 10.5px; color: var(--muted); float: right; margin: 6px 0 -2px 10px; }
.bubble.user { align-self: flex-end; background: var(--out-bubble); border-top-right-radius: 2px; }
.bubble.bot { align-self: flex-start; background: var(--in-bubble); border-top-left-radius: 2px; }
.bubble b { font-weight: 700; }

.quick-row { padding: 8px 8% 0; display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); padding: 6px 14px; border-radius: 16px;
  font-size: 13px; cursor: pointer;
}
.chip:hover { background: #2a3942; }

.composer {
  padding: 14px 8%; background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: flex-end;
}
.composer textarea {
  flex: 1; resize: none; max-height: 120px;
  padding: 12px 14px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 22px;
  color: var(--text); font-size: 15px; font-family: inherit; line-height: 1.4;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.send-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); border: none; color: #fff;
  font-size: 20px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.send-btn:disabled { opacity: .5; cursor: default; }

.typing { align-self: flex-start; color: var(--muted); font-size: 13px; padding: 4px 12px; font-style: italic; }

/* Mobile */
.backdrop { display: none; }
@media (max-width: 780px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 30;
    transform: translateX(-100%); transition: transform .25s;
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: block; }
  .messages, .composer, .quick-row { padding-left: 5%; padding-right: 5%; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; }
}
