@font-face {
  font-family: 'Yekan Bakh FaNum';
  font-style: normal;
  font-weight: normal;
  font-stretch: normal;
  src: url('persianfont/woff/YekanBakhFaNum-Regular.woff') format('woff'),
       url('persianfont/woff2/YekanBakhFaNum-Regular.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #101827;
  --ink-2: #1E293B;
  --ink-soft: #526176;
  --paper: #F3F5F8;
  --paper-2: #FAFBFC;
  --panel: #FFFFFF;
  --line: #E3E8EF;
  --line-strong: #CBD5E1;
  --gold: #B78A3B;
  --gold-dark: #8A6729;
  --gold-soft: #F5EAD7;
  --green: #17724A;
  --green-soft: #E5F4EC;
  --red: #B2382D;
  --red-soft: #FCE8E5;
  --blue: #1E5B9A;
  --blue-soft: #E5EEF8;
  --violet: #6B4E9B;
  --violet-soft: #EEE9F7;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.08), 0 2px 10px rgba(15, 23, 42, 0.04);
  --shadow-soft: 0 8px 26px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(183, 138, 59, 0.14), transparent 34rem),
    radial-gradient(circle at bottom left, rgba(30, 91, 154, 0.10), transparent 32rem),
    linear-gradient(135deg, #F8FAFC 0%, var(--paper) 52%, #ECEFF4 100%);
  color: var(--ink);
  font-family: 'Yekan Bakh FaNum', Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  min-height: 100vh;
}

button, input, select { font-family: inherit; }
a { color: inherit; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 292px;
  height: 100vh;
  flex-shrink: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.055), transparent 22%),
    linear-gradient(180deg, #121C2F 0%, #0B1220 100%);
  color: #fff;
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  border-left: 1px solid rgba(255,255,255,0.08);
  box-shadow: -18px 0 45px rgba(15, 23, 42, 0.08) inset;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 4px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: linear-gradient(135deg, #E9C983, var(--gold));
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 20px;
  box-shadow: 0 12px 26px rgba(183, 138, 59, 0.28);
}

.brand-copy { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 900; font-size: 16px; letter-spacing: -0.2px; }
.brand-subtitle { margin-top: 4px; color: #AEBBD1; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  position: relative;
  color: #C5D0E0;
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  transition: background 0.18s, color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; transform: translateX(-2px); }
.nav a.active { background: linear-gradient(135deg, #E9C983, var(--gold)); color: #101827; box-shadow: 0 10px 26px rgba(183, 138, 59, 0.24); }
.nav a span { display: block; }

.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.install-app {
  width: 100%;
  border: 1px solid rgba(233, 201, 131, 0.42);
  background: rgba(255,255,255,0.07);
  color: #F8E6BD;
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 900;
  cursor: pointer;
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.09);
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #F5EAD7;
  color: #111827;
  font-weight: 900;
}
.user-meta { display: grid; line-height: 1.25; }
.user-meta strong { font-size: 13px; }
.user-meta a { color: #B9C6DA; font-size: 12px; text-decoration: none; margin-top: 4px; }
.user-meta a:hover { color: #fff; }

.content {
  flex: 1;
  padding: 36px 44px 48px;
  max-width: 1280px;
  width: 100%;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow { margin: 0 0 5px; color: var(--gold-dark); font-size: 12px; font-weight: 900; letter-spacing: 0.4px; }
h1 { font-size: 25px; margin: 0 0 22px; font-weight: 900; letter-spacing: -0.6px; }
.page-heading h1 { margin: 0; }
h2 { font-size: 16px; margin: 0 0 18px; font-weight: 900; color: var(--ink-2); }
h3 { margin: 0; font-size: 18px; font-weight: 900; }
.muted { color: #6B7690; }
.tiny-note { display: block; margin-top: 4px; color: #7C879A; font-size: 11px; white-space: nowrap; }

.flash {
  padding: 13px 16px;
  border-radius: 14px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 800;
  border: 1px solid transparent;
  box-shadow: var(--shadow-soft);
}
.flash-success { background: var(--green-soft); color: var(--green); border-color: #CBE8D8; }
.flash-error { background: var(--red-soft); color: var(--red); border-color: #F1C9C3; }

.action-tabs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.action-tabs a {
  background: rgba(255,255,255,0.76);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  text-decoration: none;
  padding: 8px 13px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset;
}
.action-tabs a:hover, .action-tabs a.active { color: var(--ink); border-color: rgba(183, 138, 59, 0.55); background: var(--gold-soft); }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 28px; }
.compact-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.stat-card {
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}
.stat-card-primary { background: linear-gradient(135deg, #18243A, #0F172A); color: #fff; border-color: rgba(255,255,255,0.08); }
.stat-card-primary .stat-label { color: #B7C1D6; }
.stat-card-receivable { border-color: rgba(23, 114, 74, 0.18); background: linear-gradient(135deg, #FFFFFF, #F4FBF7); }
.stat-card-payable { border-color: rgba(178, 56, 45, 0.18); background: linear-gradient(135deg, #FFFFFF, #FFF7F5); }
.stat-label { font-size: 13px; color: #6B7690; font-weight: 800; }
.stat-value { font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -0.4px; }

.empty-hint { grid-column: 1 / -1; color: #6B7690; padding: 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); text-align: center; background: rgba(255,255,255,0.62); }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.panel {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(226, 232, 240, 0.96);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  margin-bottom: 24px;
}
.panel-formal { border-top: 4px solid var(--gold); }
.panel-narrow { max-width: 560px; }
.loan-panel { margin-top: 8px; }

.form { display: flex; flex-direction: column; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compact-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--ink-soft); font-weight: 900; }
.form input, .form select {
  font-size: 14px;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
.form input[type="file"] { padding: 10px; background: #fff; border-style: dashed; }
.form input:focus, .form select:focus, .inline-form input:focus, .inline-form select:focus { outline: none; border-color: rgba(183, 138, 59, 0.8); box-shadow: 0 0 0 4px rgba(183, 138, 59, 0.13); background: #fff; }
.upload-field small { color: #7C879A; font-size: 11.5px; font-weight: 700; }

.btn {
  font-size: 14px;
  font-weight: 900;
  padding: 10px 18px;
  border-radius: 13px;
  border: none;
  cursor: pointer;
  width: fit-content;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, #E8C57F, var(--gold)); color: #111827; box-shadow: 0 12px 28px rgba(183, 138, 59, 0.26); }
.btn-primary:hover { filter: brightness(0.97); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-soft); padding: 7px 12px; font-size: 13px; box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset; }
.btn-danger { color: var(--red); border-color: #EBCFC9; }
.btn-danger:hover { background: var(--red-soft); }

.account-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.account-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--ink);
}
.account-card-inactive { filter: grayscale(0.5); opacity: 0.72; }
.account-card-shine { position: absolute; inset: -40% auto auto -22%; width: 230px; height: 230px; background: rgba(255,255,255,0.08); border-radius: 999px; transform: rotate(22deg); pointer-events: none; }
.account-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; z-index: 1; }
.account-bank { color: #D8E1F1; font-size: 13px; font-weight: 900; }
.account-card-body { display: flex; flex-direction: column; gap: 12px; }
.account-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.account-info-grid span { min-width: 0; padding: 10px 11px; border-radius: 14px; background: #F8FAFC; border: 1px solid var(--line); }
.account-info-grid small { display: block; color: #7C879A; font-size: 11px; font-weight: 800; margin-bottom: 3px; }
.account-info-grid b { display: block; overflow-wrap: anywhere; font-size: 12.5px; font-weight: 900; color: var(--ink); }
.account-note { margin: 0; font-size: 12.5px; }
.account-edit { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.account-edit summary { cursor: pointer; font-weight: 900; color: var(--ink-2); }
.account-edit-form { margin-top: 14px; }
.account-actions { margin-top: 2px; }
.account-help .mini-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.mini-checks span { padding: 11px; border-radius: 14px; background: #F8FAFC; border: 1px solid var(--line); font-weight: 900; color: var(--ink-soft); }

.table-wrap { width: 100%; overflow-x: auto; border-radius: 14px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 760px; }
.table th { text-align: right; color: #667085; font-weight: 900; padding: 11px 12px; border-bottom: 1px solid var(--line); background: #F8FAFC; white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #FAFBFC; }
.table tbody tr:last-child td { border-bottom: none; }
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; white-space: nowrap; }
.badge-expense { background: var(--red-soft); color: var(--red); }
.badge-deposit { background: var(--green-soft); color: var(--green); }
.badge-loan-given { background: var(--blue-soft); color: var(--blue); }
.badge-loan-taken { background: var(--violet-soft); color: var(--violet); }
.badge-open { background: var(--gold-soft); color: var(--gold-dark); }
.badge-muted { background: #EEF0F4; color: #6B7690; }
.invoice-link { display: inline-flex; align-items: center; gap: 7px; color: var(--blue); text-decoration: none; font-weight: 900; white-space: nowrap; }
.invoice-link:hover { text-decoration: underline; }
.invoice-thumb { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08); }

.inline-form { display: grid; grid-template-columns: 136px 190px auto; align-items: center; gap: 8px; }
.inline-form input, .inline-form select { min-width: 0; font-size: 12.5px; padding: 7px 9px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.bar-list { display: flex; flex-direction: column; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 120px minmax(140px, 1fr) 120px; align-items: center; gap: 12px; font-size: 13px; }
.bar-track { background: #EEF2F7; border-radius: 999px; height: 11px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05); }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), #D9AE5C); border-radius: 999px; }
.bar-value { text-align: left; font-variant-numeric: tabular-nums; color: var(--ink-soft); white-space: nowrap; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-shell { width: 100%; max-width: 460px; }
.login-card {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(226, 232, 240, 0.96);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.login-brand h1 { margin: 0; font-size: 23px; }
.login-copy { margin: 0 0 22px; color: var(--ink-soft); font-weight: 700; }
.login-form .btn { width: 100%; justify-content: center; }

/* ============ Mobile Top Bar ============ */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1100;
  height: 58px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0);
  background: linear-gradient(180deg, #121C2F 0%, #0F172A 100%);
  color: #fff;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.18);
}
.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 15px;
}
.mobile-topbar-brand .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  font-size: 16px;
}
.mobile-topbar-user {
  text-decoration: none;
  color: inherit;
}
.mobile-topbar-user .user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 14px;
}

/* ============ Hamburger Button ============ */
.hamburger-btn {
  width: 38px;
  height: 38px;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  -webkit-tap-highlight-color: transparent;
}
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2.5px;
  background: #fff;
  border-radius: 4px;
  transition: transform 0.3s ease, opacity 0.2s ease;
}
.hamburger-btn.is-active span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.hamburger-btn.is-active span:nth-child(2) { opacity: 0; }
.hamburger-btn.is-active span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* ============ Sidebar Overlay ============ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1199;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.is-visible {
  display: block;
  opacity: 1;
}

/* ============ Bottom Navigation ============ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: linear-gradient(180deg, #FFFFFF 0%, #FAFBFC 100%);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.08);
  align-items: stretch;
  justify-content: space-around;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: #6B7690;
  font-size: 10.5px;
  font-weight: 900;
  position: relative;
  transition: color 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item i { font-size: 18px; transition: transform 0.18s; }
.bottom-nav-item.active { color: var(--gold-dark); }
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  width: 32px;
  height: 3px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, var(--gold), #E9C983);
}
.bottom-nav-item.active i { transform: scale(1.15); }

/* ============ Donut Chart ============ */
.expense-chart-layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  margin-bottom: 22px;
}
.expense-chart-figure {
  position: relative;
  flex: 0 0 auto;
}
.expense-chart-canvas {
  display: block;
  max-width: 100%;
}
.expense-chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.expense-chart-center small {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 800;
}
.expense-chart-center strong {
  font-size: 14px;
  font-weight: 900;
  color: var(--ink);
}
.expense-chart-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #F8FAFC;
  border: 1px solid var(--line);
}
.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 5px;
  flex-shrink: 0;
}
.legend-copy {
  flex: 1;
  min-width: 0;
}
.legend-copy strong {
  display: block;
  font-size: 12.5px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend-copy small {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
}
.legend-percent {
  font-size: 12px;
  font-weight: 900;
  color: var(--ink-soft);
  white-space: nowrap;
}
.compact-bar-list {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* ============ Touch Press Feedback ============ */
.is-pressed {
  transform: scale(0.97) !important;
  opacity: 0.88;
}

/* ============ Desktop: hide mobile components ============ */
@media (min-width: 981px) {
  .mobile-topbar { display: none !important; }
  .sidebar-overlay { display: none !important; }
  .bottom-nav { display: none !important; }
}

/* ============ Tablet ≤ 980px ============ */
@media (max-width: 980px) {
  .mobile-topbar { display: flex; }
  .bottom-nav { display: flex; }

  .app-shell { flex-direction: column; }

  /* Sidebar becomes slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    z-index: 1200;
    border-left: none;
    border-radius: 0;
    transition: right 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    padding: 28px 22px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.is-open { right: 0; }
  .sidebar .brand { display: flex; }
  .nav { display: flex; flex-direction: column; gap: 6px; }
  .nav a { white-space: normal; border: none; background: none; }

  .content { padding: 16px 16px calc(80px + env(safe-area-inset-bottom, 0)); max-width: none; }
  .two-col { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .action-tabs { justify-content: flex-start; }
}

/* ============ Phone ≤ 680px ============ */
@media (max-width: 680px) {
  body { font-size: 14px; }
  .content { padding: 14px 12px calc(80px + env(safe-area-inset-bottom, 0)); }
  .panel { padding: 16px; border-radius: 20px; }
  .cards-grid, .compact-grid { grid-template-columns: 1fr; gap: 12px; margin-bottom: 18px; }
  .page-heading { margin-bottom: 14px; }
  .action-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 10px; }
  .action-tabs a {
    min-height: 64px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px 10px;
    box-shadow: var(--shadow-soft);
    background: #fff;
  }
  .action-tabs a.active { background: linear-gradient(135deg, #F9EBC9, var(--gold-soft)); }
  .form-grid, .compact-form-grid { grid-template-columns: 1fr; }
  .account-card-grid { grid-template-columns: 1fr; }
  .account-info-grid { grid-template-columns: 1fr 1fr; }
  .account-help .mini-checks { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; gap: 7px; }
  .bar-value { text-align: right; }
  .inline-form { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  h1 { font-size: 21px; }
  .stat-value { font-size: 18px; }
  .login-card { padding: 22px; border-radius: 24px; }

  /* Donut chart stacks on mobile */
  .expense-chart-layout { flex-direction: column; align-items: center; gap: 18px; }
  .expense-chart-figure { width: 200px; }
  .expense-chart-center strong { font-size: 12px; }

  /* Tables become card layout */
  .table-wrap { overflow: visible; border-radius: 0; }
  .table { min-width: 0; border-collapse: separate; border-spacing: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody { display: grid; gap: 12px; }
  .table tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 12px 14px;
    box-shadow: var(--shadow-soft);
  }
  .table tbody tr:hover { background: #fff; }
  .table td {
    border: 0;
    padding: 8px 0;
    display: grid;
    grid-template-columns: minmax(88px, 36%) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }
  .table td + td { border-top: 1px solid #EEF2F7; }
  .table td::before {
    content: attr(data-label);
    color: #667085;
    font-weight: 900;
    font-size: 12px;
  }
  .table td[data-label=""] { display: flex; justify-content: flex-end; }
  .table td[data-label=""]::before { display: none; }
  .table td:has(.inline-form) { display: block; }
  .table td:has(.inline-form)::before { display: block; margin-bottom: 8px; }
  .table .inline-form { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; }
  .table .inline-form input, .table .inline-form select { width: 100%; }
  .table .btn { width: 100%; justify-content: center; }
  .invoice-link { justify-content: flex-end; }

  /* Form inputs bigger touch targets */
  .form input, .form select { padding: 13px 14px; font-size: 16px; border-radius: 14px; }
  .form label { font-size: 13px; gap: 6px; }
}

.account-mini-card {
  color: inherit;
  text-decoration: none;
  border-color: rgba(183, 138, 59, 0.20);
  background: linear-gradient(135deg, #FFFFFF, #FFFCF6);
}
.account-mini-card:hover { transform: translateY(-2px); }
.account-mini-meta { color: #7C879A; font-size: 12px; font-weight: 800; direction: ltr; text-align: right; overflow-wrap: anywhere; }

/* FontAwesome/icon refinements */
.nav a, .action-tabs a, .btn, .install-app, .badge, .invoice-link, .mini-checks span, h2 { display: inline-flex; align-items: center; gap: 8px; }
.nav a { display: flex; }
.nav a span { display: inline; }
.nav a i { width: 18px; text-align: center; opacity: 0.92; }
.action-tabs a i, .btn i, .badge i, .mini-checks i { font-size: 0.95em; }

/* Realistic bank-card look */
.account-card-grid { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.bank-card {
  --bank-bg: linear-gradient(145deg, #172238 0%, #0F172A 68%, #111827 100%);
  --bank-glow: rgba(232, 197, 127, 0.24);
  --bank-line: rgba(255,255,255,0.12);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: 1.585 / 1;
  border-radius: 20px;
  padding: 18px 20px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  background:
    radial-gradient(circle at 12% 12%, var(--bank-glow), transparent 32%),
    radial-gradient(circle at 92% 88%, rgba(255,255,255,0.13), transparent 28%),
    var(--bank-bg);
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.24), inset 0 1px 0 rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.16);
}
.bank-theme-mellat { --bank-bg: linear-gradient(135deg, #8B1020, #C51F35 52%, #5C0B17); --bank-glow: rgba(255, 214, 112, 0.23); }
.bank-theme-melli { --bank-bg: linear-gradient(135deg, #9E781E, #D6A832 48%, #1F2937); --bank-glow: rgba(255,255,255,0.22); }
.bank-theme-saderat { --bank-bg: linear-gradient(135deg, #0B4EA2, #1269C7 50%, #062D63); --bank-glow: rgba(255,255,255,0.20); }
.bank-theme-sepah { --bank-bg: linear-gradient(135deg, #14532D, #16834A 48%, #0A2E1B); --bank-glow: rgba(255,241,199,0.20); }
.bank-theme-tejarat { --bank-bg: linear-gradient(135deg, #123C7C, #1D67B1 46%, #B8242C); --bank-glow: rgba(255,255,255,0.18); }
.bank-theme-pasargad { --bank-bg: linear-gradient(135deg, #2F2B5F, #7C4D9E 48%, #1D1B3C); --bank-glow: rgba(248,222,126,0.22); }
.bank-theme-parsian { --bank-bg: linear-gradient(135deg, #7C2D12, #C56A21 54%, #33150A); --bank-glow: rgba(255,237,213,0.22); }
.bank-theme-saman { --bank-bg: linear-gradient(135deg, #075985, #0EA5E9 48%, #083344); --bank-glow: rgba(224,242,254,0.24); }
.bank-theme-maskan { --bank-bg: linear-gradient(135deg, #8A3A11, #EA580C 52%, #431407); --bank-glow: rgba(255,237,213,0.24); }
.bank-theme-keshavarzi { --bank-bg: linear-gradient(135deg, #365314, #65A30D 48%, #1A2E05); --bank-glow: rgba(236,252,203,0.22); }
.bank-theme-shahr { --bank-bg: linear-gradient(135deg, #0F766E, #14B8A6 46%, #134E4A); --bank-glow: rgba(204,251,241,0.22); }
.bank-theme-ayandeh { --bank-bg: linear-gradient(135deg, #1E1B4B, #4F46E5 52%, #111827); --bank-glow: rgba(224,231,255,0.22); }
.bank-theme-refah { --bank-bg: linear-gradient(135deg, #991B1B, #DC2626 48%, #451A03); --bank-glow: rgba(255,255,255,0.20); }
.bank-theme-eghtesad { --bank-bg: linear-gradient(135deg, #064E3B, #059669 48%, #022C22); --bank-glow: rgba(209,250,229,0.22); }
.bank-theme-ansar { --bank-bg: linear-gradient(135deg, #581C87, #9333EA 46%, #2E1065); --bank-glow: rgba(243,232,255,0.22); }
.bank-theme-day { --bank-bg: linear-gradient(135deg, #0F172A, #334155 52%, #020617); --bank-glow: rgba(226,232,240,0.18); }

.bank-card-pattern {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.38;
  pointer-events: none;
  background:
    linear-gradient(120deg, transparent 0 28%, rgba(255,255,255,0.10) 28% 29%, transparent 29% 100%),
    repeating-linear-gradient(45deg, transparent 0 16px, rgba(255,255,255,0.05) 17px 18px);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
.bank-card-main, .bank-card-footer, .card-number { position: relative; z-index: 1; }
.bank-card-main { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.bank-chip {
  width: 48px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(135deg, #FCE7A9, #B88931 48%, #F7D98C);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: inset 0 0 0 1px rgba(71, 47, 8, 0.20), 0 9px 20px rgba(0,0,0,0.16);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
}
.bank-chip span { border-left: 1px solid rgba(70, 45, 8, 0.25); border-bottom: 1px solid rgba(70, 45, 8, 0.18); }
.contactless { color: rgba(255,255,255,0.82); font-size: 25px; transform: rotate(90deg); }
.card-number {
  direction: ltr;
  text-align: center;
  letter-spacing: 3px;
  font-size: clamp(16px, 2.6vw, 24px);
  line-height: 1.2;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(0,0,0,0.25);
  padding: 7px 0 1px;
  white-space: nowrap;
}
.bank-card-footer { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; }
.bank-card-footer div { min-width: 0; }
.bank-card-footer small { display: block; color: rgba(255,255,255,0.62); font-size: 10.5px; font-weight: 900; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.bank-card-footer strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 14px; font-weight: 900; }
.bank-card-balance { font-size: clamp(13px, 2.8vw, 16px) !important; font-variant-numeric: tabular-nums; }
.account-bank { display: inline-flex; align-items: center; gap: 7px; color: rgba(255,255,255,0.86); letter-spacing: 0.1px; }
.account-note { padding: 10px 12px; border-radius: 14px; background: #F8FAFC; border: 1px solid var(--line); color: var(--ink-soft); }
.account-share-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-light {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 8px 12px;
  font-size: 12.5px;
  box-shadow: var(--shadow-soft);
}
.copy-chip {
  border: 1px solid var(--line);
  background: #F8FAFC;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.copy-chip:hover { transform: translateY(-1px); background: var(--gold-soft); border-color: rgba(183, 138, 59, 0.35); color: var(--ink); }
.copy-chip.is-done, .share-account.is-done { background: var(--green-soft); color: var(--green); border-color: rgba(23,114,74,0.28); }
.account-edit summary { display: inline-flex; align-items: center; gap: 8px; }

@media (max-width: 680px) {
  .account-card-grid { grid-template-columns: 1fr; }
  .bank-card { border-radius: 18px; padding: 14px 16px; }
  .bank-chip { width: 44px; height: 32px; border-radius: 8px; }
  .contactless { font-size: 20px; }
  .card-number { font-size: clamp(15px, 4.8vw, 22px); letter-spacing: 1.5px; padding: 4px 0 0; }
  .bank-card-footer { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 8px; }
  .bank-card-footer strong { font-size: 12.5px; }
  .bank-card-balance { font-size: clamp(11px, 3.2vw, 14px) !important; }
  .account-info-grid { grid-template-columns: 1fr 1fr; }
  .account-share-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-share-row .share-account { grid-column: 1 / -1; width: 100%; justify-content: center; }
  .copy-chip { justify-content: center; width: 100%; }

  .table-wrap { overflow: visible; border-radius: 0; }
  .table { min-width: 0; border-collapse: separate; border-spacing: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody { display: grid; gap: 12px; }
  .table tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 12px 14px;
    box-shadow: var(--shadow-soft);
  }
  .table tbody tr:hover { background: #fff; }
  .table td {
    border: 0;
    padding: 9px 0;
    display: grid;
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }
  .table td + td { border-top: 1px solid #EEF2F7; }
  .table td::before {
    content: attr(data-label);
    color: #667085;
    font-weight: 900;
    font-size: 12px;
  }
  .table td[data-label=""] { display: flex; justify-content: flex-end; }
  .table td[data-label=""]::before { display: none; }
  .table td:has(.inline-form) { display: block; }
  .table td:has(.inline-form)::before { display: block; margin-bottom: 8px; }
  .table .inline-form { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; }
  .table .inline-form input, .table .inline-form select { width: 100%; }
  .table .btn { width: 100%; justify-content: center; }
  .invoice-link { justify-content: flex-end; }
}

/* ================= صدور فاکتور ================= */
.invoice-toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-bottom: 18px; }
.invoice-toolbar .btn { width: auto; }

.invoice-sheet {
  max-width: 820px;
  margin: 0 auto;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  font-family: 'Yekan Bakh FaNum', Tahoma, Arial, sans-serif;
}

.inv-head {
  padding: 30px 34px 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  border-bottom: 2px solid var(--ink);
}
.inv-brand { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.inv-mark {
  width: 48px; height: 48px; flex: 0 0 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #E9C983, var(--gold));
  color: #111827;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 900;
  box-shadow: 0 10px 24px rgba(183, 138, 59, 0.28);
}
.inv-brand h1 { font-size: 20px; margin: 0 0 4px; font-weight: 900; }
.inv-brand .inv-role { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; font-weight: 800; }
.inv-brand .inv-meta { font-size: 12.5px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 3px; }
.inv-brand .inv-meta span { overflow-wrap: anywhere; }

.inv-tag { text-align: left; direction: ltr; flex: 0 0 auto; }
.inv-tag .inv-label { font-size: 11px; color: var(--gold-dark); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 6px; font-weight: 900; }
.inv-tag input {
  font-size: 20px; font-weight: 900; color: var(--ink);
  border: none; background: transparent; text-align: left;
  width: 150px; padding: 0; direction: ltr; font-family: inherit;
}
.inv-tag input:focus { outline: none; border-bottom: 1px dashed var(--gold); }

.inv-strip { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.inv-col { padding: 20px 34px; }
.inv-col:first-child { border-left: 1px solid var(--line); }
.inv-col h3 { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 12px; font-weight: 900; }
.inv-field { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 9px; }
.inv-field label { color: var(--ink-soft); flex: 0 0 auto; font-weight: 800; }
.inv-field input {
  font-size: 13px; border: none; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--ink); text-align: left; direction: rtl;
  padding: 3px 0; flex: 1; min-width: 0; font-family: inherit;
}
.inv-field input:focus { outline: none; border-bottom: 1px solid var(--gold); }
.inv-field.ltr input { direction: ltr; text-align: left; }

.inv-items { padding: 24px 34px 4px; }
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table thead th {
  font-size: 11px; letter-spacing: 0.4px; color: var(--ink-soft);
  text-align: right; padding: 0 8px 10px; border-bottom: 1px solid var(--ink); font-weight: 900;
}
.inv-table thead th.inv-num, .inv-table thead th.inv-gutter { text-align: center; }
.inv-table tbody td { padding: 8px; border-bottom: 1px solid var(--gutter, #EEF0F4); font-size: 13.5px; vertical-align: top; }
.inv-table td.inv-gutter {
  width: 34px; text-align: center; color: #AEB6C2; font-size: 12px;
  background: #F8FAFC; user-select: none; font-variant-numeric: tabular-nums;
}
.inv-table td input, .inv-table td textarea {
  width: 100%; border: none; background: transparent; color: var(--ink);
  font-size: 13.5px; padding: 4px 5px; border-radius: 8px; resize: none; font-family: inherit;
}
.inv-table td input:focus, .inv-table td textarea:focus { outline: none; background: var(--gold-soft); }
.inv-table td.inv-num input { text-align: center; direction: ltr; font-variant-numeric: tabular-nums; }
.inv-table td.inv-money input { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
.inv-table td.inv-line-total { text-align: left; direction: ltr; font-weight: 900; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-table td.inv-rm { width: 32px; text-align: center; }
.inv-rm-btn { border: none; background: transparent; color: #C6CCC9; cursor: pointer; font-size: 15px; line-height: 1; padding: 4px; }
.inv-rm-btn:hover { color: var(--red); }

.inv-add-wrap { padding: 12px 8px 4px; }
.inv-add-row {
  font-size: 13px; border: 1px dashed var(--line-strong); background: transparent;
  color: var(--gold-dark); padding: 10px 14px; border-radius: 12px; cursor: pointer;
  width: 100%; text-align: center; font-weight: 900; font-family: inherit;
}
.inv-add-row:hover { border-color: var(--gold); background: var(--gold-soft); }

.inv-totals-wrap { padding: 16px 34px 28px; display: flex; justify-content: space-between; gap: 28px; align-items: flex-start; }
.inv-notes { flex: 1; font-size: 12.5px; color: var(--ink-soft); min-width: 0; }
.inv-notes h3 { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 8px; font-weight: 900; }
.inv-notes textarea {
  width: 100%; min-height: 80px; border: 1px solid var(--line); border-radius: 12px;
  background: transparent; color: var(--ink); padding: 10px; resize: vertical;
  font-size: 12.5px; font-family: inherit; line-height: 1.8;
}
.inv-notes textarea:focus { outline: none; border-color: var(--gold); }

.inv-totals { width: 300px; flex: 0 0 300px; }
.inv-totals .inv-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--gutter, #EEF0F4); }
.inv-totals .inv-row label { color: var(--ink-soft); font-weight: 800; }
.inv-totals .inv-row .inv-val { direction: ltr; font-variant-numeric: tabular-nums; font-weight: 800; }
.inv-totals .inv-row.inv-discount .inv-val, .inv-totals .inv-row.inv-discount input { color: var(--red); }
.inv-totals .inv-row input {
  width: 90px; border: none; border-bottom: 1px solid var(--line); background: transparent;
  text-align: left; direction: ltr; font-size: 13px; font-family: inherit; font-weight: 800;
}
.inv-totals .inv-row input:focus { outline: none; border-bottom: 1px solid var(--gold); }
.inv-grand {
  margin-top: 12px; background: linear-gradient(135deg, #18243A, #0F172A); color: #fff;
  border-radius: 14px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: baseline;
}
.inv-grand label { font-size: 12.5px; color: #B7C1D6; font-weight: 800; }
.inv-grand .inv-val { font-size: 19px; font-weight: 900; direction: rtl; font-variant-numeric: tabular-nums; }

.inv-foot {
  border-top: 1px solid var(--line); padding: 18px 34px 26px;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; font-size: 12px; color: var(--ink-soft);
}
.inv-foot .inv-legal { flex: 1; min-width: 0; }
.inv-sign { text-align: center; flex: 0 0 auto; }
.inv-sign img { display: block; width: 150px; height: auto; margin: 0 auto 2px; }
.inv-sign small { display: block; color: var(--ink-soft); font-weight: 800; border-top: 1px solid var(--line-strong); padding-top: 6px; }

@media (max-width: 680px) {
  .invoice-toolbar { display: grid; grid-template-columns: 1fr; }
  .invoice-toolbar .btn { width: 100%; justify-content: center; }
  .inv-head { flex-direction: column; padding: 22px 18px 18px; }
  .inv-tag { text-align: right; direction: rtl; }
  .inv-tag input { text-align: right; direction: ltr; width: 100%; }
  .inv-strip { grid-template-columns: 1fr; }
  .inv-col { padding: 18px; }
  .inv-col:first-child { border-left: none; border-bottom: 1px solid var(--line); }
  .inv-items { padding: 18px 12px 4px; }
  .inv-table thead th.inv-num { font-size: 10px; }
  .inv-table td, .inv-table thead th { padding-left: 4px; padding-right: 4px; }
  .inv-totals-wrap { flex-direction: column; padding: 16px 18px 24px; }
  .inv-totals { width: 100%; flex: 1; }
  .inv-foot { flex-direction: column; align-items: stretch; padding: 18px; }
  .inv-sign { text-align: left; }
  .inv-sign img { margin: 0 0 2px; }
}

/* هنگام ساخت PDF فقط برگه دیده شود */
.invoice-sheet.is-exporting { box-shadow: none; border-color: transparent; }

@media print {
  body { background: #fff; }
  .sidebar, .invoice-toolbar, .page-heading, .flash, .install-app { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; max-width: none; }
  .invoice-sheet { box-shadow: none; border: none; max-width: 100%; margin: 0; }
  .inv-add-wrap, .inv-rm { display: none !important; }
}
