/* ============================================================
   PLUS HAIR CO. — Financial Dashboard
   Aesthetic: "Institutional Capital" — Mercury × Linear
   ============================================================ */

:root {
  /* Surface palette */
  --surface-0: #0c1222;
  --surface-1: #111827;
  --surface-2: #1a2234;
  --surface-3: #232f43;
  --surface-4: #2c3a52;

  /* Content background */
  --canvas: #f8f7f4;
  --canvas-raised: #ffffff;
  --canvas-sunken: #f0eeea;
  --canvas-border: #e8e5df;

  /* Text */
  --text-primary: #1a1a1a;
  --text-secondary: #6b6560;
  --text-tertiary: #9c9690;
  --text-inverse: #f0eeea;
  --text-inverse-muted: #8896ab;

  /* Accent — warm gold */
  --accent: #c9a84c;
  --accent-dim: rgba(201, 168, 76, 0.15);

  /* Semantic */
  --deposit: #1a7a4c;
  --deposit-bg: #edf7f0;
  --deposit-border: #b8e0c8;
  --withdrawal: #b44632;
  --withdrawal-bg: #fdf2f0;
  --withdrawal-border: #e8bfb8;

  /* Interactive */
  --link: #2563a8;
  --link-hover: #1a4878;
  --focus-ring: rgba(37, 99, 168, 0.25);

  /* Spacing */
  --sidebar-w: 260px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.03);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-modal: 0 24px 80px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.12);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--canvas);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid var(--surface-3);
  transition: transform 0.35s var(--ease-out);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 22px 20px;
  border-bottom: 1px solid var(--surface-3);
}

.brand-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #a88a32);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Instrument Serif", serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--surface-1);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-inverse);
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-inverse-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 1px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-inverse-muted);
  padding: 8px 12px 6px;
  margin-bottom: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-inverse-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text-inverse);
}
.nav-item.active {
  background: var(--surface-3);
  color: var(--text-inverse);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active .nav-icon { opacity: 1; }

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-inverse-muted);
}
.sidebar-meta .nav-icon { width: 15px; height: 15px; }
.sidebar-badge {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 8px;
  border-radius: 4px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Top Bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--canvas);
  border-bottom: 1px solid var(--canvas-border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(248, 247, 244, 0.85);
}

.mobile-menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: 6px;
}
.mobile-menu-btn:hover { background: var(--canvas-sunken); }

.topbar-left { display: flex; align-items: baseline; gap: 12px; }

.page-title {
  font-family: "Instrument Serif", serif;
  font-size: 24px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.page-breadcrumb {
  font-size: 13px;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--deposit);
  box-shadow: 0 0 0 2px var(--deposit-bg);
  animation: pulse-dot 2.5s infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px var(--deposit-bg); }
  50% { box-shadow: 0 0 0 5px rgba(26, 122, 76, 0.1); }
}

/* ============================================================
   TAB CONTENT
   ============================================================ */
.tab-content {
  display: none;
  padding: 28px 32px 16px;
  flex: 1;
  animation: fadeIn 0.3s var(--ease-out);
}
.tab-content.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   METRIC CARDS
   ============================================================ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--canvas-raised);
  border: 1px solid var(--canvas-border);
  border-radius: var(--radius-md);
  padding: 20px 22px 16px;
  transition: box-shadow 0.2s ease, transform 0.2s var(--ease-out);
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--canvas-border);
  transition: background 0.2s ease;
}
.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.metric-deposit::before { background: var(--deposit); }
.metric-withdrawal::before { background: var(--withdrawal); }
.metric-balance::before { background: var(--accent); }

.metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.metric-value {
  font-family: "DM Mono", "SF Mono", monospace;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.metric-deposit .metric-value { color: var(--deposit); }
.metric-withdrawal .metric-value { color: var(--withdrawal); }

.metric-footer {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* ============================================================
   CONTROLS BAR
   ============================================================ */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrapper {
  flex: 1;
  min-width: 220px;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--canvas-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--canvas-raised);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search::placeholder { color: var(--text-tertiary); }
#search:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.filter-wrapper {
  position: relative;
}
.filter-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
#typeFilter {
  padding: 9px 14px 9px 32px;
  border: 1px solid var(--canvas-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--canvas-raised);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239c9690' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  transition: border-color 0.15s;
}
#typeFilter:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.row-count {
  font-size: 12.5px;
  color: var(--text-tertiary);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-container {
  background: var(--canvas-raised);
  border: 1px solid var(--canvas-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--canvas-sunken);
  position: sticky;
  top: 0;
  z-index: 2;
}
th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--canvas-border);
  transition: color 0.15s;
}
th:hover { color: var(--text-primary); }
th[data-sort]::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  vertical-align: middle;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239c9690' stroke-width='1.5'%3E%3Cpath d='M4 4l2-2 2 2M4 8l2 2 2-2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  opacity: 0.5;
}
th.sort-asc::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%231a1a1a' stroke-width='2'%3E%3Cpath d='M4 7l2-3 2 3'/%3E%3C/svg%3E");
  opacity: 1;
}
th.sort-desc::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%231a1a1a' stroke-width='2'%3E%3Cpath d='M4 5l2 3 2-3'/%3E%3C/svg%3E");
  opacity: 1;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--canvas-border);
  vertical-align: middle;
  color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tr { transition: background 0.1s ease; }
tr:hover { background: var(--canvas-sunken); }

.num {
  text-align: right;
  font-family: "DM Mono", "SF Mono", monospace;
  font-size: 12.5px;
  letter-spacing: -0.01em;
}
.withdrawal { color: var(--withdrawal); }
.deposit { color: var(--deposit); }

.ref-link {
  color: var(--link);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.ref-link:hover {
  background: rgba(37, 99, 168, 0.08);
  color: var(--link-hover);
}
.ref-no-file {
  color: var(--text-tertiary);
  cursor: default;
  text-decoration: none;
}

.fx-info {
  font-size: 11.5px;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-family: "DM Mono", monospace;
}

/* Summary bar — hidden but kept for JS compat */
.summary-bar { display: none; }

/* ============================================================
   DOCUMENT CARDS
   ============================================================ */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  max-width: 800px;
}

.doc-card {
  background: var(--canvas-raised);
  border: 1px solid var(--canvas-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, transform 0.2s var(--ease-out);
  overflow: hidden;
}
.doc-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.doc-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 0;
}
.doc-type-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--withdrawal);
  background: var(--withdrawal-bg);
  border: 1px solid var(--withdrawal-border);
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}
.doc-type-label {
  font-size: 11.5px;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

.doc-card-body {
  padding: 14px 20px 16px;
  flex: 1;
}
.doc-card-body h3 {
  font-family: "Instrument Serif", serif;
  font-size: 18px;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
}
.doc-card-body p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.doc-card-footer {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--canvas-border);
  background: var(--canvas-sunken);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--surface-1);
  color: var(--text-inverse);
}
.btn-primary:hover {
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--canvas-border);
}
.btn-ghost:hover {
  background: var(--canvas-sunken);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

.btn-sm { padding: 6px 10px; font-size: 12.5px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-icon:hover {
  background: var(--canvas-sunken);
  color: var(--text-primary);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 24, 0.55);
  backdrop-filter: blur(4px);
  animation: fadeBackdrop 0.2s ease;
}
@keyframes fadeBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  position: relative;
  background: var(--canvas-raised);
  border-radius: var(--radius-lg);
  width: 90vw;
  max-width: 900px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  animation: modalSlideUp 0.3s var(--ease-out);
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--canvas-border);
}
.modal-title-group {
  display: flex; align-items: center; gap: 10px;
}
.modal-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--withdrawal);
  background: var(--withdrawal-bg);
  border: 1px solid var(--withdrawal-border);
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}
.modal-header h3 {
  font-family: "Instrument Serif", serif;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-primary);
}
.modal-actions { display: flex; gap: 6px; align-items: center; }

.modal-body {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 20px;
  background: var(--canvas-sunken);
}
.modal-body canvas {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.modal-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--canvas-border);
}

.page-info {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
  min-width: 100px;
  text-align: center;
}

/* ============================================================
   DIGITAL PRESENCE
   ============================================================ */
.digital-section {
  margin-bottom: 32px;
}

.digital-section-title {
  font-family: "Instrument Serif", serif;
  font-size: 20px;
  font-weight: 400;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--canvas-border);
}
.digital-section-title svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.digital-grid {
  max-width: 1000px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.digital-card {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.digital-card:hover {
  border-color: var(--card-hover-color, #1877F2);
}

.digital-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fb-badge {
  color: #1877F2;
  background: rgba(24, 119, 242, 0.1);
  border: 1px solid rgba(24, 119, 242, 0.2);
}

.post-badge {
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(201, 168, 76, 0.25);
}

.btn-fb {
  color: #1877F2;
}
.btn-fb svg {
  stroke: #1877F2;
}
.digital-card:hover .btn-fb {
  background: rgba(24, 119, 242, 0.08);
}

.btn-post {
  color: var(--text-secondary);
}
.digital-post:hover .btn-post {
  color: var(--accent);
  background: var(--accent-dim);
}
.digital-post:hover .btn-post svg {
  stroke: var(--accent);
}

.web-badge {
  color: #10B981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.shopee-badge {
  color: #EE4D2D;
  background: rgba(238, 77, 45, 0.1);
  border: 1px solid rgba(238, 77, 45, 0.2);
}

.ig-badge {
  color: #E4405F;
  background: rgba(228, 64, 95, 0.1);
  border: 1px solid rgba(228, 64, 95, 0.2);
}

.tiktok-badge {
  color: #ffffff;
  background: #000000;
  border: 1px solid rgba(0, 0, 0, 0.3);
}
.tiktok-badge svg {
  fill: #ffffff;
}

.digital-card:has(.web-badge) { --card-hover-color: #10B981; }
.digital-card:has(.shopee-badge) { --card-hover-color: #EE4D2D; }
.digital-card:has(.ig-badge) { --card-hover-color: #E4405F; }
.digital-card:has(.tiktok-badge) { --card-hover-color: #000000; }

.btn-web {
  color: #10B981;
}
.btn-web svg {
  stroke: #10B981;
}
.digital-card:hover .btn-web {
  background: rgba(16, 185, 129, 0.08);
}

.btn-shopee {
  color: #EE4D2D;
}
.btn-shopee svg {
  stroke: #EE4D2D;
}
.digital-card:hover .btn-shopee {
  background: rgba(238, 77, 45, 0.08);
}

.btn-ig {
  color: #E4405F;
}
.btn-ig svg {
  stroke: #E4405F;
}
.digital-card:hover .btn-ig {
  background: rgba(228, 64, 95, 0.08);
}

.btn-tiktok {
  color: #000000;
}
.btn-tiktok svg {
  stroke: #000000;
}
.digital-card:hover .btn-tiktok {
  background: rgba(0, 0, 0, 0.06);
}

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  border-top: 1px solid var(--canvas-border);
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
  margin-top: auto;
}

/* ============================================================
   MOBILE TRANSACTION CARDS (hidden on desktop)
   ============================================================ */
.mobile-cards {
  display: none;
}

.mobile-tx-card {
  background: var(--canvas-raised);
  border: 1px solid var(--canvas-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.mobile-tx-card:active {
  box-shadow: var(--shadow-md);
}

.mobile-tx-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 8px;
}
.mobile-tx-particulars {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.mobile-tx-amount {
  font-family: "DM Mono", monospace;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.mobile-tx-amount.is-deposit { color: var(--deposit); }
.mobile-tx-amount.is-deposit::before { content: '+'; }
.mobile-tx-amount.is-withdrawal { color: var(--withdrawal); }
.mobile-tx-amount.is-withdrawal::before { content: '−'; }

.mobile-tx-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12px;
  color: var(--text-tertiary);
  align-items: center;
}
.mobile-tx-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.mobile-tx-meta-label {
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.mobile-tx-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--canvas-border);
  gap: 8px;
}
.mobile-tx-balance {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--text-secondary);
}
.mobile-tx-balance span {
  font-weight: 500;
}

.mobile-tx-ref {
  font-size: 12.5px;
}
.mobile-tx-ref .ref-link {
  padding: 6px 10px;
  margin: -6px -10px;
  font-size: 13px;
}

.mobile-tx-fx {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Safe area insets for notched phones */
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    transition: transform 0.35s var(--ease-out), box-shadow 0.35s ease;
    padding-top: env(safe-area-inset-top);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(0,0,0,0.2);
  }

  .mobile-menu-btn {
    display: flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .main { margin-left: 0; }

  .topbar {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    gap: 8px;
  }
  .topbar-left { gap: 8px; flex: 1; min-width: 0; }
  .page-title {
    font-size: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .page-breadcrumb { display: none; }

  .tab-content { padding: 16px; }

  /* Metric cards — 2 columns, compact */
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .metric-card { padding: 14px 16px 12px; }
  .metric-label { font-size: 10.5px; margin-bottom: 4px; }
  .metric-value { font-size: 17px; }
  .metric-footer { font-size: 11px; margin-top: 4px; }

  /* Controls — stacked, full width, bigger touch targets */
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .search-wrapper { min-width: 100%; }
  #search {
    padding: 12px 12px 12px 40px;
    font-size: 16px; /* prevents iOS zoom */
    border-radius: var(--radius-md);
  }
  .search-icon { left: 14px; }
  #typeFilter {
    width: 100%;
    padding: 12px 36px 12px 36px;
    font-size: 16px; /* prevents iOS zoom */
    border-radius: var(--radius-md);
  }
  .filter-icon { left: 12px; }
  .row-count {
    text-align: center;
    font-size: 12px;
    padding: 4px 0;
  }

  /* Hide desktop table, show mobile cards */
  .table-container { display: none; }
  .mobile-cards { display: block; }

  /* Document cards */
  .doc-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
  .doc-card-body h3 { font-size: 16px; }
  .doc-card-footer {
    flex-wrap: wrap;
  }
  .doc-card-footer .btn {
    min-height: 44px;
    flex: 1;
    justify-content: center;
    font-size: 14px;
  }

  /* Digital grid */
  .digital-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
  .digital-section-title { font-size: 18px; }

  /* Nav items — bigger touch targets */
  .nav-item {
    padding: 14px 16px;
    font-size: 15px;
    gap: 12px;
    min-height: 48px;
  }
  .nav-icon { width: 20px; height: 20px; }
  .nav-section-label { padding: 10px 16px 8px; font-size: 11px; }

  /* Footer */
  .app-footer {
    flex-direction: column;
    gap: 4px;
    text-align: center;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    font-size: 11px;
  }

  /* Overlay for sidebar */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Modal — full screen on mobile */
  .modal-content {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    animation: modalSlideUpMobile 0.3s var(--ease-out);
  }
  @keyframes modalSlideUpMobile {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
  }
  .modal-header {
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top));
    gap: 8px;
  }
  .modal-header h3 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .modal-body { padding: 12px; }
  .modal-footer {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    gap: 8px;
  }
  .modal-footer .btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
  }
  .modal-actions .btn-ghost {
    min-height: 40px;
    padding: 8px 12px;
  }
  .btn-icon {
    width: 44px;
    height: 44px;
  }
  .page-info { font-size: 13px; }

  /* Sidebar brand compact */
  .sidebar-brand { padding: 20px 18px 16px; }
  .sidebar-footer { padding: 14px 18px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  /* Very small phones */
  .metrics-grid { grid-template-columns: 1fr; gap: 8px; }
  .metric-card {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
  }
  .metric-value { font-size: 16px; }
  .tab-content { padding: 12px; }
  .topbar { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .page-title { font-size: 18px; }
  .topbar-status { display: none; }

  .mobile-tx-card { padding: 14px; }
  .mobile-tx-particulars { font-size: 13px; }
  .mobile-tx-amount { font-size: 14px; }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets everywhere */
  .ref-link {
    padding: 8px 10px;
    margin: -8px -10px;
  }
  .nav-item { min-height: 48px; }

  /* Disable hover effects that feel wrong on touch */
  .metric-card:hover {
    box-shadow: none;
    transform: none;
  }
  .doc-card:hover {
    box-shadow: none;
    transform: none;
  }
  /* Use active states instead */
  .metric-card:active {
    box-shadow: var(--shadow-md);
    transform: scale(0.98);
  }
  .doc-card:active {
    box-shadow: var(--shadow-md);
    transform: scale(0.98);
  }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--canvas-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* Selection */
::selection { background: var(--accent-dim); color: var(--text-primary); }
