:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #68748a;
  --border: #e3e8f1;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --navy: #10213f;
  --success: #15965f;
  --success-soft: #ecfdf5;
  --danger: #dc3f4f;
  --danger-soft: #fff1f2;
  --warning: #d98712;
  --warning-soft: #fff8e8;
  --shadow-sm: 0 1px 2px rgba(16, 33, 63, .04), 0 4px 14px rgba(16, 33, 63, .04);
  --shadow: 0 16px 42px rgba(16, 33, 63, .12);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(37, 99, 235, .08), transparent 26rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  min-width: 0;
  max-width: 100%;
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  vertical-align: -0.16em;
}

.eyebrow {
  display: block;
  color: var(--primary);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .14em;
}

.logo-mark {
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  border-radius: 15px;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .25);
}

.logo-mark .icon {
  width: 26px;
  height: 26px;
  stroke-width: 1.9;
}

.logo-mark.small {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  box-shadow: none;
}

.logo-mark.small .icon {
  width: 21px;
  height: 21px;
}

.login-screen {
  display: grid;
  width: 100%;
  max-width: 100vw;
  min-height: 100dvh;
  padding: 24px;
  place-items: center;
  overflow-x: hidden;
}

.login-card {
  width: min(100%, 430px);
  min-width: 0;
  max-width: 100%;
  padding: 36px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(227, 232, 241, .9);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 15px;
}

.login-brand h1 {
  margin: 3px 0 0;
  font-size: 1.65rem;
  line-height: 1.1;
  letter-spacing: -.04em;
}

.login-brand h1 i {
  color: var(--primary);
  font-style: normal;
}

.login-copy {
  margin: 24px 0;
  color: var(--muted);
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  color: #344157;
  font-size: .83rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid #d8dfeb;
  border-radius: 11px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

input[readonly],
input:disabled,
select:disabled {
  color: var(--muted);
  background: #f2f5f9;
}

.password-field,
.search-field {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.password-field input {
  padding-right: 62px;
}

.input-action {
  position: absolute;
  top: 50%;
  right: 6px;
  padding: 6px 9px;
  color: var(--primary);
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: .75rem;
  font-weight: 800;
  transform: translateY(-50%);
}

.form-error {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: .82rem;
  text-align: center;
}

.app-shell {
  width: 100%;
  max-width: 100vw;
  min-height: 100dvh;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 24px;
  padding: 0 max(22px, calc((100vw - 1320px) / 2));
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid rgba(227, 232, 241, .9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 11px;
}

.brand > span:last-child {
  display: grid;
  line-height: 1.1;
}

.brand strong {
  font-size: .98rem;
  letter-spacing: -.02em;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: .69rem;
}

.desktop-nav {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.desktop-nav a {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  color: #59667b;
  border-radius: 10px;
  font-size: .79rem;
  font-weight: 750;
  transition: color .18s, background .18s;
}

.desktop-nav a:hover {
  color: var(--text);
  background: #f3f6fa;
}

.desktop-nav a.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  color: #58667c;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.icon-button:hover {
  color: var(--primary);
  border-color: #cbd9f8;
  background: var(--primary-soft);
}

.user-chip {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  background: var(--navy);
  border-radius: 50%;
  font-size: .78rem;
  font-weight: 850;
}

.main-content {
  width: min(100%, 1320px);
  min-width: 0;
  max-width: 100vw;
  min-height: calc(100dvh - 66px);
  margin: 0 auto;
  padding: 32px 22px 56px;
  overflow-x: hidden;
}

.page {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  animation: page-in .28s ease both;
}

.page > *,
.page-heading > *,
.detail-title > *,
.section-head > *,
.job-row > *,
.movement-row > * {
  min-width: 0;
  max-width: 100%;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(5px); }
}

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

.page-heading h1 {
  margin: 2px 0 4px;
  font-size: clamp(1.55rem, 2.6vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -.045em;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
}

.heading-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  color: #425069;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: .81rem;
  font-weight: 800;
  transition: transform .12s, background .18s, border-color .18s, color .18s;
}

.button:hover {
  border-color: #cbd4e2;
  background: #f8fafc;
}

.button:active {
  transform: scale(.98);
}

.button:disabled {
  cursor: wait;
  opacity: .62;
}

.button.primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(37, 99, 235, .18);
}

.button.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.button.secondary {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #dce8ff;
}

.button.success {
  color: var(--success);
  background: var(--success-soft);
  border-color: #c7f0dc;
}

.button.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #ffd9dd;
}

.button.danger.ghost {
  background: transparent;
  border-color: transparent;
}

.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: .74rem;
}

.button.icon-only {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.button.wide,
.wide {
  width: 100%;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 750;
}

.back-link:hover {
  color: var(--primary);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  min-width: 230px;
  flex: 1;
}

.search-box .icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 13px;
  color: #8792a5;
  transform: translateY(-50%);
}

.search-box input {
  padding-left: 40px;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-sm);
}

.card {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 20px;
}

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

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

.client-card {
  position: relative;
  display: flex;
  min-height: 190px;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}

.client-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #70a0ff);
  content: "";
}

.client-card.debtor {
  background: linear-gradient(155deg, #fff 45%, #fff4f4);
  border-color: #fecaca;
}

.client-card.debtor::before {
  background: linear-gradient(90deg, #dc3f4f, #fb7185);
}

.client-card.settled {
  border-color: #bbecd5;
}

.client-card.settled::before {
  background: linear-gradient(90deg, #15965f, #4ade80);
}

.debt-flag {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  margin: 1px 0 10px;
  padding: 3px 9px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #fecdd3;
  border-radius: 999px;
  font-size: .64rem;
  font-weight: 850;
  letter-spacing: .02em;
}

.debt-flag.settled {
  color: var(--success);
  background: var(--success-soft);
  border-color: #bbecd5;
}

.client-card:hover {
  border-color: #cad8f4;
  box-shadow: 0 14px 34px rgba(16, 33, 63, .09);
  transform: translateY(-2px);
}

.client-card h3 {
  margin: 3px 0 8px;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: -.02em;
}

.location {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  color: var(--muted);
  font-size: .76rem;
}

.location .icon {
  color: var(--primary);
}

.last-activity {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
}

.last-activity .icon {
  color: var(--primary);
}

.client-numbers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
  padding-top: 14px;
  border-top: 1px solid #edf0f5;
}

.client-numbers span {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: .67rem;
}

.client-numbers strong {
  min-width: 0;
  color: var(--text);
  font-size: .88rem;
  overflow-wrap: anywhere;
}

.client-card-actions {
  display: flex;
  gap: 7px;
  margin-top: auto;
}

.client-card-actions .button:first-child {
  flex: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 20px;
}

.stats-grid.stats-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-grid.stats-two,
.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
  position: relative;
  min-height: 116px;
  padding: 18px;
  overflow: hidden;
}

.stat-card .stat-icon {
  display: grid;
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 10px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: .73rem;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(1.25rem, 2.1vw, 1.7rem);
  line-height: 1.15;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.stat-card.success .stat-icon,
.stat-card.success {
  color: var(--success);
}

.stat-card.success .stat-icon {
  background: var(--success-soft);
}

.stat-card.danger .stat-icon,
.stat-card.danger {
  color: var(--danger);
}

.stat-card.danger .stat-icon {
  background: var(--danger-soft);
}

.stat-card.warning .stat-icon,
.stat-card.warning {
  color: var(--warning);
}

.stat-card.warning .stat-icon {
  background: var(--warning-soft);
}

.section-card {
  margin-top: 18px;
  overflow: hidden;
}

.section-head {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 19px;
  background: #fbfcfe;
  border-bottom: 1px solid var(--border);
}

.section-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: .98rem;
  letter-spacing: -.02em;
}

.section-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .72rem;
}

.section-body {
  padding: 19px;
}

.table-wrap {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}

th {
  padding: 12px 14px;
  color: #738096;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid #edf0f4;
  font-size: .8rem;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fbfcff;
}

.clickable-row,
.clickable-card {
  cursor: pointer;
}

.clickable-row:hover td {
  background: var(--primary-soft);
}

.clickable-card:hover {
  border-color: #a9c1f8;
  background: var(--primary-soft);
}

.open-cue {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--primary);
  font-size: .67rem;
  font-weight: 800;
}

.debtor-row td {
  background: #fffafa;
}

.align-right {
  text-align: right;
}

.number {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.money-positive {
  color: var(--success);
  font-weight: 800;
}

.money-negative {
  color: var(--danger);
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.mini {
  font-size: .69rem;
}

.badge {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  color: #59667a;
  background: #f0f3f7;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.success {
  color: var(--success);
  background: var(--success-soft);
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.badge.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.detail-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.detail-title h1 {
  margin: 0 0 8px;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  line-height: 1.15;
  letter-spacing: -.04em;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.job-list,
.movement-list {
  display: grid;
  gap: 10px;
}

.job-row,
.movement-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  transition: border-color .18s, background .18s;
}

.job-row:hover,
.movement-row:hover {
  background: #fbfcff;
  border-color: #cfdaed;
}

.job-main h3,
.movement-main h3 {
  margin: 0;
  font-size: .88rem;
}

.job-meta,
.movement-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  color: var(--muted);
  font-size: .7rem;
}

.job-side,
.movement-side {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 7px;
}

.job-side strong,
.movement-side strong {
  font-size: .92rem;
}

.job-lines {
  grid-column: 1 / -1;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 10px;
}

.job-lines div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 6px 0;
  color: #526078;
  border-bottom: 1px dashed #dfe5ee;
  font-size: .72rem;
}

.job-lines div:last-child {
  border-bottom: 0;
}

.tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 14px;
  padding: 4px;
  background: #eef2f7;
  border-radius: 12px;
}

.tabs button {
  min-height: 36px;
  flex: 1;
  padding: 7px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: .75rem;
  font-weight: 800;
}

.tabs button.active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 2px 8px rgba(16, 33, 63, .08);
}

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

.employee-card {
  position: relative;
  padding: 20px;
  overflow: hidden;
}

.employee-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--success);
  content: "";
}

.employee-card.debt::before {
  background: var(--danger);
}

.employee-card h3 {
  margin: 0;
  font-size: 1rem;
}

.employee-balance {
  margin: 22px 0;
}

.employee-balance span {
  display: block;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 750;
  text-transform: uppercase;
}

.employee-balance strong {
  display: block;
  margin-top: 3px;
  font-size: 1.55rem;
  letter-spacing: -.04em;
}

.empty-state {
  display: grid;
  min-height: 280px;
  padding: 36px 20px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #cdd6e4;
  border-radius: var(--radius);
  text-align: center;
}

.empty-state .empty-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 13px;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 18px;
}

.empty-state h3 {
  margin: 0 0 5px;
  color: var(--text);
}

.empty-state p {
  max-width: 430px;
  margin: 0;
  font-size: .82rem;
}

.filter-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 12px;
}

.filter-row label {
  margin: 0;
}

.cash-movement {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
}

.movement-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--success);
  background: var(--success-soft);
  border-radius: 11px;
}

.movement-icon.expense {
  color: var(--danger);
  background: var(--danger-soft);
}

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

.denomination-grid label {
  margin: 0;
}

.denomination {
  position: relative;
}

.denomination span {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  font-size: .72rem;
  transform: translateY(-50%);
}

.denomination input {
  padding-right: 48px;
}

.closing-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.closing-summary div {
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.closing-summary span {
  display: block;
  color: var(--muted);
  font-size: .67rem;
}

.closing-summary strong {
  display: block;
  margin-top: 3px;
  font-size: 1rem;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  padding: 20px;
  overflow: auto;
  place-items: center;
  background: rgba(10, 20, 40, .55);
  backdrop-filter: blur(5px);
  animation: fade .18s ease both;
}

@keyframes fade {
  from { opacity: 0; }
}

.modal {
  width: min(100%, 620px);
  min-width: 0;
  max-width: 100%;
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 20px;
  box-shadow: 0 28px 80px rgba(5, 14, 31, .28);
  animation: modal-in .2s ease both;
}

.modal.large {
  width: min(100%, 820px);
}

.modal.print-modal {
  width: min(100%, 920px);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
}

.modal-head {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -.025em;
}

.modal-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .74rem;
}

.modal-body {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 22px;
  overflow-x: hidden;
}

.modal-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 15px 22px;
  background: rgba(250, 251, 253, .96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.line-items {
  display: grid;
  gap: 9px;
}

.line-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 90px 125px 105px 36px;
  align-items: end;
  gap: 8px;
  padding: 11px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.line-row label {
  margin: 0;
  font-size: .68rem;
}

.line-row input {
  min-height: 39px;
}

.line-subtotal {
  display: grid;
  min-height: 39px;
  align-items: center;
  padding: 0 8px;
  font-size: .77rem;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.form-total {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 13px;
  padding: 12px 2px;
}

.form-total span {
  color: var(--muted);
  font-size: .78rem;
}

.form-total strong {
  font-size: 1.25rem;
}

.toast-region {
  position: fixed;
  z-index: 200;
  top: 78px;
  right: 18px;
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 9px;
}

.toast {
  padding: 13px 15px;
  color: #fff;
  background: var(--navy);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: .79rem;
  font-weight: 700;
  animation: toast-in .2s ease both;
}

.toast.error {
  background: #a61f32;
}

.toast.success {
  background: #08724a;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(10px); }
}

.mobile-nav {
  display: none;
}

.more-sheet {
  position: fixed;
  z-index: 90;
  inset: 0;
}

.sheet-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(9, 18, 35, .5);
  border: 0;
}

.sheet-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 10px 18px max(22px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 50px rgba(10, 20, 40, .18);
  animation: sheet-in .22s ease both;
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 12px;
  background: #d4dbe6;
  border-radius: 4px;
}

.sheet-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-title h2 {
  margin: 2px 0 0;
  font-size: 1.1rem;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 15px;
}

.sheet-grid a,
.sheet-grid .sheet-link {
  display: flex;
  width: 100%;
  min-height: 66px;
  align-items: center;
  gap: 10px;
  padding: 13px;
  color: var(--text);
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 13px;
  font-size: .78rem;
  font-weight: 750;
  text-align: left;
}

.sheet-grid a .icon,
.sheet-grid .sheet-link .icon {
  color: var(--primary);
  font-size: 1.25rem;
}

.albaran-sheet {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 900px;
  padding: 48px;
  color: #111827;
  background: #fff;
}

.albaran-head {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 24px;
  border-bottom: 3px solid var(--primary);
}

.albaran-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
}

.albaran-brand h1 {
  margin: 0;
  font-size: 1.35rem;
}

.albaran-brand p,
.albaran-number p {
  margin: 3px 0 0;
  color: #667085;
  font-size: .76rem;
}

.albaran-number {
  min-width: 0;
  text-align: right;
}

.albaran-number strong {
  display: block;
  color: var(--primary);
  font-size: 1.15rem;
}

.albaran-client {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  margin: 30px 0;
  padding: 18px;
  background: #f7f9fc;
  border-radius: 12px;
}

.albaran-client span {
  display: block;
  margin-bottom: 5px;
  color: #748096;
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.albaran-client strong {
  font-size: .95rem;
}

.albaran-table th {
  background: #10213f;
  color: #fff;
}

.albaran-table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}

.albaran-table th:first-child,
.albaran-table td:first-child {
  width: 46%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.albaran-table th:not(:first-child),
.albaran-table td:not(:first-child) {
  width: 18%;
  white-space: normal;
}

.albaran-total {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.albaran-total div {
  min-width: 240px;
  padding: 15px 18px;
  color: #fff;
  background: var(--primary);
  border-radius: 10px;
  text-align: right;
}

.albaran-total span {
  display: block;
  font-size: .68rem;
  opacity: .85;
}

.albaran-total strong {
  font-size: 1.5rem;
}

.albaran-footer {
  margin-top: 70px;
  padding-top: 16px;
  color: #7a8597;
  border-top: 1px solid #e5e9f0;
  font-size: .68rem;
  text-align: center;
}

@media (max-width: 1120px) {
  .desktop-nav a {
    padding: 8px 9px;
  }

  .client-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    display: none;
  }

  .desktop-nav {
    display: none;
  }

  .main-content {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    margin: 0;
    padding: 10px max(8px, env(safe-area-inset-left)) calc(84px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  }

  .mobile-nav {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: calc(66px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(5, 1fr);
    align-items: start;
    padding: 7px 8px env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 28px rgba(16, 33, 63, .08);
    backdrop-filter: blur(18px);
  }

  .mobile-nav a,
  .mobile-nav > button:not(.quick-add) {
    display: flex;
    min-height: 50px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 3px;
    color: #7a8698;
    background: transparent;
    border: 0;
    font-size: .64rem;
    font-weight: 750;
  }

  .mobile-nav a .icon,
  .mobile-nav > button .icon {
    width: 21px;
    height: 21px;
  }

  .mobile-nav a.active {
    color: var(--primary);
  }

  .mobile-nav .quick-add {
    display: grid;
    width: 52px;
    height: 52px;
    margin: -23px auto 0;
    padding: 0;
    place-items: center;
    color: #fff;
    background: var(--primary);
    border: 5px solid var(--bg);
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .3);
  }

  .mobile-nav .quick-add .icon {
    width: 23px;
    height: 23px;
  }

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

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

  .stats-grid.stats-three,
  .stats-grid.stats-two,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 620px) {
  body {
    background: #f4f7fb;
    font-size: 15px;
  }

  .main-content {
    width: 100%;
    max-width: 100vw;
    padding-top: 8px;
    padding-right: max(7px, env(safe-area-inset-right));
    padding-left: max(7px, env(safe-area-inset-left));
  }

  .login-screen {
    display: block;
    min-height: 100dvh;
    padding: 0;
    background: var(--surface);
  }

  .login-card {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    min-height: 100dvh;
    padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .login-card > *,
  .login-card label,
  .login-card input,
  .login-card .password-field {
    min-width: 0;
    max-width: 100%;
  }

  .login-card input {
    min-height: 48px;
    font-size: 16px;
  }

  .login-card .button {
    min-height: 48px;
    font-size: .95rem;
  }

  .login-brand h1 {
    font-size: 1.75rem;
  }

  .login-copy {
    font-size: .95rem;
    line-height: 1.5;
  }

  .page-heading,
  .detail-title {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading {
    margin-bottom: 18px;
  }

  .heading-actions,
  .detail-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
    width: 100%;
  }

  .heading-actions .button,
  .detail-actions .button {
    width: 100%;
    min-height: 46px;
    font-size: .88rem;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    min-width: 0;
  }

  .client-grid,
  .employee-grid,
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .client-card {
    min-height: 0;
    padding: 17px;
  }

  .stats-grid {
    gap: 9px;
  }

  .stats-grid.stats-three,
  .stats-grid.stats-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 112px;
    padding: 16px;
  }

  .stat-card strong {
    font-size: clamp(1.1rem, 5.5vw, 1.4rem);
  }

  .stat-card .stat-icon {
    width: 29px;
    height: 29px;
    margin-bottom: 9px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head .inline-actions {
    width: 100%;
  }

  .section-head .inline-actions .button {
    flex: 1;
  }

  .section-body {
    padding: 13px;
  }

  .job-row,
  .movement-row {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 14px;
  }

  .job-side,
  .movement-side {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    justify-items: start;
    text-align: left;
  }

  .job-lines div {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .job-lines div span:nth-child(2) {
    display: none;
  }

  .cash-movement {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .cash-movement .movement-side {
    grid-column: 1 / -1;
    padding-top: 9px;
    border-top: 1px solid #edf0f4;
  }

  .cash-movement .open-cue {
    width: 100%;
    justify-content: flex-end;
  }

  .tabs {
    justify-content: flex-start;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .tabs button {
    min-width: max-content;
    flex: 0 0 auto;
    padding-right: 15px;
    padding-left: 15px;
    scroll-snap-align: start;
  }

  .filter-row,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .full {
    grid-column: auto;
  }

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

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    max-height: 94dvh;
    border-radius: 21px 21px 0 0;
  }

  .modal-head {
    padding: 17px;
  }

  .modal-body {
    width: 100%;
    max-width: 100vw;
    padding: 14px;
  }

  .modal-footer {
    padding: 13px 17px max(13px, env(safe-area-inset-bottom));
  }

  .modal-footer .button {
    flex: 1;
  }

  .line-row {
    grid-template-columns: minmax(0, 1fr) 70px 100px 36px;
  }

  .line-row label:first-child {
    grid-column: 1 / -1;
  }

  .line-subtotal {
    display: none;
  }

  .albaran-sheet {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 740px;
    padding: 18px 14px;
    overflow-x: hidden;
  }

  .albaran-head {
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 16px;
  }

  .albaran-brand {
    width: 100%;
  }

  .albaran-brand h1 {
    font-size: 1rem;
  }

  .albaran-brand p,
  .albaran-number p {
    font-size: .64rem;
    overflow-wrap: anywhere;
  }

  .albaran-number {
    width: 100%;
    text-align: left;
  }

  .albaran-client {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 18px 0;
    padding: 12px;
  }

  .albaran-table,
  .albaran-table tbody {
    display: block;
    width: 100%;
  }

  .albaran-table thead {
    display: none;
  }

  .albaran-table tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
    padding: 13px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
  }

  .albaran-table td,
  .albaran-table td:first-child,
  .albaran-table td:not(:first-child) {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: .82rem;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .albaran-table td:first-child {
    grid-column: 1 / -1;
    padding-bottom: 9px;
    border-bottom: 1px solid #dfe5ee;
    font-size: .92rem;
    font-weight: 750;
  }

  .albaran-table td:not(:first-child)::before {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    content: attr(data-label);
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .albaran-total div {
    width: 100%;
    min-width: 0;
    padding: 12px;
  }

  .albaran-footer {
    margin-top: 35px;
  }

  .summary-client-table,
  .summary-client-table tbody {
    display: block;
    width: 100%;
  }

  .summary-client-table thead {
    display: none;
  }

  .summary-client-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    padding: 11px;
    border-bottom: 1px solid var(--border);
  }

  .summary-client-table tr.debtor-row {
    background: #fff5f5;
    border: 1px solid #fecaca;
    border-left: 4px solid var(--danger);
    border-radius: 12px;
  }

  .summary-client-table td {
    display: block;
    min-width: 0;
    padding: 6px;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  .summary-client-table td:first-child {
    grid-column: 1 / -1;
    padding-bottom: 9px;
    border-bottom: 1px solid #edf0f4;
  }

  .summary-client-table td:not(:first-child)::before {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    content: attr(data-label);
    font-size: .58rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .expenses-table,
  .expenses-table tbody {
    display: block;
    width: 100%;
  }

  .expenses-table thead {
    display: none;
  }

  .expenses-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 9px;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid var(--danger);
    border-radius: 13px;
    box-shadow: var(--shadow-sm);
  }

  .expenses-table td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  .expenses-table .expense-concept {
    grid-column: 1 / -1;
    padding-bottom: 10px;
    border-bottom: 1px solid #edf0f4;
    font-size: .92rem;
    overflow-wrap: anywhere;
  }

  .expenses-table td[data-label]::before {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    content: attr(data-label);
    font-size: .61rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .expenses-table .expense-actions {
    grid-column: 1 / -1;
  }

  .expenses-table .expense-actions .inline-actions {
    justify-content: flex-end !important;
  }
}

@media (max-width: 390px) {
  .stats-grid,
  .stats-grid.stats-three,
  .stats-grid.stats-two {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 96px;
  }

  .mobile-nav {
    padding-right: 3px;
    padding-left: 3px;
  }

  .mobile-nav a,
  .mobile-nav > button:not(.quick-add) {
    font-size: .61rem;
  }
}

@media print {
  body {
    background: #fff;
  }

  body > * {
    display: none !important;
  }

  #modalRoot {
    display: block !important;
  }

  #modalRoot .modal-backdrop {
    position: static;
    display: block;
    padding: 0;
    overflow: visible;
    background: #fff;
  }

  #modalRoot .modal {
    width: 100%;
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #modalRoot .modal-head,
  #modalRoot .modal-footer {
    display: none;
  }

  #modalRoot .modal-body {
    padding: 0;
  }

  .albaran-sheet {
    min-height: 0;
    padding: 28px;
  }

  .albaran-table {
    display: table;
    table-layout: fixed;
  }

  .albaran-table thead {
    display: table-header-group;
  }

  .albaran-table tbody {
    display: table-row-group;
  }

  .albaran-table tr {
    display: table-row;
  }

  .albaran-table th,
  .albaran-table td,
  .albaran-table td:first-child,
  .albaran-table td:not(:first-child) {
    display: table-cell;
    padding: 10px 14px;
    border-bottom: 1px solid #edf0f4;
    font-size: .8rem;
    text-align: inherit;
  }

  .albaran-table td:not(:first-child) {
    text-align: right;
  }

  .albaran-table td:not(:first-child)::before {
    display: none;
    content: none;
  }

  @page {
    size: A4;
    margin: 8mm;
  }
}
