:root {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --danger: #ef4444;
  --unread: #f59e0b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 1.2rem; font-weight: 700; letter-spacing: .3px; }
.brand span { color: var(--primary); }

/* ---------- Tombol ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  font-family: inherit;
  transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #0f172a; font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); color: #0f172a; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.layout { display: flex; flex: 1; min-height: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 300px;
  min-width: 300px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-empty { color: var(--text-dim); text-align: center; padding: 24px 8px; font-size: .9rem; }

.address-item {
  position: relative;
  text-align: left;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: all .15s;
}
.address-item:hover { border-color: var(--primary); }
.address-item.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.address-label { font-weight: 600; font-size: .85rem; word-break: break-all; padding-right: 34px; }
.address-meta { color: var(--text-dim); font-size: .75rem; margin-top: 4px; }
.address-unread {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--unread);
  color: #0f172a;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 999px;
  min-width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px;
}

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.empty-state {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-dim);
  text-align: center;
  gap: 6px;
}
.empty-icon { font-size: 3.5rem; }
.empty-state h2 { color: var(--text); margin: 0; }
.empty-state p { margin: 0; font-size: .9rem; }

.inbox { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.inbox-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.inbox-header h2 { margin: 0; font-size: 1rem; word-break: break-all; }

.message-list { flex: 1; overflow-y: auto; padding: 12px 20px; display: flex; flex-direction: column; gap: 8px; }
.list-empty { color: var(--text-dim); text-align: center; padding: 40px; }

.message-item {
  position: relative;
  text-align: left;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: all .15s;
}
.message-item:hover { border-color: var(--primary); }
.message-item.unread { border-left: 3px solid var(--unread); }
.msg-sender { font-weight: 600; font-size: .85rem; padding-right: 16px; }
.msg-subject { color: var(--text-dim); font-size: .85rem; margin-top: 2px; }
.msg-time { color: var(--text-dim); font-size: .75rem; margin-top: 4px; }
.msg-dot {
  position: absolute;
  top: 12px; right: 12px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--unread);
}

/* ---------- Detail ---------- */
.detail { flex: 1; overflow-y: auto; padding: 16px 20px; }
.detail .btn { margin-bottom: 12px; }
.detail-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 860px;
}
.detail-card h2 { margin: 0 0 12px; word-break: break-word; }
.detail-meta { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; margin-bottom: 16px; }
.detail-meta span { color: var(--text-dim); }
.detail-meta b { color: var(--text); font-weight: 600; word-break: break-all; }
.detail-body { border-top: 1px solid var(--border); padding-top: 16px; word-break: break-word; line-height: 1.55; }
.detail-text { white-space: pre-wrap; font-family: inherit; margin: 0; }
.detail-iframe { width: 100%; min-height: 480px; border: none; background: #fff; border-radius: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-alt);
  border: 1px solid var(--primary);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: .85rem;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .sidebar { width: 220px; min-width: 220px; }
}

