@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700&display=swap');

:root {
  color-scheme: light;

  /* Modern HSL Palette (Professional & High Contrast) */
  --h: 220;
  /* Primary Blue Hue */
  --s: 89%;

  --bg: hsl(var(--h), 33%, 97%);
  --surface: hsl(var(--h), 20%, 100%);
  --card: hsl(var(--h), 20%, 100%);
  --text: hsl(var(--h), 47%, 11%);
  --muted: hsl(var(--h), 15%, 45%);

  --primary: hsl(var(--h), 89%, 54%);
  --primary-bg: hsl(var(--h), 89%, 95%);
  --primary-border: hsl(var(--h), 89%, 90%);

  --danger: hsl(0, 84%, 60%);
  --danger-bg: hsl(0, 84%, 96%);

  --ok: hsl(142, 69%, 45%);
  --ok-bg: hsl(142, 69%, 95%);

  --warn: hsl(38, 92%, 50%);
  --warn-bg: hsl(38, 92%, 95%);

  --radius-sm: 10px;
  --radius: 20px;
  --radius-lg: 28px;

  /* Glassmorphism Logic */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(15, 23, 42, 0.08);
  --glass-blur: blur(12px);

  /* Elevation */
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 22px 60px rgba(15, 23, 42, 0.12);

  /* Gradients */
  --grad-main: linear-gradient(135deg, hsl(var(--h), 89%, 60%), hsl(var(--h), 89%, 45%));
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: "Vazirmatn", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  direction: rtl;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(at 0% 0%, hsla(var(--h), 89%, 54%, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, hsla(142, 69%, 45%, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
}

input,
button,
select,
textarea {
  font-family: inherit
}

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

.sidebar {
  width: 240px;
  background: var(--surface);
  border-left: 1px solid rgba(15, 23, 42, .08);
  padding: 12px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  z-index: 100;
}

.sb-header {
  padding: 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.04);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  margin-bottom: 15px;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: white;
  border: 1px solid rgba(15, 23, 42, .06);
  box-shadow: 0 4px 15px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: hidden;
}

.sb-brand::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.03) 0%, transparent 70%);
  z-index: 0;
}

.brand-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sb-header-logout {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.15);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.sb-header-logout:hover {
  background: var(--danger);
  color: white;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 15px rgba(239, 68, 68, 0.25);
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--grad-main);
  color: white;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .15);
}

.brand-title {
  font-weight: 800;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 1px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 10px 10px;
  -webkit-overflow-scrolling: touch;
}

.sb-menu-card {
  background: white;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, .06);
  padding: 6px;
  box-shadow: 0 4px 15px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: transform 0.3s ease;
}

.sb-menu-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(15, 23, 42, 0.05);
}

.sb-divider {
  font-size: 10px;
  font-weight: 850;
  color: var(--primary);
  text-transform: uppercase;
  margin: 6px 8px 10px;
  letter-spacing: 1px;
  opacity: 0.8;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sb-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.1), transparent);
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.sb-icon {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  opacity: 0.7;
}

.sb-link:hover {
  background: hsla(var(--h), 89%, 54%, 0.05);
  color: var(--primary);
  padding-right: 15px;
}

.sb-link.active {
  background: var(--primary);
  color: white;
  font-weight: 700;
  box-shadow: 0 8px 15px rgba(37, 99, 235, 0.25);
  transform: scale(1.02);
}

.sb-link.active .sb-icon {
  opacity: 1;
  stroke-width: 2.6;
}

/* Premium Footer Optimization */
.sb-footer {
  margin-top: auto;
  padding: 10px;
  padding-bottom: 15px;
  /* Minimal padding */
  border-top: 1px solid rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
}

.sb-date-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f0f7ff 0%, #e0efff 100%);
  border: 1px solid rgba(37, 99, 235, .1);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.sb-date-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--grad-main);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.2);
  flex-shrink: 0;
}

.sb-date-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sb-date-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sb-date-value {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

/* Sidebar Toggle Header on Mobile */
.sidebar-header {
  display: none;
  margin-bottom: 0;
}

@media (max-width: 980px) {
  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    margin-bottom: 10px;
  }

  .sb-brand {
    margin-bottom: 0;
    flex: 1;
    background: transparent;
    border: 0;
    padding: 0;
  }
}

.sb-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-bg);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (max-width: 980px) {
  .sb-close-btn {
    display: flex;
  }
}

.sb-user-name {
  font-weight: 800
}

.sb-user-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px
}

.main {
  flex: 1;
  padding: 18px;
  min-width: 0
}

.main-inner {
  max-width: 1200px;
  margin: 0 auto
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  margin-top: 8px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 8px;
  z-index: 50;
}

.topbar-title {
  font-weight: 900
}

.topbar-spacer {
  flex: 1
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .03);
  border: 1px solid rgba(15, 23, 42, .08);
  color: var(--muted);
  font-size: 13px
}

.icon-btn {
  border: 1px solid rgba(15, 23, 42, .10);
  background: rgba(15, 23, 42, .03);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 14px;
  cursor: pointer
}

.icon-btn:hover {
  background: rgba(15, 23, 42, .05)
}

.card {
  background: var(--card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
  .card {
    padding: 16px;
    border-radius: var(--radius-sm);
  }
}

.card-title {
  font-weight: 700;
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-value {
  font-size: 32px;
  font-weight: 900;
  margin-top: 12px;
  color: hsl(var(--h), 47%, 15%);
}

.card-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--primary);
  text-decoration: none
}

.card-link:hover {
  text-decoration: underline
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
}

.grid4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.grid5 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width:1200px) {
  .grid4 {
    grid-template-columns: repeat(2, minmax(0, 1fr))
  }

  .grid5 {
    grid-template-columns: repeat(2, minmax(0, 1fr))
  }
}

@media (max-width:980px) {
  .grid {
    grid-template-columns: 1fr
  }

  .grid2,
  .grid3,
  .grid4,
  .grid5 {
    grid-template-columns: 1fr
  }

  /* Off-canvas sidebar on mobile */
  .app-shell {
    display: block;
    min-height: 100vh
  }

  .sidebar {
    width: min(86vw, 330px);
    max-width: 330px;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    transform: translateX(110%);
    transition: transform .25s ease;
    z-index: 1100;
    /* Higher than bottom-nav */
    border-left: 0;
    border-right: 1px solid rgba(15, 23, 42, .08);
  }

  .sidebar.open {
    transform: translateX(0)
  }

  body.sb-lock {
    overflow: hidden
  }

  .main {
    padding: 16px;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
    /* Clear bottom nav + safe area */
  }

  .main-inner {
    padding-bottom: 20px;
  }
}

.table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, .08);
  margin-top: 10px
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  background: rgba(255, 255, 255, .70)
}

.table th,
.table td {
  padding: 12px;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  text-align: right;
  font-size: 13px;
  vertical-align: middle;
}

.table th {
  color: var(--muted);
  font-weight: 800
}

.center {
  text-align: center
}

.label {
  display: block;
  font-weight: 800;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 12px 16px;
  margin-top: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  min-height: 52px;
  transition: all 0.2s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
  appearance: none;
  -webkit-appearance: none;
}

textarea.input {
  height: auto;
  line-height: 1.6;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-bg);
  background: white;
}

.mt {
  margin-top: 12px
}

.mt2 {
  margin-top: 18px
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--glass-border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.2s ease;
  user-select: none;
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: scale(0.97);
}

.btn:hover {
  background: hsl(var(--h), 20%, 98%);
  box-shadow: var(--shadow-md);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: transparent;
}

.btn-primary:hover {
  background: hsl(var(--h), 89%, 48%);
  color: white;
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: hsla(0, 84%, 60%, 0.2);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.w100 {
  width: 100%
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
}

.badge.badge-red {
  background: #dc2626 !important;
  color: #fff !important;
  border: 1px solid #b91c1c !important;
  box-shadow: 0 1px 2px rgba(220, 38, 38, 0.2);
}

.badge.ok {
  background: var(--ok-bg);
  border-color: hsla(142, 69%, 45%, 0.2);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-bg);
  border-color: hsla(38, 92%, 50%, 0.2);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-bg);
  border-color: hsla(0, 84%, 60%, 0.2);
  color: var(--danger);
}

.alert {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, .12);
  margin: 12px 0
}

.alert-danger {
  background: rgba(239, 68, 68, .12);
  border-color: rgba(239, 68, 68, .25)
}

.muted {
  color: var(--muted);
  font-size: 13px
}

.kv {
  display: flex;
  gap: 10px;
  margin: 8px 0;
  flex-wrap: wrap
}

.kv span {
  color: var(--muted);
  min-width: 92px
}

.right {
  text-align: left
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(120deg, rgba(37, 99, 235, .22), rgba(245, 158, 11, .20));
}

.auth-card {
  width: min(520px, 100%);
  background: rgba(255, 255, 255, .40);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 26px;
  padding: 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18)
}

.auth-head {
  text-align: center
}

.auth-head h1 {
  margin: 10px 0 6px;
  font-size: 22px
}

.auth-head p {
  margin: 0;
  color: var(--muted)
}

.auth-badge {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, .14);
  border: 1px solid rgba(37, 99, 235, .20);
  font-weight: 900
}

.auth-foot {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center
}

.pager {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  flex-wrap: wrap
}

.pager-left,
.pager-right,
.pager-mid {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap
}

.autocomplete {
  position: relative
}

.autolist {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 2000;
  background: rgba(255, 255, 255, .98);
  border: 1px solid rgba(15, 23, 42, .12);
  border-radius: 16px;
  overflow: hidden;
  max-height: 260px;
  overflow: auto;
  box-shadow: 0 16px 34px rgba(15, 23, 42, .14)
}

.autolist button {
  display: block;
  width: 100%;
  text-align: right;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer
}

.autolist button:hover {
  background: rgba(37, 99, 235, .08)
}

/* Invoice form – UI Finalization (v2.0.45) */
.inv-return-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr 0.5fr;
  gap: 12px;
  align-items: center;
  width: 100%;
}

@media (max-width: 980px) {
  .inv-return-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    height: auto !important;
  }

  /* Hide the header grid on mobile */
  .card .inv-return-grid:first-child:not(.mb) {
    display: none;
  }
}

.inv-return-grid>div {
  min-width: 0;
}

/* Unified Modern Return UI System (v2.3.1) */
.return-card-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.return-item-modern {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr 0.8fr;
  gap: 16px;
  align-items: center;
}

.return-item-modern:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
}

.return-item-modern.danger:hover {
  border-color: hsla(0, 84%, 60%, 0.3);
}

.r-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.r-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.r-value-box {
  background: hsla(var(--h), 20%, 96%, 0.5);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.r-check-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

@media (max-width: 1024px) {
  .return-item-modern {
    grid-template-columns: repeat(2, 1fr);
    padding: 18px;
  }

  .r-field.full {
    grid-column: span 2;
  }
}

@media (max-width: 600px) {
  .return-item-modern {
    grid-template-columns: 1fr;
  }

  .r-field {
    grid-column: span 1 !important;
  }
}

.checkbox-premium {
  width: 26px;
  height: 26px;
  cursor: pointer;
  accent-color: var(--primary);
  border-radius: 6px;
}

.inv-item-grid {
  display: grid;
  grid-template-columns: 1.8fr 0.6fr 0.7fr 0.45fr 1fr 0.8fr 0.75fr;
  gap: 12px;
  align-items: end;
  width: 100%;
  padding-bottom: 8px;
}

.inv-item-grid>div {
  min-width: 0;
}

.inv-item-grid .label {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Global High Contrast Form Styling (Sales, Purchase, Returns) */
.inv-item-grid .input,
.inv-product-row,
.inv-notes .input,
.inv-totals .input,
.inv-customer-search .input,
#invoiceForm .input,
.row .input {
  /* Index page filters */
  border-width: 1.5px !important;
  border-color: rgba(0, 0, 0, .32) !important;
  border-style: solid !important;
}

.inv-item-grid .input {
  padding: 10px 14px;
  height: 46px;
  font-size: 14px;
  font-family: inherit;
}

.inv-product-row {
  display: flex;
  align-items: stretch;
  background: var(--input-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 46px;
}

.inv-product-row .item-name {
  border: none !important;
  background: transparent !important;
  flex: 1;
  min-width: 0;
  height: 100%;
}

.inv-product-row .actions {
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(0, 0, 0, .15);
  /* Separator in RTL */
  width: 32px;
}

.inv-btn {
  flex: 1;
  width: 100%;
  border: none;
  border-radius: 0;
  background: rgba(0, 0, 0, .03);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.inv-plus {
  background: rgba(34, 197, 94, .15);
  color: #166534;
  border-bottom: 1px solid rgba(0, 0, 0, .1);
}

.inv-minus {
  background: rgba(239, 68, 68, .15);
  color: #991b1b;
}

.inv-btn:hover {
  filter: brightness(1.1);
  background: rgba(0, 0, 0, .08);
}

/* Footer: Notes right, Totals left in RTL */
.inv-note-sum {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 30px;
  align-items: start;
}

@media (max-width: 980px) {
  .inv-note-sum {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .inv-totals {
    width: 100%;
  }
}


/* Payable highlight on invoice view */
.kv-payable {
  background: rgba(0, 0, 0, .03);
  border: 2px solid rgba(0, 0, 0, .22);
  border-radius: 14px;
  padding: 10px 12px;
  margin-top: 8px;
}

.kv-payable b {
  font-weight: 900
}

/* Invoice create/edit: make item fields compact (desktop) */
.inv-item .inv-row-top {
  grid-template-columns: 2.2fr 0.6fr auto;
  align-items: end
}

.inv-item .inv-row-bot {
  grid-template-columns: 0.7fr 1fr 1fr;
}

.inv-item .inv-row-top .row {
  margin-top: 6px
}

.print-body {
  background: white;
  color: #111;
  font-family: "Vazirmatn", Tahoma, Arial
}

.print-page {
  width: 210mm;
  min-height: 297mm;
  margin: 10mm auto;
  background: white;
  color: #111;
  padding: 10mm;
  border: 1px solid #ddd
}

.print-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px
}

.print-title {
  font-weight: 900;
  font-size: 18px
}

.print-brand {
  display: flex;
  align-items: center;
  gap: 10px
}

.print-cust {
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 42%;
  gap: 6px
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px
}

.print-table th,
.print-table td {
  border: 1px solid #ddd;
  padding: 8px;
  font-size: 12px;
  text-align: right
}

.print-table th {
  background: #f3f4f6
}

.print-sum {
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
  max-width: 320px
}

.sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px
}

.sum-row.total {
  font-size: 14px;
  font-weight: 900
}

.print-notes {
  border: 1px dashed #bbb;
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px
}

.print-sign {
  display: flex;
  justify-content: space-between;
  margin-top: 18px
}

.print-sign>div {
  width: 45%;
  border-top: 1px solid #aaa;
  padding-top: 6px;
  text-align: center;
  font-size: 12px
}

.receipt-sep {
  border-top: 2px dashed #777;
  margin: 18px 0
}

.delivery-receipt {
  padding-top: 4px
}


/* Tabs (Settings) - Glass on light UI */
.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .55);
  border: 1px solid rgba(15, 23, 42, .10);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
}

.tab-btn {
  border: 1px solid rgba(15, 23, 42, .12);
  background: rgba(255, 255, 255, .40);
  color: rgba(15, 23, 42, .75);
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, .55);
}

.tab-btn.active {
  background: rgba(160, 110, 255, .22);
  border-color: rgba(160, 110, 255, .35);
  color: rgba(40, 10, 90, .95);
  box-shadow: 0 10px 24px rgba(80, 20, 180, .10);
}

/* Extra emphasis for Auth/Super tabs */
.tabs .tab-btn[data-tab="auth"].active {
  background: rgba(59, 130, 246, .18);
  border-color: rgba(59, 130, 246, .30);
  color: rgba(15, 23, 42, .92)
}

.tabs .tab-btn[data-tab="super"].active {
  background: rgba(168, 85, 247, .18);
  border-color: rgba(168, 85, 247, .30);
  color: rgba(15, 23, 42, .92)
}

.tab-pane {
  display: none;
  margin-top: 16px
}

.tab-pane.active {
  display: block
}

.p2 {
  padding: 12px
}

.btn-success {
  background: rgba(16, 185, 129, .12);
  border-color: rgba(16, 185, 129, .22)
}

.btn-success:hover {
  background: rgba(16, 185, 129, .16)
}

.hr {
  height: 1px;
  background: rgba(15, 23, 42, .08);
  width: 100%;
}


/* Dashboard cards */
.dash {
  padding-bottom: 76px;
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(520px, 1fr);
  gap: 14px;
  margin-top: 16px;
  align-items: start;
}

@media (max-width:1100px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

/* Payable-by-currency cards */
.dash-sum-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width:980px) {
  .dash-sum-grid {
    grid-template-columns: 1fr;
  }
}

.sum-curr-card {
  display: block;
  border-radius: 26px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  min-height: 84px;
  transform: translateZ(0);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.sum-curr-card::before {
  content: "";
  position: absolute;
  inset: -60px;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0));
  opacity: .55;
  pointer-events: none;
}

.sum-curr-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0));
  opacity: .22;
  pointer-events: none;
}

.sum-curr-card .sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px
}

.sum-curr-card .sum-label {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  padding-right: 44px;
}

.sum-curr-card .sum-amount {
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .2px;
  white-space: nowrap;
}

.sum-curr-card .sum-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .16);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  border: 1px solid rgba(255, 255, 255, .18);
  backdrop-filter: blur(10px)
}

.sum-curr-card:hover {
  transform: translateY(-2px);
  filter: saturate(1.05)
}

.sum-curr-card:active {
  transform: translateY(-1px) scale(.99)
}

@media (max-width:520px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  display: block;
  color: #fff;
  text-decoration: none;
  border-radius: 28px;
  padding: 20px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .18);
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: -80px;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0));
  opacity: .6;
  pointer-events: none;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0));
  opacity: .28;
  pointer-events: none;
}

.stat-card .stat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px
}

.stat-ico {
  width: 46px;
  height: 46px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .18);
  backdrop-filter: blur(10px)
}

.stat-ico svg {
  width: 22px;
  height: 22px;
  opacity: .98
}

.stat-num {
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .4px
}

.stat-title {
  font-size: 18px;
  font-weight: 900;
  margin-top: 14px
}

.stat-sub {
  opacity: .9;
  margin-top: 5px;
  font-size: 13px
}

.stat-line {
  position: absolute;
  left: 20px;
  bottom: 18px;
  width: 92px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .52)
}

.stat-card:hover {
  transform: translateY(-2px);
  filter: saturate(1.05)
}

.stat-card:active {
  transform: translateY(-1px) scale(.99)
}

.grad-blue {
  background: var(--grad-blue)
}

.grad-green {
  background: var(--grad-green)
}

.grad-purple {
  background: var(--grad-purple)
}

.sum-card {
  border-radius: 22px;
  text-align: center;
  padding: 22px
}

.sum-title {
  font-weight: 800;
  color: var(--muted)
}

.sum-val {
  font-size: 40px;
  font-weight: 900;
  color: #b45309;
  margin-top: 10px
}

.sum-val-lines {
  font-size: 22px;
  font-weight: 800;
  color: #b45309;
  margin-top: 10px;
  line-height: 1.9;
  text-align: center
}

.sum-unit {
  font-size: 14px;
  font-weight: 700;
  color: #64748b
}

.quick-card {
  border-radius: 22px
}

.quick-title {
  font-weight: 900;
  margin-bottom: 12px
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap
}

@media (max-width:520px) {
  .quick-actions .btn {
    flex: 1;
    justify-content: center
  }
}

/* Mobile bottom navigation (app-like) */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, .85);
  border-top: 1px solid rgba(15, 23, 42, .10);
  backdrop-filter: blur(14px);
  padding: 8px 10px 10px;
  z-index: 60;
}

.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 4px;
  border-radius: 14px;
}

.bn-ico {
  font-size: 18px;
  line-height: 1
}

.bn-item.active {
  color: var(--primary);
  background: rgba(37, 99, 235, .08)
}

@media (max-width:980px) {
  .bottom-nav {
    display: flex
  }
}

/* Customer financial status badges */
.fin-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center
}

.fin-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.2;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  white-space: nowrap
}

.fin-badge.debt {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412
}

.fin-badge.credit {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46
}

.fin-badge.wallet {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a
}


/* Payments form layout */
.pay-form-grid {
  display: grid;
  gap: 10px;
}

.pay-form-grid>* {
  min-width: 0
}

.pay-form-grid input[type="hidden"] {
  display: none !important
}

.pay-form-grid .input,
.pay-form-grid .select,
.pay-form-grid .btn {
  width: 100%;
}

@media (min-width: 768px) {

  /* amount | method | date | pick button | reference */
  .pay-form-grid {
    grid-template-columns: 1.2fr 1fr 1.6fr 1.2fr;
    align-items: end;
  }

  .pay-form-grid .btn {
    width: auto;
    min-width: 120px;
  }
}


/* Payments date group */
.pay-date-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end
}

/* On small screens, the generic .pay-form-grid .btn{width:100%} would crush the date input.
   Keep the input readable by letting it flex and sizing the button to its content. */
.pay-form-grid .pay-date-wrap .input {
  flex: 1;
  min-width: 0
}

.pay-form-grid .pay-date-wrap .btn {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap
}



/* ===== Dashboard (Modern) ===== */
.dash {
  padding: 18px
}

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px
}

.dash-title {
  display: flex;
  flex-direction: column;
  gap: 6px
}

.dash-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .06);
  border: 1px solid rgba(15, 23, 42, .08);
  width: max-content;
  font-size: 12px
}

.dash-h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.2px
}

.dash-sub {
  font-size: 12px;
  color: rgba(15, 23, 42, .72)
}

/* Layout per requested mock:
   - left: 4 cards in 2x2
   - right: "مانده قابل پرداخت" spans two rows */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(520px, 1fr);
  gap: 14px;
  align-items: start;
}

.dash-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0
}

.dash-col-main .due-card {
  min-height: 190px
}

.dash-col-main .due-card.dash-size-sm {
  min-height: 170px
}

.dash-col-main .due-card.dash-size-md {
  min-height: 190px
}

.dash-col-main .due-card.dash-size-lg {
  min-height: 230px
}

.tiles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px
}

.tiles-grid .dash-card {
  height: 118px;
  min-height: 0
}

.tiles-grid .dash-card.dash-size-sm {
  height: 98px
}

.tiles-grid .dash-card.dash-size-md {
  height: 118px
}

.tiles-grid .dash-card.dash-size-lg {
  height: 150px
}

.tiles-grid .dash-card.span-2 {
  grid-column: 1 / -1
}

.tiles-grid .dash-card.sum-card {
  height: auto;
  min-height: 190px
}

.tiles-grid .dash-card.sum-card.dash-size-sm {
  min-height: 170px
}

.tiles-grid .dash-card.sum-card.dash-size-md {
  min-height: 190px
}

.tiles-grid .dash-card.sum-card.dash-size-lg {
  min-height: 230px
}

/* Financial KPI row: 2 equal cards on desktop */
.summary-section {
  margin-top: 16px
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  direction: rtl;
  align-items: stretch
}

.summary-grid .dash-card {
  min-height: 190px
}

.summary-grid .dash-card.dash-size-sm {
  min-height: 170px
}

.summary-grid .dash-card.dash-size-md {
  min-height: 190px
}

.summary-grid .dash-card.dash-size-lg {
  min-height: 230px
}

@media (max-width:1240px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr))
  }
}

@media (max-width:700px) {
  .summary-grid {
    grid-template-columns: 1fr
  }
}

@media (max-width:1100px) {
  .dash-grid {
    grid-template-columns: 1fr
  }

  .tiles-grid {
    grid-template-columns: 1fr 1fr
  }
}

@media (max-width:600px) {
  .tiles-grid {
    grid-template-columns: 1fr
  }

  .tiles-grid .dash-card.span-2 {
    grid-column: 1
  }

  .summary-grid {
    grid-template-columns: 1fr
  }
}


/* Card base */
.dash-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 18px;
  border-radius: 22px;
  text-decoration: none;
  color: #fff;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 10px 28px rgba(2, 6, 23, .14);
  transition: transform .18s ease, box-shadow .18s ease;
  min-height: 112px;
}

/* Compact cards: used for management tiles with small KPI content */
.dash-card.compact {
  min-height: 88px;
  padding: 12px 14px;
  border-radius: 20px
}

.dash-card.compact .dash-ico {
  width: 36px;
  height: 36px;
  border-radius: 12px
}

.dash-card.compact .dash-num {
  font-size: 15px
}

.dash-card.compact .dash-label {
  font-size: 11px
}

.dash-card.compact .dash-card-foot {
  font-size: 11px
}

.dash-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(2, 6, 23, .16)
}

.dash-card:before {
  content: "";
  position: absolute;
  inset: -40px;
  background:
    radial-gradient(circle at 25% 20%, rgba(255, 255, 255, .28), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, .18), transparent 55%);
  opacity: .9
}

.dash-card:after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02));
  backdrop-filter: blur(8px)
}

.dash-card>* {
  position: relative;
  z-index: 1
}

.dash-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px
}

.dash-ico {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .18)
}

.dash-ico svg {
  width: 24px;
  height: 24px
}

.dash-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px
}

.dash-num {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -.2px;
  line-height: 1.15
}

.dash-label {
  font-size: 12px;
  opacity: .92
}

.dash-card-foot {
  font-size: 12px;
  opacity: .9;
  margin-top: auto
}

.dash-actions {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: 0 10px 25px rgba(2, 6, 23, .06);
  direction: rtl
}

.dash-actions-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 10px;
  text-align: right
}

.dash-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  direction: rtl;
  justify-content: flex-start
}

/* Themes */
.theme-blue {
  background: linear-gradient(135deg, #1D4ED8, #2563EB)
}

.theme-green {
  background: linear-gradient(135deg, #059669, #10B981)
}

.theme-purple {
  background: linear-gradient(135deg, #7C3AED, #A855F7)
}

.theme-indigo {
  background: linear-gradient(135deg, #4F46E5, #1D4ED8)
}

.theme-amber {
  background: linear-gradient(135deg, #B45309, #F59E0B)
}

.theme-emerald {
  background: linear-gradient(135deg, #065F46, #10B981)
}

.theme-rose {
  background: linear-gradient(135deg, #9F1239, #F43F5E)
}

.theme-slate {
  background: linear-gradient(135deg, #0F172A, #334155)
}

/* Summary cards (debtor/creditor/wallet) */
.sum-card {
  min-height: 190px
}

/* Due cards (RTL-safe numeric layout) */
.due-card {
  min-height: 210px;
}

/* Dashboard placement (desktop)
   3 columns:
   Row 1: Due(Sale) | Customers | Products
   Row 2: Due(Purchase) | Sales | Purchases
   Row 3: Finance (full width)
*/
/* NOTE:
   Do NOT hard-code grid placement for dashboard cards here.
   Cards are laid out by their local grids (tiles-grid / summary-grid) and by the two-column dash-grid wrapper.
   Hard-coded placement rules caused broken alignment/collapsing when cards were nested inside grids.
*/
.due-card .due-layout,
.sum-card .due-layout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px
}

.due-card .due-title,
.sum-card .due-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 170px
}

.due-card .due-title-text,
.sum-card .due-title-text {
  display: flex;
  flex-direction: column;
  gap: 2px
}

.due-card .due-h,
.sum-card .due-h {
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2
}

.due-card .due-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 260px;
  flex: 1
}

.sum-card .due-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  flex: 1
}

.due-card .due-row,
.sum-card .due-row {
  display: grid;
  /* RTL-friendly row: [go] [amount] [currency]
     visually: right=go, middle=amount, left=currency (like: تومان ۹۰,۰۰۰) */
  direction: rtl;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  column-gap: 10px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .20);
  padding: 11px 14px;
  border-radius: 18px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease
}

.due-card .due-row:hover,
.sum-card .due-row:hover {
  background: rgba(255, 255, 255, .20);
  border-color: rgba(255, 255, 255, .28);
  transform: translateY(-1px)
}

.due-card .due-cur,
.sum-card .due-cur {
  font-weight: 900;
  opacity: .95;
  white-space: nowrap
}

.due-card .due-amt,
.sum-card .due-amt {
  font-weight: 900;
  letter-spacing: -.2px;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: right
}

.due-card .due-go,
.sum-card .due-go {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .22);
}

.due-card .due-go svg,
.sum-card .due-go svg {
  width: 18px;
  height: 18px;
  opacity: .92
}

/* Slightly tighter density for summary cards */
.sum-card .due-row {
  padding: 10px 12px;
  border-radius: 16px
}

.sum-card .due-rows {
  gap: 8px
}

/* Summary cards: make currency rows wider (requested)
   - Reduce title min width so rows have more space
   - Fix the currency column width so pills look consistent */
.sum-card .due-title {
  min-width: 140px
}

.sum-card .due-rows {
  min-width: 320px
}

.sum-card .due-row {
  grid-template-columns: 36px 1fr 110px
}

/* Responsive (dashboard) */
@media (max-width:1100px) {
  .dash-grid {
    grid-template-columns: 1fr
  }
}

@media (max-width:768px) {
  .dash {
    padding: 12px
  }

  .dash-h1 {
    font-size: 18px
  }

  .dash-card {
    min-height: 98px;
    padding: 14px 14px;
    border-radius: 20px
  }

  .dash-ico {
    width: 38px;
    height: 38px;
    border-radius: 12px
  }

  /* Due card becomes vertical for narrow screens */
  .due-card {
    border-radius: 22px
  }

  .due-card .due-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 12px
  }

  .due-card .due-title {
    justify-content: space-between
  }

  .due-card .due-rows {
    min-width: 0
  }

  .due-card .due-row {
    padding: 10px 12px;
    border-radius: 16px
  }

  /* Shortcuts: true right alignment + stacked buttons */
  .dash-actions {
    padding: 12px 12px
  }

  .dash-actions-title {
    text-align: right
  }

  .dash-actions-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    direction: rtl;
    justify-content: flex-start
  }

  .dash-actions-row a {
    width: 100%;
    justify-content: center
  }
}

@media (max-width:420px) {
  .sum-card .due-rows {
    min-width: 0
  }

  .sum-card .due-row {
    grid-template-columns: 36px 1fr auto
  }
}




/* ===== UI: Power logout in topbar (right) ===== */
.btn-power-logout {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 60, 60, .14);
  color: #ff2a2a;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .10);
  transition: transform .15s ease, background .15s ease;
}

.btn-power-logout:hover {
  transform: translateY(-1px);
  background: rgba(255, 60, 60, .22)
}

.btn-power-logout:active {
  transform: translateY(0)
}

/* Sidebar: allow scrolling when menu grows */
.sb-nav {
  flex: 1;
  overflow: auto;
  padding-bottom: 12px;
}

/* Settings tabs: glass background + distinct active state */
#settingsTabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .35);
  border: 1px solid rgba(255, 255, 255, .40);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#settingsTabs .tab-btn {
  background: rgba(255, 255, 255, .25);
  border: 1px solid rgba(255, 255, 255, .35);
  color: rgba(0, 0, 0, .55);
  padding: 10px 14px;
  border-radius: 14px;
}

#settingsTabs .tab-btn:hover {
  background: rgba(255, 255, 255, .35);
  color: rgba(0, 0, 0, .75)
}

#settingsTabs .tab-btn.active {
  background: rgba(160, 110, 255, .22);
  border-color: rgba(160, 110, 255, .35);
  color: rgba(40, 10, 90, .95);
  box-shadow: 0 10px 24px rgba(80, 20, 180, .12);
}

/* Hamburguer / Menu UI cleanup - redundant parts removed */

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.05);
}

@media (max-width: 980px) {
  .mobile-menu-btn {
    display: flex;
  }

  .main-inner {
    padding-top: 70px;
  }
}

/* Sidebar close button (mobile) - Corrected RTL positioning */
.sb-close-btn {
  display: none;
  position: absolute;
  top: 16px;
  left: 16px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, .25);
  background: rgba(239, 68, 68, .10);
  color: #dc2626;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s ease;
  z-index: 1001;
  /* Above everything */
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(239, 68, 68, .15);
}

.sb-close-btn:hover {
  background: rgba(239, 68, 68, .18);
  transform: scale(1.05);
}

@media (max-width: 980px) {
  .sb-close-btn {
    display: flex;
  }
}

/* Premium Sidebar Footer (Refined) */
.sb-footer {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid rgba(15, 23, 42, .05);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: hsla(var(--h), 20%, 98%, 0.4);
  border-radius: 0 0 0 14px;
}

@media (max-width: 980px) {
  .sb-footer {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
    /* Extra room to ensure date is above floating bottom-nav */
  }

  .sb-date-card {
    padding: 8px 10px;
    gap: 8px;
  }

  .sb-date-icon {
    width: 28px;
    height: 28px;
  }

  .sb-date-icon svg {
    width: 16px;
    height: 16px;
  }

  .sb-date-value {
    font-size: 11.5px;
  }
}

/* Bottom nav - Modern Floating App Look */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 20px;
  right: 20px;
  height: 64px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  z-index: 1000;
  padding: 0 10px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
  border-radius: 20px;
}

@media (max-width: 980px) {
  .bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
}

@keyframes bn-pop {
  0% {
    transform: scale(1) translateY(0);
  }

  50% {
    transform: scale(1.1) translateY(-4px);
  }

  100% {
    transform: scale(1) translateY(-2px);
  }
}

.bn-item.active {
  color: var(--primary);
  background: hsla(var(--h), 89%, 54%, 0.1);
  animation: bn-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.bn-item:active {
  transform: scale(0.95);
}

.bn-ico {
  font-size: 18px;
  transition: transform 0.2s ease;
}

.bn-txt {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1px;
}

/* Mobile-First Table -> Cards transformation */
@media (max-width: 768px) {
  .responsive-table {
    display: block;
    background: transparent;
    border: 0;
    min-width: 0;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .responsive-table tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
  }

  .responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dotted hsla(var(--h), 20%, 90%, 0.8);
    text-align: left;
    font-size: 14px;
    min-height: 44px;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
    justify-content: center;
    gap: 10px;
  }

  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
    font-size: 12px;
  }
}



/* Override and improve mobile UI */

/* Mobile menu button - Better visibility */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 90;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(37, 99, 235, .30);
  transition: all .2s ease;
}

/* Hamburger icon */
.menu-icon {
  position: relative;
  width: 22px;
  height: 2px;
  background: white;
  display: block;
  border-radius: 2px;
  pointer-events: none;
}

.menu-icon::before,
.menu-icon::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 2px;
  background: white;
  border-radius: 2px;
  left: 0;
}

.menu-icon::before {
  top: -7px;
}

.menu-icon::after {
  top: 7px;
}

.mobile-menu-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(37, 99, 235, .40);
}

.mobile-menu-btn:active {
  transform: translateY(0);
}

@media (max-width: 980px) {
  .mobile-menu-btn {
    display: flex;
  }

  .main-inner {
    padding-top: 76px;
  }
}

/* Duplicate sb-close-btn removed (Pruning for v2.2.1) */

/* Old mobile footer redundant styles removed */

/* Refined Consolidated Header (v2.0.4) */
.grid-header-compact {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
  background: var(--surface);
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 1200px) {
  .grid-header-compact {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .grid-header-compact {
    grid-template-columns: 1fr;
  }
}

.grid-header-compact>* {
  min-width: 0;
}

.grid-header-compact .btn {
  flex: 0 0 auto;
}

@media (max-width: 600px) {
  .grid-header-compact>* {
    min-width: 100%;
  }
}

.grid-header-compact .input,
.grid-header-compact select.input {
  height: 48px !important;
  font-size: 14px;
}

/* Modern Integrated Date Picker */
.modern-picker-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.modern-picker-wrapper .input {
  width: 100%;
  padding-left: 80px !important;
  /* Make room for the button (RTL) */
}

.modern-picker-btn {
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  height: 36px !important;
  min-width: 65px;
  border-radius: 12px !important;
  background: var(--primary) !important;
  color: white !important;
  font-size: 11px !important;
  font-weight: bold;
  border: none;
  cursor: pointer;
  z-index: 5;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modern-picker-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Refined Per-Row Stock UI (v2.1.0) - Restored Grid for Desktop */

.item-stup-container {
  display: flex;
  flex-direction: column;
  position: relative;
}

.item-stock-info {
  font-size: 10px;
  text-align: center;
  width: 100%;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 2px;
  white-space: nowrap;
}

@media print {

  /* Hide the entire application UI */
  .app-shell,
  .sidebar,
  .topbar,
  .bottom-nav,
  .alert,
  #trialPopup,
  .mobile-menu-btn,
  .pager,
  .btn,
  .form-control,
  .table-wrap .btn,
  .topbar-spacer,
  .sb-overlay {
    display: none !important;
  }

  /* Isolation for Generated Reports */
  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-engine-output {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 30px !important;
    background: #fff !important;
    z-index: 9999 !important;
  }

  .print-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-top: 15px !important;
  }

  .print-table th,
  .print-table td {
    border: 1px solid #000 !important;
    padding: 8px !important;
    color: #000 !important;
  }

  .print-table th {
    background: #eee !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

.print-engine-output {
  display: none;
}



.inv-col-stup select {
  font-size: 11px !important;
}


@media (max-width: 600px) {
  .inv-item-grid {
    grid-template-columns: 1fr;
  }

  .inv-col-product {
    grid-column: span 1;
  }
}