  @import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');

  :root {
    --blue: #1D3E9E;
    --blue-dark: #142c73;
    --blue-tint: #EAF0FB;
    --ink: #1C2130;
    --ink-soft: #5B6273;
    --paper: #FFFFFF;
    --slab: #F4F5F8;
    --line: #E3E5EC;
    --green: #157347;
    --green-tint: #E7F5EE;
    --amber: #B4650A;
    --amber-tint: #FCF1E2;
    --red: #B02A2A;
    --red-tint: #FCEAEA;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(28,33,48,.06), 0 6px 16px rgba(28,33,48,.05);
    --shadow-lg: 0 4px 10px rgba(28,33,48,.08), 0 14px 32px rgba(28,33,48,.10);
  }

  * { box-sizing: border-box; }
  html, body {
    margin: 0; padding: 0;
    background: var(--slab);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
  }
  body { padding-bottom: 88px; }

  h1, h2, h3, .display {
    font-family: 'Barlow Condensed', 'Inter', sans-serif;
    font-weight: 700;
    letter-spacing: .01em;
    margin: 0;
  }
  svg.icon { display: block; }

  .app-header {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: #fff;
    padding: 22px 20px 30px;
    border-radius: 0 0 20px 20px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
  }
  .app-header::after {
    content: ''; position: absolute; top: -40px; right: -40px; width: 140px; height: 140px;
    border-radius: 50%; background: rgba(255,255,255,.06); pointer-events: none;
  }
  .app-header .brand {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    opacity: .85;
    position: relative;
  }
  .app-header h1 {
    font-size: 26px;
    margin-top: 2px;
    position: relative;
  }
  .header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; position: relative; }
  .header-icons { display: flex; gap: 8px; margin-top: 2px; position: relative; z-index: 3; }
  .header-icon-btn {
    width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.14);
    border: none; color: #fff; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .15s ease;
  }
  .header-icon-btn:active { background: rgba(255,255,255,.28); transform: scale(.94); }

  .balance-card {
    margin: -22px 16px 0;
    background: var(--paper);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    position: relative;
    z-index: 2;
  }
  .balance-card .label {
    font-size: 12px;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
  }
  .balance-card .amount {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 40px;
    font-weight: 700;
    color: var(--blue);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    margin-top: 2px;
  }
  .balance-card .sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

  .content { padding: 18px 16px 8px; }

  .btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
  }
  .action-btn {
    display: flex; flex-direction: row; align-items: center; justify-content: center;
    gap: 8px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 10px;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    box-shadow: var(--shadow);
    cursor: pointer;
    -webkit-user-select: none; user-select: none;
    white-space: nowrap;
  }
  .action-btn:active { transform: scale(.97); background: var(--slab); }
  .action-btn .icon { font-size: 26px; }
  .action-btn .icon-wrap { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .action-btn .btn-label { overflow: hidden; text-overflow: ellipsis; }
  .action-btn.primary { background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff; border-color: transparent; grid-column: span 2; padding: 18px 10px; font-size: 18px; box-shadow: 0 8px 20px rgba(29,62,158,.28); }
  .action-btn.primary .icon-wrap { background: rgba(255,255,255,.16); color: #fff; }
  .action-btn.received { color: var(--green); }
  .action-btn.received .icon-wrap { background: var(--green-tint); color: var(--green); }
  .action-btn.returned { color: var(--amber); }
  .action-btn.returned .icon-wrap { background: var(--amber-tint); color: var(--amber); }
  .action-btn.compact { padding: 13px 6px; gap: 6px; font-size: 13.5px; }
  .action-btn.compact .icon-wrap { width: 26px; height: 26px; }

  .link-row {
    display: flex; gap: 10px; margin-top: 12px;
  }
  .link-btn {
    flex: 1;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--blue);
    cursor: pointer;
  }

  .section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--ink-soft);
    font-weight: 700;
    margin: 22px 4px 10px;
  }

  .txn-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
  }
  .txn-card .row1 { display: flex; justify-content: space-between; align-items: baseline; }
  .txn-card .amt { font-family: 'Barlow Condensed', sans-serif; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .txn-card .amt.neg { color: var(--red); }
  .txn-card .amt.pos { color: var(--green); }
  .txn-card .amt.neutral { color: var(--ink); }
  .txn-card .cat { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
  .txn-card .meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 10px; }
  .badge {
    display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px;
    border-radius: 20px; text-transform: uppercase; letter-spacing: .03em;
  }
  .badge.pending { background: var(--amber-tint); color: var(--amber); }
  .badge.verified { background: var(--green-tint); color: var(--green); }
  .badge.query { background: var(--red-tint); color: var(--red); }
  .badge.receipt-yes { background: var(--green-tint); color: var(--green); }
  .badge.receipt-no { background: var(--red-tint); color: var(--red); }
  .badge.cancelled { background: #ECEDF1; color: #6B7188; }

  .txn-card.cancelled { opacity: .6; }
  .txn-card.cancelled .amt { text-decoration: line-through; }

  .audit-entry {
    border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin-bottom: 10px; font-size: 12.5px;
  }
  .audit-entry .audit-action { font-weight: 700; color: var(--ink); }
  .audit-entry .audit-meta { color: var(--ink-soft); margin-top: 2px; }
  .audit-entry .audit-reason { color: var(--ink-soft); font-style: italic; margin-top: 2px; }

  .assign-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; }
  .assign-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border: 1.5px solid var(--line); border-radius: 10px; background: var(--slab); font-size: 14px; font-weight: 500;
  }
  .assign-item input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--blue); }
  .pin-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--slab);
  }
  .pin-row .pin-name { font-weight: 600; font-size: 14px; }
  .pin-reveal {
    font-family: 'Barlow Condensed', sans-serif; font-size: 18px; font-weight: 700; letter-spacing: .08em;
    color: var(--green); background: var(--green-tint); padding: 4px 10px; border-radius: 8px; margin-top: 4px; display: inline-block;
  }

  .empty-state {
    text-align: center; padding: 40px 20px; color: var(--ink-soft); font-size: 14px;
  }

  .avatar {
    display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
    color: #fff; font-family: 'Barlow Condensed', sans-serif; font-weight: 700; flex-shrink: 0;
  }

  .who-line { display: flex; align-items: center; gap: 7px; margin-top: 8px; }

  .notif-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; margin-bottom: 9px; box-shadow: var(--shadow); display: flex; gap: 11px; }
  .notif-card.unread { border-left: 3px solid var(--amber); background: var(--amber-tint); }
  .notif-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--amber-tint); color: var(--amber); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .notif-card.unread .notif-icon { background: var(--amber); color: #fff; }
  .notif-title { font-size: 13.5px; font-weight: 700; color: var(--ink); }
  .notif-detail { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
  .notif-time { font-size: 10.5px; color: var(--ink-soft); margin-top: 5px; opacity: .8; }
  .notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; margin-left: 5px; }
  .nav-icon-wrap { position: relative; display: inline-flex; }
  .nav-icon-wrap .notif-dot { position: absolute; top: -2px; right: -2px; margin: 0; border: 1.5px solid var(--paper); }

  .status-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: #ECEDF1; color: #6B7188; }

  .chart-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 15px; box-shadow: var(--shadow); margin-bottom: 6px; }
  .bar-chart { display: flex; align-items: flex-end; gap: 7px; height: 96px; padding-top: 4px; }
  .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
  .bar { width: 100%; background: linear-gradient(180deg, var(--blue), var(--blue-dark)); border-radius: 5px 5px 2px 2px; min-height: 5px; transition: height .5s cubic-bezier(.2,.8,.3,1); }
  .bar-col.current .bar { background: linear-gradient(180deg, var(--green), #0d5c38); }
  .bar-label { font-size: 9.5px; color: var(--ink-soft); margin-top: 6px; font-weight: 600; }
  .bar-value { font-size: 8.5px; color: var(--ink-soft); font-weight: 600; margin-bottom: 3px; opacity: .85; }

  .export-btn { display: flex; align-items: center; justify-content: center; gap: 9px; text-decoration: none; background: linear-gradient(135deg, var(--green), #0d5c38); color: #fff; border-radius: 12px; padding: 13px 10px; font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 13.5px; letter-spacing: .01em; box-shadow: 0 6px 16px rgba(21,115,71,.28); margin-bottom: 8px; white-space: nowrap; }
  .export-btn .btn-label { overflow: hidden; text-overflow: ellipsis; }

  .filter-select { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--paper); font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }

  /* Forms / sheet */
  .sheet-backdrop {
    position: fixed; inset: 0; background: rgba(20,23,32,.45);
    display: none; z-index: 50;
  }
  .sheet-backdrop.open { display: block; }
  .sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
    background: var(--paper);
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform .25s ease;
    box-shadow: 0 -8px 30px rgba(0,0,0,.2);
  }
  .sheet.open { transform: translateY(0); }
  .sheet-handle { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 10px auto 0; }
  .sheet-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px 6px;
  }
  .sheet-header h2 { font-size: 21px; }
  .sheet-close { font-size: 22px; color: var(--ink-soft); background: none; border: none; padding: 4px 8px; cursor: pointer; }
  .sheet-body { padding: 6px 18px 24px; }

  .field { margin-bottom: 14px; }
  .field label {
    display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
    text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
  }
  .field .req { color: var(--red); }
  .field input[type=text], .field input[type=date], .field input[type=number],
  .field select, .field textarea {
    width: 100%;
    font-size: 16px;
    font-family: inherit;
    padding: 13px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: var(--slab);
    color: var(--ink);
  }
  .field textarea { resize: vertical; min-height: 118px; }
  .field .amount-input {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 28px;
    font-weight: 700;
    padding: 14px 14px;
  }
  .field-error { color: var(--red); font-size: 12.5px; margin-top: 4px; }

  .segmented {
    display: flex; background: var(--slab); border-radius: 10px; padding: 3px;
    border: 1.5px solid var(--line); flex-wrap: wrap;
  }
  .segmented button {
    flex: 1 1 auto; min-width: 64px; border: none; background: none; padding: 10px 4px; font-size: 14px;
    font-weight: 600; color: var(--ink-soft); border-radius: 8px; cursor: pointer;
  }
  .segmented button.active { background: var(--paper); color: var(--blue); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
  .segmented.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; }
  .segmented.grid2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 4px; }
  .segmented.grid3 button, .segmented.grid2 button { flex: none; min-width: 0; }

  .submit-btn {
    width: 100%; background: var(--blue); color: #fff; border: none; border-radius: 12px;
    padding: 15px 12px; font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700;
    letter-spacing: .02em; text-transform: uppercase; cursor: pointer; margin-top: 6px;
    display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  }
  .submit-btn .btn-label { overflow: hidden; text-overflow: ellipsis; }
  .submit-btn:disabled { opacity: .55; }
  .submit-btn.saving { background: var(--ink-soft); }

  .banner {
    position: fixed; top: 16px; left: 16px; right: 16px; z-index: 100;
    background: var(--ink); color: #fff; padding: 14px 18px; border-radius: 12px;
    font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 10px;
    transform: translateY(-120%); transition: transform .25s ease;
  }
  .banner.show { transform: translateY(0); }
  .banner.success { background: var(--green); }
  .banner.error { background: var(--red); }
  .banner .txn-id { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; letter-spacing: .03em; }

  .bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--paper); border-top: 1px solid var(--line);
    display: flex; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,.04);
  }
  .bottom-nav button {
    flex: 1; background: none; border: none; padding: 6px 2px; font-size: 11.5px;
    font-weight: 600; color: var(--ink-soft); display: flex; flex-direction: column;
    align-items: center; gap: 3px; cursor: pointer;
  }
  .bottom-nav button.active { color: var(--blue); }
  .bottom-nav .nav-icon { font-size: 19px; }

  .kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card {
    background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
    padding: 14px; box-shadow: var(--shadow);
  }
  .kpi-card .kpi-label { font-size: 11.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
  .kpi-card .kpi-value { font-family: 'Barlow Condensed', sans-serif; font-size: 25px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
  .kpi-card.warn .kpi-value { color: var(--amber); }
  .kpi-card.danger .kpi-value { color: var(--red); }
  .kpi-card .kpi-note { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }

  select#adminSupervisorSelect, select#supervisorSelect {
    width: 100%; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line);
    background: var(--paper); font-size: 15px; font-weight: 600; color: var(--ink);
  }

  .filter-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
  .chip {
    flex: 0 0 auto; padding: 8px 14px; border-radius: 20px; border: 1.5px solid var(--line);
    background: var(--paper); font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
    white-space: nowrap;
  }
  .chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

  .recon-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .recon-table th { text-align: left; color: var(--ink-soft); font-size: 11px; text-transform: uppercase; padding: 6px 8px; border-bottom: 1.5px solid var(--line); }
  .recon-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
  .recon-table tr:last-child td { border-bottom: none; }

  .spinner {
    display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  .loading-screen {
    display: flex; align-items: center; justify-content: center; height: 60vh; color: var(--ink-soft); font-size: 14px;
  }

  /* Login screen */
  .login-screen {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    padding: 24px 18px; background: var(--slab);
  }
  .login-card {
    width: 100%; max-width: 360px; background: var(--paper); border-radius: 20px;
    box-shadow: var(--shadow); padding: 28px 22px 24px;
  }
  .login-card h1 { font-size: 24px; margin-bottom: 4px; }
  .login-badge { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); display: flex; align-items: center; justify-content: center; color: #fff; margin-bottom: 14px; box-shadow: 0 8px 18px rgba(29,62,158,.3); }
  .login-sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 18px; }
  .login-hint { font-size: 12px; color: var(--ink-soft); text-align: center; margin: 14px 0 0; }
  #loginPin { letter-spacing: 8px; text-align: center; }

  .who-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 4px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
  }
  .logout-link {
    background: none; border: none; color: var(--blue); font-weight: 600; font-size: 12.5px;
    padding: 4px 6px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
  }

  .tab-panel { display: none; animation: fadeInTab .2s ease; }
  .tab-panel.active { display: block; }
  @keyframes fadeInTab { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

  .header-brand-row { display: flex; align-items: center; gap: 8px; }
  .brand-logo { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; flex-shrink: 0; background: rgba(255,255,255,.15); display: none; }

  .logo-upload-box {
    display: flex; align-items: center; gap: 14px; background: var(--paper);
    border: 1px dashed var(--line); border-radius: 12px; padding: 14px; margin-bottom: 8px;
  }
  .logo-preview {
    width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
    background: var(--slab); border: 1px solid var(--line);
  }
  .logo-preview-empty {
    width: 56px; height: 56px; border-radius: 12px; flex-shrink: 0;
    background: var(--slab); border: 1px dashed var(--line);
    display: flex; align-items: center; justify-content: center; color: var(--ink-soft);
  }
  .logo-upload-actions { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
  .logo-file-label {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--slab); border: 1.5px solid var(--line); border-radius: 9px;
    padding: 9px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .logo-file-label input[type=file] { display: none; }

  .settings-section {
    background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
    margin-bottom: 10px; overflow: hidden; box-shadow: var(--shadow);
  }
  .settings-section-header {
    display: flex; align-items: center; gap: 11px; padding: 15px 16px;
    cursor: pointer; -webkit-user-select: none; user-select: none;
  }
  .settings-section-icon {
    width: 34px; height: 34px; border-radius: 10px; background: var(--blue-tint); color: var(--blue);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .settings-section-title { flex: 1; font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700; color: var(--ink); }
  .settings-section-chevron { color: var(--ink-soft); display: flex; transition: transform .2s ease; flex-shrink: 0; }
  .settings-section.open .settings-section-chevron { transform: rotate(180deg); }
  .settings-section-body { display: none; padding: 0 16px 16px; border-top: 1px solid var(--line); padding-top: 14px; }
  .settings-section.open .settings-section-body { display: block; }
  .settings-section-body .section-title:first-child { margin-top: 0; }
