/* =========================================================
   AllExchange — Design System
   Style: Clean fintech, light content, dark sidebar
   ========================================================= */

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --cyan:        #00c9d4;
  --cyan-dark:   #00a8b2;
  --cyan-soft:   #e0f9fa;
  --cyan-glow:   rgba(0, 201, 212, 0.18);

  /* Sidebar */
  --sidebar-bg:  #0b1120;
  --sidebar-w:   240px;

  /* Surface */
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;

  /* Text */
  --text:        #1e293b;
  --text-muted:  #64748b;
  --text-light:  #94a3b8;

  /* Border */
  --border:      #e2e8f0;
  --border-dark: #cbd5e1;

  /* Status */
  --green:       #22c55e;
  --green-soft:  #dcfce7;
  --red:         #ef4444;
  --red-soft:    #fee2e2;
  --yellow:      #f59e0b;
  --yellow-soft: #fef3c7;
  --blue:        #3b82f6;
  --blue-soft:   #dbeafe;

  /* Status aliases */
  --success:        #22c55e;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --text-secondary: #64748b;

  /* Shadow */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:      0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.12);

  /* Radius */
  --r-sm:   6px;
  --r:      10px;
  --r-lg:   16px;
  --r-full: 9999px;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── Typography ───────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.3rem; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 1.05rem; font-weight: 600; }
h4 { font-size: .9rem;   font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }

p { color: var(--text-muted); font-size: .93rem; }

/* ── App Shell ────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-logo {
  padding: 22px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--cyan), var(--cyan-dark));
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .85rem;
  color: #fff;
  letter-spacing: -.03em;
  flex-shrink: 0;
}
.sidebar-logo .logo-name {
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  letter-spacing: -.01em;
}
.sidebar-logo .logo-sub {
  font-size: .7rem;
  color: rgba(255,255,255,.35);
  margin-top: 1px;
}

.sidebar-section {
  padding: 18px 12px 4px;
}
.sidebar-section-label {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.25);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.55);
  font-size: .875rem;
  font-weight: 450;
  transition: all .15s ease;
  cursor: pointer;
  margin-bottom: 2px;
  position: relative;
}
.nav-item svg {
  width: 17px; height: 17px;
  flex-shrink: 0;
  opacity: .7;
}
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.85);
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--cyan-glow);
  color: var(--cyan);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; color: var(--cyan); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--cyan);
  border-radius: 0 3px 3px 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--cyan);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  transition: background .15s;
  cursor: pointer;
}
.sidebar-user:hover { background: rgba(255,255,255,.06); }
.sidebar-user .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user .user-info .user-name {
  font-size: .8rem;
  font-weight: 600;
  color: rgba(255,255,255,.8);
  line-height: 1.2;
}
.sidebar-user .user-info .user-role {
  font-size: .68rem;
  color: rgba(255,255,255,.3);
}
.sidebar-user .logout-btn {
  margin-left: auto;
  color: rgba(255,255,255,.25);
  transition: color .15s;
}
.sidebar-user:hover .logout-btn { color: var(--red); }

/* ── Main Content ─────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.sidebar-toggle { display: none; }

.topbar-title {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.01em;
}
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: var(--text-muted);
}
.topbar-breadcrumb span { color: var(--text-light); }
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-body {
  padding: 26px 28px;
  flex: 1;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header-left h1 { margin-bottom: 3px; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.card-header {
  padding: 18px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ── Stat Cards ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: .06;
  transform: translate(20px, -20px);
}
.stat-card.cyan::after  { background: var(--cyan); }
.stat-card.green::after { background: var(--green); }
.stat-card.red::after   { background: var(--red); }
.stat-card.blue::after  { background: var(--blue); }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.stat-icon svg { width: 19px; height: 19px; }
.stat-icon.cyan   { background: var(--cyan-soft);   color: var(--cyan-dark); }
.stat-icon.green  { background: var(--green-soft);  color: #16a34a; }
.stat-icon.red    { background: var(--red-soft);    color: #dc2626; }
.stat-icon.blue   { background: var(--blue-soft);   color: #2563eb; }
.stat-icon.yellow { background: var(--yellow-soft); color: #d97706; }

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 5px;
}
.stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-change {
  font-size: .72rem;
  font-weight: 600;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.stat-change.up   { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s ease;
  white-space: nowrap;
  line-height: 1;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--cyan);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,201,212,.3);
}
.btn-primary:hover {
  background: var(--cyan-dark);
  box-shadow: 0 4px 14px rgba(0,201,212,.4);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-dark);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: #fca5a5;
}
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 5px 11px; font-size: .78rem; }
.btn-lg { padding: 12px 24px; font-size: .95rem; }
.btn-icon {
  padding: 7px;
  border-radius: var(--r-sm);
}
.btn-icon svg { width: 16px; height: 16px; }
.btn:disabled,
.btn.disabled {
  opacity: .5;
  pointer-events: none;
}

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-label .req { color: var(--red); margin-left: 2px; }

.form-control,
.form-input,
.form-select {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .88rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control::placeholder,
.form-input::placeholder,
.form-select::placeholder { color: var(--text-light); }
.form-control:hover,
.form-input:hover,
.form-select:hover { border-color: var(--border-dark); }
.form-control:focus,
.form-input:focus,
.form-select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-glow);
}
.form-control:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}
.form-control:disabled,
.form-input:disabled,
.form-select:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

select.form-control,
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-error {
  font-size: .75rem;
  color: var(--red);
  margin-top: 4px;
}
.form-control.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .form-control {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  flex: 1;
}
.input-group .btn {
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.input-group-prefix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  color: var(--text-muted);
  font-size: .83rem;
}

/* ── Tables ───────────────────────────────────────────── */
.table-wrap,
.data-table {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  background: var(--surface-2);
  padding: 11px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  font-size: .865rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }

.td-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge-green  { background: var(--green-soft);  color: #16a34a; }
.badge-red    { background: var(--red-soft);    color: #dc2626; }
.badge-yellow { background: var(--yellow-soft); color: #d97706; }
.badge-blue   { background: var(--blue-soft);   color: #2563eb; }
.badge-cyan   { background: var(--cyan-soft);   color: var(--cyan-dark); }
.badge-gray   { background: #f1f5f9;            color: var(--text-muted); }

/* ── Chat UI ──────────────────────────────────────────── */
.chat-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  height: calc(100vh - 58px);
  overflow: hidden;
}

.chat-list {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-list-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-list-header h2 { font-size: .95rem; margin-bottom: 10px; }
.chat-list-body {
  overflow-y: auto;
  flex: 1;
}

.chat-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--cyan-soft); }
.chat-item.active .chat-item-name { color: var(--cyan-dark); }
.chat-item .chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.chat-item-meta { flex: 1; min-width: 0; }
.chat-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-item-name {
  font-size: .86rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item-time {
  font-size: .7rem;
  color: var(--text-light);
  flex-shrink: 0;
}
.chat-item-preview {
  font-size: .78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.chat-unread {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  color: #fff;
  font-size: .63rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
}

.chat-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-2);
}
.chat-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-header-info .chat-user-name {
  font-size: .95rem;
  font-weight: 700;
}
.chat-header-info .chat-user-meta {
  font-size: .75rem;
  color: var(--text-muted);
}
.chat-header-actions { margin-left: auto; display: flex; gap: 6px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-row {
  display: flex;
  gap: 8px;
  max-width: 70%;
}
.msg-row.out {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-row.in { align-self: flex-start; }

.msg-bubble {
  padding: 9px 13px;
  border-radius: var(--r-lg);
  font-size: .875rem;
  line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
}
.msg-row.in .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg);
  color: var(--text);
}
.msg-row.out .msg-bubble {
  background: var(--cyan);
  color: #fff;
  border-radius: var(--r-lg) 4px var(--r-lg) var(--r-lg);
}
.msg-time {
  font-size: .67rem;
  color: var(--text-light);
  align-self: flex-end;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.msg-row.out .msg-time { color: rgba(255,255,255,.6); }

.msg-image {
  max-width: 220px;
  border-radius: var(--r);
  cursor: pointer;
  transition: opacity .15s;
}
.msg-image:hover { opacity: .85; }

.msg-file {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  min-width: 200px;
  cursor: pointer;
  transition: background .12s;
}
.msg-file:hover { background: var(--surface-2); }
.msg-file-icon {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  background: var(--blue-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--blue);
  flex-shrink: 0;
}
.msg-file-icon svg { width: 17px; height: 17px; }
.msg-file-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
}
.msg-file-size { font-size: .7rem; color: var(--text-muted); }

.date-divider {
  text-align: center;
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-light);
  position: relative;
  margin: 8px 0;
}
.date-divider::before, .date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}
.date-divider::before { left: 0; }
.date-divider::after  { right: 0; }
.date-divider span {
  background: var(--surface-2);
  padding: 0 10px;
  position: relative;
  z-index: 1;
}

.chat-input-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}
.chat-input-bar .form-control {
  border-radius: var(--r-lg);
  padding: 10px 14px;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}
.chat-send-btn {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: var(--cyan);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(0,201,212,.3);
}
.chat-send-btn:hover {
  background: var(--cyan-dark);
  box-shadow: 0 4px 14px rgba(0,201,212,.45);
  transform: scale(1.05);
}
.chat-send-btn svg { width: 17px; height: 17px; }

/* ── Accounting ───────────────────────────────────────── */
.amount-positive { color: var(--green); font-weight: 700; }
.amount-negative { color: var(--red);   font-weight: 700; }
.amount-transfer { color: var(--blue);  font-weight: 700; }

.account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.account-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), #3b82f6);
}
.account-currency {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .08em;
  margin-bottom: 6px;
}
.account-balance {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--text);
}
.account-name {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Filters Bar ──────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.filters-bar .form-control {
  width: auto;
}

/* ── Pagination ───────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-link {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .12s;
  border: 1px solid transparent;
}
.page-link:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.page-link.active {
  background: var(--cyan);
  color: #fff;
  border-color: var(--cyan);
}
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ── Alerts ───────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 16px;
  border-radius: var(--r);
  font-size: .86rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--green-soft);  color: #15803d; border-color: #bbf7d0; }
.alert-error   { background: var(--red-soft);    color: #b91c1c; border-color: #fca5a5; }
.alert-info    { background: var(--cyan-soft);   color: var(--cyan-dark); border-color: #a5f3f7; }
.alert-warning { background: var(--yellow-soft); color: #92400e; border-color: #fde68a; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px) scale(.98);
  transition: transform .2s;
}
.modal-overlay.show .modal { transform: translateY(0) scale(1); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background .12s, color .12s;
}
.modal-close:hover { background: var(--red-soft); color: var(--red); }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Login Page ───────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  background: var(--sidebar-bg);
  overflow: hidden;
  position: relative;
}
.login-bg-pattern {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(0,201,212,.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(59,130,246,.06) 0%, transparent 50%);
  pointer-events: none;
}
.login-left {
  width: 55%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  position: relative;
  z-index: 1;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 60px;
}
.login-brand .brand-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--cyan), var(--cyan-dark));
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: 1rem;
  color: #fff;
}
.login-brand .brand-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
}
.login-brand .brand-name span { color: var(--cyan); }

.login-hero-title {
  font-size: 2.4rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
  letter-spacing: -.03em;
  margin-bottom: 16px;
}
.login-hero-title .accent { color: var(--cyan); }
.login-hero-sub {
  font-size: 1rem;
  color: rgba(255,255,255,.45);
  line-height: 1.6;
  max-width: 360px;
}

.login-features {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,.55);
  font-size: .85rem;
}
.login-feature svg {
  width: 16px; height: 16px;
  color: var(--cyan);
  flex-shrink: 0;
}

.login-right {
  width: 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(255,255,255,.03);
  border-left: 1px solid rgba(255,255,255,.06);
  position: relative;
  z-index: 1;
}

.login-card {
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}
.login-card-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -.02em;
}
.login-card-sub {
  font-size: .83rem;
  color: var(--text-muted);
  margin-bottom: 30px;
}
.login-divider {
  text-align: center;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-light);
  margin: 16px 0;
  position: relative;
}
.login-divider::before, .login-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 30px);
  height: 1px;
  background: var(--border);
}
.login-divider::before { left: 0; }
.login-divider::after  { right: 0; }

.btn-login {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: .9rem;
}

/* ── Empty State ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px; height: 48px;
  color: var(--text-light);
  margin: 0 auto 16px;
}
.empty-state h3 {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-state p { font-size: .84rem; max-width: 260px; margin: 0 auto; }

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── Utilities ────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: .8rem; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
  .login-left  { display: none; }
  .login-right { width: 100%; border-left: none; background: var(--sidebar-bg); }

  /* Sidebar mobile drawer */
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 199;
  }
  .sidebar-backdrop.show { display: block; }
  .main-content { margin-left: 0; overflow-x: hidden; }

  /* Prevent tables from pushing the page wider */
  .card { max-width: 100%; }
  .table-wrap,
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-responsive table,
  .table-wrap table { min-width: 600px; }

  /* Chat */
  .chat-shell { grid-template-columns: 1fr; }
  .chat-list { display: none; }
  .chat-list.show { display: flex; position: fixed; inset: 0; z-index: 150; }

  /* Grids */
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .acct-grid { grid-template-columns: 1fr !important; }
  .form-grid { grid-template-columns: 1fr !important; }

  /* Page header stacks on mobile */
  .page-header { flex-direction: column; align-items: flex-start; }

  /* Card header stacks */
  .card-header { flex-wrap: wrap; }
  .card-header-filters { width: 100%; flex-direction: column; }

  /* Filters: remove fixed widths, let them flex/wrap */
  .filters-bar,
  .filter-form { flex-wrap: wrap; gap: 8px; }
  .filters-bar select,
  .filters-bar input,
  .filters-bar .form-control,
  .filters-bar .form-input,
  .filters-bar .form-select,
  .filter-form select,
  .filter-form input,
  .filter-form .form-control,
  .filter-form .form-input,
  .filter-form .form-select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Input group */
  .input-group { width: 100% !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .page-body  { padding: 16px; }
  .topbar     { padding: 0 16px; }
  .grid-2     { grid-template-columns: 1fr; }

  .filters-bar,
  .filter-form { flex-direction: column; align-items: stretch; }
  .filters-bar > div,
  .filter-form > div { width: 100%; }
  .filters-bar select,
  .filters-bar input,
  .filter-form select,
  .filter-form input { width: 100% !important; }

  /* Form grids stack */
  .form-grid { grid-template-columns: 1fr !important; }

  /* Table: scroll horizontally, compact cells */
  .table-wrap,
  .data-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  thead th { padding: 8px 10px; font-size: .68rem; }
  tbody td { padding: 10px 10px; font-size: .8rem; }

  /* Topbar breadcrumb truncate */
  .topbar-breadcrumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
