:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --bg: #f7f4ef;
  --card: #ffffff;
  --line: #eadfd6;
  --shadow: 0 10px 30px rgba(31, 41, 55, 0.08);

  --aqua-50: #f1fbf6;
  --aqua-100: #e2f5ec;
  --aqua-200: #c8eadb;
  --aqua-400: #7cc9a8;
  --aqua-600: #3b8f6d;
  --aqua-700: #2f7458;

  --coral-50: #fff5ef;
  --coral-100: #ffe9db;
  --coral-200: #ffd1ba;
  --coral-400: #f4a582;
  --coral-600: #c66a3d;

  --accent: var(--aqua-400);
  --accent-2: var(--aqua-100);
  --accent-coral: var(--coral-200);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: radial-gradient(circle at 15% 10%, #ffffff 0, #f4f2fb 35%, var(--bg) 100%);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 41, 55, 0.55);
  display: grid;
  place-items: center;
  z-index: 50;
}

#login-overlay {
  background: linear-gradient(rgba(15, 23, 42, 0.45), rgba(15, 23, 42, 0.45));
  overflow: hidden;
}

#login-overlay::before {
  content: "";
  position: absolute;
  inset: -20px;
  background: url("assets/fondo-login.png") center/cover no-repeat;
  filter: blur(6px);
  transform: scale(1.03);
}

.login-modal {
  position: relative;
  z-index: 1;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  min-width: 320px;
  width: min(1100px, 94vw);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.login-modal {
  width: min(420px, 92vw);
  min-width: 0;
  max-height: none;
  overflow: visible;
  align-items: center;
  gap: 10px;
  padding: 30px 26px 24px;
  border: 1px solid #dbe8f5;
  box-shadow: 0 20px 42px rgba(17, 24, 39, 0.2);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.login-logo {
  width: min(240px, 72%);
  height: auto;
  margin-bottom: 4px;
}

#form-login {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

#form-login input,
#form-login button {
  width: 100%;
}

#login-error {
  min-height: 18px;
  text-align: center;
}

.modal-wide {
  min-width: 520px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

body.login-active .app {
  display: none;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.side {
  background: linear-gradient(180deg, #2a2f3a 0%, #2f3a4f 100%);
  color: #e5e7eb;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: hidden;
}

.side-collapsed .app {
  grid-template-columns: 88px 1fr;
}

.side-collapsed .side {
  padding: 16px 10px;
  gap: 16px;
}

.side-collapsed .brand-title,
.side-collapsed .brand-sub {
  display: none;
}

.side-collapsed .brand-logo {
  width: 46px;
}

.side-collapsed #toggle-side {
  font-size: 12px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--aqua-200);
  color: #1f2937;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand-logo {
  width: 172px;
  height: auto;
  filter: none;
}

.brand-title {
  font-family: "Fraunces", serif;
  font-size: 18px;
}

.brand-sub {
  font-size: 12px;
  color: #94a3b8;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  color: #d7e3f3;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 12px;
  background: transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.nav a.active,
.nav a:hover {
  background: rgba(165, 243, 252, 0.18);
  color: #fff;
}

.nav .icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  color: var(--icon-color, #9ca3af);
}

.nav .icon svg {
  width: 20px;
  height: 20px;
}

.side-collapsed .nav a {
  justify-content: center;
}

.side-collapsed .nav .label {
  display: none;
}

.side-footer {
  margin-top: 4px;
  font-size: 12px;
  color: #94a3b8;
  display: none;
  gap: 8px;
}

.nav a[href="#/dashboard"] { --icon-color: #38bdf8; }
.nav a[href="#/balances"] { --icon-color: #f59e0b; }
.nav a[href="#/local"] { --icon-color: #22c55e; }
.nav a[href="#/clients"] { --icon-color: #8b5cf6; }
.nav a[href="#/visits"] { --icon-color: #06b6d4; }
.nav a[href="#/budgets"] { --icon-color: #10b981; }
.nav a[href="#/orders"] { --icon-color: #ec4899; }
.nav a[href="#/pumps"] { --icon-color: #f97316; }
.nav a[href="#/work-orders"] { --icon-color: #eab308; }
.nav a[href="#/calendar"] { --icon-color: #3b82f6; }
.nav a[href="#/catalog"] { --icon-color: #14b8a6; }
.nav a[href="#/history"] { --icon-color: #a78bfa; }
.nav a[href="#/costs"] { --icon-color: #0ea5a4; }
.nav a[href="#/settings"] { --icon-color: #fb7185; }

.pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.2);
  color: #0f172a;
}

.user-menu {
  position: relative;
}

.user-dropdown {
  position: absolute;
  top: 44px;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow);
  min-width: 180px;
  z-index: 30;
}

.user-dropdown .btn {
  width: 100%;
  justify-content: center;
}

#menu-change-user {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

#menu-change-user:hover {
  background: #cfe2ff;
}

#menu-logout {
  background: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
}

#menu-logout:hover {
  background: #fdd5d5;
}

.main {
  padding: 24px 32px 40px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 10px 12px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 255, 0.9));
  border: 1px solid #e7e7f4;
  box-shadow: 0 8px 20px rgba(35, 55, 86, 0.06);
}

.page-title {
  font-family: "Fraunces", serif;
  font-size: 24px;
}

.page-sub {
  color: var(--muted);
  font-size: 14px;
}

#main-root[data-section="dashboard"] .top { border-left: 6px solid #38bdf8; }
#main-root[data-section="balances"] .top { border-left: 6px solid #f59e0b; }
#main-root[data-section="local"] .top { border-left: 6px solid #22c55e; }
#main-root[data-section="clients"] .top { border-left: 6px solid #8b5cf6; }
#main-root[data-section="visits"] .top { border-left: 6px solid #06b6d4; }
#main-root[data-section="budgets"] .top { border-left: 6px solid #10b981; }
#main-root[data-section="orders"] .top { border-left: 6px solid #ec4899; }
#main-root[data-section="pumps"] .top { border-left: 6px solid #f97316; }
#main-root[data-section="work-orders"] .top { border-left: 6px solid #eab308; }
#main-root[data-section="calendar"] .top { border-left: 6px solid #3b82f6; }
#main-root[data-section="catalog"] .top { border-left: 6px solid #14b8a6; }
#main-root[data-section="history"] .top { border-left: 6px solid #a78bfa; }
#main-root[data-section="settings"] .top { border-left: 6px solid #fb7185; }
#main-root[data-section="costs"] .top { border-left: 6px solid #0ea5a4; }

.top-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  min-width: 260px;
  flex: 1 1 220px;
}

#costs-search {
  border: 2px solid #8fd3cf;
  background: linear-gradient(180deg, #ffffff 0%, #f3fffd 100%);
  box-shadow: 0 6px 18px rgba(14, 165, 164, 0.14);
  font-weight: 600;
}

#costs-search:focus {
  outline: none;
  border-color: #0ea5a4;
  box-shadow: 0 0 0 3px rgba(14, 165, 164, 0.18), 0 8px 18px rgba(14, 165, 164, 0.12);
}

#costs-search::placeholder {
  color: #4b7f7d;
  opacity: 0.95;
}

#costs-save-public-selection {
  background: #e8f5ff;
  border-color: #b9dcff;
  color: #1e5fa7;
}

#costs-save-public-selection:hover {
  background: #dcefff;
}

#costs-print-public {
  background: #efeafe;
  border-color: #d8cbff;
  color: #5b3aa8;
}

#costs-print-public:hover {
  background: #e6dcff;
}

#costs-provider-tabs .btn {
  background: #fff7e8;
  border-color: #f3ddba;
  color: #8b5a1a;
}

#costs-provider-tabs .btn:hover {
  background: #ffefcf;
}

#costs-provider-tabs .btn.info {
  background: #dff0ff;
  border-color: #b7d8ff;
  color: #245ea8;
}

.btn {
  border: none;
  background: var(--aqua-100);
  color: var(--aqua-600);
  border: 1px solid var(--aqua-200);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.btn .btn-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  font-size: 12px;
  line-height: 1;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

#toggle-side-top {
  display: none;
}
.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-group.two {
  display: flex;
}

.btn-group .btn {
  min-width: 90px;
  white-space: nowrap;
  justify-content: center;
}

.btn-group.budget-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.btn-group.budget-actions .btn {
  min-width: 64px;
  padding: 5px 8px;
  font-size: 11px;
  line-height: 1.1;
}

.btn.info {
  background: #e6f3ff;
  color: #1f5aa6;
  border: 1px solid #c3daf5;
}

.btn.success {
  background: #e4f6ee;
  color: #1f7a57;
  border: 1px solid #bfe6d4;
}

.btn.danger {
  background: #ffe8e1;
  color: #b6583d;
  border: 1px solid #f5cdbd;
}

.btn.whatsapp {
  background: #eafaf1;
  color: #128c7e;
  border: 1px solid #b7e7d4;
}

.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.client-input {
  font-weight: 700;
}

#form-budget .client-input {
  grid-column: 1 / -1;
}

.budget-client-inline {
  grid-column: 1 / -1;
}

.budget-client-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  display: grid;
  gap: 6px;
}

.budget-client-name {
  font-weight: 700;
  font-size: 16px;
}

.budget-client-address {
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}

.budget-client-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.budget-client-subline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.budget-list-card {
  max-height: none;
  overflow: visible;
}

@media (max-width: 980px) {
  .budget-detail-card {
    position: static;
  }
}

.btn.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn.success {
  background: #e4f6ee;
  color: #1f7a57;
  border: 1px solid #bfe6d4;
}

.btn.visit-resolve {
  background: #e4f6ee;
  color: #1f7a57;
  border: 1px solid #bfe6d4;
}

.btn.visit-quote {
  background: #e7f0ff;
  color: #2b5ea8;
  border: 1px solid #c9daf8;
}

.btn.danger {
  background: #ffe8e1;
  color: #b6583d;
  border: 1px solid #f5cdbd;
}

.btn.info {
  background: #e7f0ff;
  color: #2b5ea8;
  border: 1px solid #c9daf8;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.stat-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbf7f1 100%);
  border: 1px solid #eadfd6;
}

.stat-card .stat {
  font-size: 30px;
  font-weight: 700;
}

.stat-pending {
  border-left: 10px solid #f0b198;
}

.stat-budgets {
  border-left: 10px solid #95c9ac;
}

.stat-orders {
  border-left: 10px solid #9fb8e0;
}

.stat-clients {
  border-left: 10px solid #c8afe8;
}

.form-card {
  background: linear-gradient(180deg, #ffffff 0%, #fdf8f3 100%);
  border: 1px solid #eadfd6;
  box-shadow: 0 18px 36px rgba(31, 41, 55, 0.08);
}

.feature-card {
  background: linear-gradient(180deg, #ffffff 0%, #f6fbf9 100%);
  border: 1px solid var(--aqua-200);
}

.form-card .card-title {
  font-size: 20px;
}

.client-card {
  background: #f9f7fd;
  border: 1px solid #ebe5f6;
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 12px;
  position: relative;
}

.client-edit-corner {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  padding: 0;
  border-color: #cddff8;
  color: #2f6fb5;
  background: #eef5ff;
}

.client-balance.clickable {
  cursor: pointer;
}

.client-balance.clickable:hover {
  text-decoration: underline;
}

.client-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.client-name {
  font-size: 18px;
  font-weight: 700;
}

.client-balance {
  background: var(--aqua-200);
  color: var(--aqua-600);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
}

.client-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.client-meta strong {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.client-notes {
  background: #fff;
  border: 1px dashed #e7e3f3;
  border-radius: 12px;
  padding: 10px 12px;
}

.card.wide {
  margin-top: 16px;
}

.card-title {
  font-weight: 600;
  margin-bottom: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.compact-grid {
  margin-top: 12px;
}

.compact-summary .stat {
  font-size: 24px;
}

.dashboard-nav-card {
  text-align: left;
  cursor: pointer;
  width: 100%;
  border: 1px solid #e9ddd2;
  border-radius: 14px;
  box-shadow: 0 10px 20px rgba(37, 56, 80, 0.08);
  background: linear-gradient(160deg, #ffffff 0%, #f8fbff 55%, #f4fbf8 100%);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-nav-card:hover {
  border-color: var(--aqua-400);
  box-shadow: 0 12px 28px rgba(59, 143, 109, 0.16);
  transform: translateY(-1px);
}

#view-dashboard .stat-card.dashboard-nav-card {
  border-left-width: 12px;
  border-top: 1px solid #ece4dc;
  border-right: 1px solid #ece4dc;
  border-bottom: 1px solid #ece4dc;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

#view-dashboard .stat-pending {
  border-left-color: #f2a486;
}

#view-dashboard .stat-budgets {
  border-left-color: #7cc9a8;
}

#view-dashboard .stat-orders {
  border-left-color: #8eaee2;
}

#view-dashboard .stat-clients {
  border-left-color: #b99ce6;
}

#view-dashboard .compact-summary {
  border-radius: 14px;
  border: 1px solid #d8e7df;
  box-shadow: 0 8px 18px rgba(22, 49, 76, 0.08);
  background: linear-gradient(160deg, #ffffff 0%, #f2fbf7 100%);
}

#view-dashboard .dash-visits-card {
  border-left: 10px solid #4fd1dc;
  background: linear-gradient(180deg, #ffffff 0%, #eefbfd 100%);
}

#view-dashboard .dash-balances-card {
  border-left: 10px solid #f6c76d;
  background: linear-gradient(180deg, #ffffff 0%, #fff9ee 100%);
}

#view-dashboard .dash-pumps-card {
  border-left: 10px solid #fb9b64;
  background: linear-gradient(180deg, #ffffff 0%, #fff4ee 100%);
}

#view-dashboard .dash-work-card {
  border-left: 10px solid #95b8ff;
  background: linear-gradient(180deg, #ffffff 0%, #f1f6ff 100%);
}

#view-dashboard .stat-card .card-title {
  margin-bottom: 4px;
}

#view-dashboard .wide {
  border: 1px solid #dbe7de;
  box-shadow: 0 10px 24px rgba(33, 58, 87, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fcff 100%);
}

#view-dashboard .dashboard-today-card {
  border: 2px solid #9dcfbd;
  background: linear-gradient(180deg, #ffffff 0%, #f0fbf6 100%);
  box-shadow: 0 16px 32px rgba(39, 110, 86, 0.16);
}

#view-dashboard .dashboard-today-card .card-title {
  color: #1f7a57;
  font-size: 22px;
  margin-bottom: 14px;
}

.list-head.dashboard-today-head {
  grid-template-columns: 90px 130px 1.1fr 1.4fr 130px 120px 90px;
}

.table-row.dashboard-today-row {
  grid-template-columns: 90px 130px 1.1fr 1.4fr 130px 120px 90px;
  align-items: center;
  font-size: 13px;
}

.table-row.dashboard-today-row .btn {
  min-width: 66px;
  padding: 5px 8px;
}

.stat {
  font-size: 32px;
  font-weight: 700;
  margin: 6px 0;
}

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

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-grid textarea {
  grid-column: 1 / -1;
  min-height: 80px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

#form-order input[name="client_query"] {
  grid-column: 1 / -1;
}

.ledger-sheet {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.ledger-head,
.ledger-row {
  display: grid;
  grid-template-columns: minmax(92px, 110px) minmax(86px, 100px) minmax(0, 1.8fr) minmax(96px, 120px) minmax(110px, 140px) minmax(86px, 100px);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
}

.ledger-row > * {
  min-width: 0;
}

.ledger-head {
  background: #f6f8fc;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: #667085;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.ledger-input-row {
  background: #ffffff;
}

.ledger-input-row input,
.ledger-input-row select {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
}

.concept-picker {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  align-items: center;
}

.concept-picker .icon-btn {
  width: 40px;
  height: 40px;
}

.concept-editor {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.local-item-fields {
  display: grid;
  grid-template-columns: 72px 96px 112px;
  gap: 6px;
  align-items: center;
}

.local-item-fields .btn {
  padding: 7px 10px;
  font-size: 12px;
}

.local-draft-list {
  border-top: 1px dashed var(--line);
  background: linear-gradient(180deg, #fcfffd 0%, #f6fbff 100%);
  padding: 8px 10px;
  display: grid;
  gap: 6px;
}

.local-draft-head,
.local-draft-row {
  display: grid;
  grid-template-columns: 1fr 90px 120px 120px 80px;
  gap: 8px;
  align-items: center;
  font-size: 11px;
}

.local-draft-head {
  color: #6a7687;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  padding: 2px 2px 0;
}

.local-draft-row {
  border: 1px solid #e7efe9;
  background: #fff;
  border-radius: 10px;
  padding: 6px 8px;
}

.local-draft-row .btn {
  padding: 5px 8px;
  font-size: 11px;
}

.local-draft-total {
  justify-self: end;
  font-size: 12px;
  font-weight: 700;
  color: #244465;
  background: #eaf4ff;
  border: 1px solid #cee5ff;
  border-radius: 999px;
  padding: 5px 10px;
}

.ledger-list {
  gap: 0;
}

#form-pump input[name="client_query"] {
  grid-column: 1 / -1;
}

#form-visit {
  grid-template-columns: minmax(420px, 4fr) minmax(150px, 1fr);
}

#form-visit input[name="client_query"] {
  grid-column: 1 / 2;
}

#form-visit input[name="fecha"] {
  grid-column: 2 / 3;
}

#form-visit textarea[name="motivo"],
#form-visit button[type="submit"] {
  grid-column: 1 / -1;
}

#form-order .items {
  grid-column: 1 / -1;
}

#form-order > button[type="submit"] {
  grid-column: 1 / -1;
  justify-self: start;
}

.table {
  display: grid;
  gap: 8px;
}

.list-head {
  display: grid;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f8fc;
}

.list-head.clients-head {
  grid-template-columns: 90px 1.1fr 1.25fr 1fr 1.1fr 0.9fr;
}

.list-head.budgets-head {
  grid-template-columns: 110px 1fr 110px 130px 430px;
}

.list-head.orders-head {
  grid-template-columns: 150px 1.4fr 1.4fr 120px 140px 140px;
}

.list-head.work-head {
  grid-template-columns: 1.6fr 1.6fr 140px 140px;
}

.list-head.local-head {
  grid-template-columns: minmax(92px, 110px) minmax(86px, 100px) minmax(0, 1.8fr) minmax(96px, 120px) minmax(110px, 140px) minmax(86px, 100px);
}

.list-head.costs-head {
  grid-template-columns: 34px minmax(0, 0.55fr) minmax(0, 2.05fr) minmax(0, 0.5fr) minmax(0, 0.75fr) minmax(0, 0.75fr) minmax(0, 0.72fr) minmax(0, 0.75fr) minmax(0, 0.75fr) minmax(0, 0.8fr) minmax(0, 0.82fr) minmax(0, 0.82fr);
  position: sticky;
  top: 0;
  z-index: 6;
  background: #f5f7fd;
  box-shadow: 0 2px 0 rgba(219, 226, 241, 0.9);
  width: 100%;
  min-width: 0;
}

.table-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  align-items: start;
}

.table-row.budget-row {
  grid-template-columns: 110px 1fr 110px 130px 430px;
  align-items: center;
}

.table-row.budget-row > div:nth-child(4) {
  text-align: left;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table-row.work-row {
  grid-template-columns: 1.6fr 1.6fr 140px 140px;
}

.table-row.visit-row {
  grid-template-columns: 140px 1.2fr 1.2fr 220px;
  align-items: center;
}

.table-row.order-row {
  grid-template-columns: 150px 1.4fr 1.4fr 120px 140px 140px;
  align-items: center;
  font-size: 12px;
  gap: 6px;
  padding: 8px 10px;
}

.table-row.pump-row {
  grid-template-columns: 140px 1.2fr 1.1fr 170px 240px;
  align-items: center;
}

.table-row.balance-row {
  grid-template-columns: 120px 1.1fr 1.1fr 140px 140px 220px;
  align-items: center;
  cursor: pointer;
}

.table-row.local-row {
  grid-template-columns: minmax(92px, 110px) minmax(86px, 100px) minmax(0, 1.8fr) minmax(96px, 120px) minmax(110px, 140px) minmax(86px, 100px);
  align-items: center;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  border-bottom: 1px solid var(--line);
  padding: 7px 10px;
  font-size: 12px;
}

.table-row.local-row > * {
  min-width: 0;
}

.table-row.local-row > :nth-child(3) {
  white-space: normal;
  word-break: break-word;
}

.table-row.local-row .btn {
  padding: 6px 8px;
  font-size: 11px;
}

.table-row.local-row:last-child {
  border-bottom: 0;
}

.table-row.catalog-row {
  grid-template-columns: 110px 110px 1.4fr 130px 110px;
  align-items: center;
  cursor: pointer;
}

.costs-table {
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  width: 100%;
  min-width: 0;
}

#view-costs {
  height: calc(100vh - 140px);
  overflow: hidden;
}

#costs-main-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#costs-main-card.hidden {
  display: none !important;
}

#costs-main-card > .actions,
#costs-main-card > .muted,
#costs-main-card > .card-title {
  flex: 0 0 auto;
}

#list-costs {
  flex: 1 1 auto;
  min-height: 0;
}

.costs-actions-row {
  align-items: center;
}

.costs-config-row {
  align-items: flex-end;
  gap: 10px;
}

.cost-input {
  display: grid;
  gap: 4px;
  min-width: 130px;
}

.cost-input span {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

.table-row.costs-row {
  grid-template-columns: 34px minmax(0, 0.55fr) minmax(0, 2.05fr) minmax(0, 0.5fr) minmax(0, 0.75fr) minmax(0, 0.75fr) minmax(0, 0.72fr) minmax(0, 0.75fr) minmax(0, 0.75fr) minmax(0, 0.8fr) minmax(0, 0.82fr) minmax(0, 0.82fr);
  gap: 6px;
  font-size: 9px;
  padding: 8px 10px;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.table-row.costs-row .cost-show-public {
  width: 14px;
  height: 14px;
}

.list-head.costs-head > div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-row.costs-row > div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-row.costs-row > div:nth-child(3) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.catalog-split {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 1.25fr);
  gap: 14px;
  align-items: start;
}

.catalog-form-card {
  background: linear-gradient(180deg, #ffffff 0%, #f4fbf8 100%);
  border: 1px solid var(--aqua-200);
}

.catalog-form-grid {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.catalog-form-grid .btn-row {
  grid-column: 1 / -1;
}

.catalog-list-card {
  position: sticky;
  top: 84px;
}

.catalog-table {
  max-height: calc(100vh - 300px);
  overflow: auto;
  padding-right: 4px;
}

.catalog-table .table-row.catalog-row {
  grid-template-columns: 90px 100px 1.5fr 120px 100px;
  gap: 6px;
  font-size: 13px;
  padding: 8px 10px;
}

.catalog-search {
  align-items: center;
  gap: 10px;
}

.catalog-search .icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--aqua-100);
  border: 1px solid var(--aqua-200);
  color: var(--aqua-600);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.catalog-search .icon svg {
  width: 18px;
  height: 18px;
}

#catalog-modal-list {
  max-height: calc(90vh - 190px);
  overflow: auto;
  padding-right: 4px;
}

#catalog-modal-list .table-row {
  font-size: 12px;
}

.action-cell {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.table-row.client-row {
  grid-template-columns: 90px 1.1fr 1.25fr 1fr 1.1fr 0.9fr;
}

.table-row.client-row > div {
  min-width: 0;
  word-break: break-word;
}

.clients-split {
  display: grid;
  grid-template-columns: minmax(520px, 1.2fr) minmax(380px, 1fr);
  gap: 14px;
  align-items: start;
}

.clients-results-card {
  min-height: 420px;
}

.clients-results-table {
  max-height: calc(100vh - 290px);
  overflow: auto;
  padding-right: 4px;
}

.clients-results-table .table-row.client-row {
  grid-template-columns: 90px 1.1fr 1.25fr 1fr 1.1fr 0.9fr;
  gap: 6px;
  font-size: 13px;
  padding: 8px 10px;
}

#list-budgets,
#list-orders,
#list-orders-history,
#list-work-orders,
#list-clients {
  gap: 6px;
}

.clients-results-table .table-row.client-row .stack {
  gap: 1px;
}

.clients-detail-card {
  position: sticky;
  top: 84px;
}

.order-total {
  font-weight: 600;
  white-space: nowrap;
  font-size: 13px;
}

.order-inline {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.order-actions .btn {
  min-width: 84px;
  padding: 6px 10px;
  font-size: 12px;
}

.balance-amount {
  font-weight: 700;
  text-align: left;
}

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

.local-amount {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

#view-local .grid {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
}

#view-local .stat-card {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 10px;
}

#view-local .stat-card .card-title {
  font-size: 14px;
  margin-bottom: 6px;
}

#view-local .stat-card .stat {
  font-size: 24px;
  margin: 0;
}

.stack {
  display: grid;
  gap: 2px;
}

.table-row.selected {
  border-color: var(--accent);
  background: #f1f8ff;
}

.table-row.closed {
  border-color: #d3d8e5;
  background: #f4f1fb;
  position: relative;
}

.table-row.closed::after {
  content: "✓";
  position: absolute;
  right: 12px;
  top: 10px;
  color: #65a30d;
  font-weight: 700;
}

mark {
  background: #fde68a;
  padding: 0 2px;
  border-radius: 4px;
}

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

.autocomplete-list {
  position: absolute;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 4px;
  z-index: 40;
  max-height: 240px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}

.autocomplete-item:hover {
  background: var(--accent-2);
}

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

#view-calendar .card {
  background: linear-gradient(180deg, rgba(236, 249, 252, 0.9), rgba(255, 250, 246, 0.9));
  border: 1px solid rgba(179, 213, 224, 0.45);
  box-shadow: 0 16px 30px rgba(42, 69, 86, 0.08);
}

#view-calendar .card-title {
  font-size: 20px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.calendar-day {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(212, 220, 235, 0.8);
  border-radius: 12px;
  padding: 10px;
  height: 100%;
  display: grid;
  gap: 8px;
  grid-template-rows: auto 1fr;
}

.calendar-day.today {
  border-color: var(--aqua-300);
  box-shadow: 0 10px 24px rgba(55, 124, 146, 0.12);
}

.calendar-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--aqua-50);
  border: 1px solid var(--aqua-200);
  border-radius: 12px;
  padding: 8px 10px;
}

.calendar-day-name {
  font-weight: 600;
  text-transform: capitalize;
  min-height: 22px;
}

.calendar-day-date {
  font-size: 12px;
  color: var(--muted);
}

.calendar-count {
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.calendar-day-body {
  display: grid;
  gap: 8px;
  overflow: auto;
  min-height: 0;
  align-content: start;
  grid-auto-rows: max-content;
}

.calendar-item {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  color: #1f2937;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  display: grid;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 86px;
}

.calendar-item .cal-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.calendar-item .cal-main {
  font-size: 13px;
  font-weight: 600;
}

.calendar-item .cal-meta {
  color: var(--muted);
}

.calendar-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

.calendar-item.dragging {
  opacity: 0.6;
  transform: scale(0.98);
}

.calendar-day-body.drop-target {
  outline: 2px dashed var(--aqua-300);
  outline-offset: 4px;
  border-radius: 12px;
}

.event-date-input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
  width: 100%;
}

.calendar-item.visit {
  background: var(--aqua-50);
  border-color: var(--aqua-200);
  color: var(--aqua-700);
}

.calendar-item.work {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.calendar-item.order {
  background: var(--coral-50);
  border-color: var(--coral-200);
  color: var(--coral-600);
}

.calendar-empty {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 6px 0 2px;
}

.event-card {
  display: grid;
  gap: 14px;
}

.event-title {
  font-size: 18px;
  font-weight: 700;
}

.event-client-name {
  font-size: 22px;
  font-weight: 700;
}

.event-section {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.event-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.event-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.event-ot-num {
  font-size: 12px;
  color: var(--muted);
}

.btn-primary-action {
  padding: 12px 18px;
  font-size: 14px;
}

.btn.link-btn {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.toast {
  margin-top: 10px;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.budget-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.budget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.budget-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.budget-title {
  font-weight: 700;
}

.budget-total {
  background: var(--aqua-100);
  border: 1px solid var(--aqua-200);
  color: var(--aqua-600);
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.budget-items {
  display: grid;
  gap: 8px;
}

.budget-item {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 14px;
}

.budget-item > div:first-child {
  font-size: 15px;
  font-weight: 600;
}

.status {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
}

.status.success {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.status.danger {
  background: var(--coral-100);
  color: var(--coral-600);
  border-color: var(--coral-200);
}

.status.info {
  background: var(--aqua-100);
  color: var(--aqua-600);
  border-color: var(--aqua-200);
}

.status-ot {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-ot.pending {
  background: #eef2ff;
  color: #3730a3;
  border-color: #c7d2fe;
}

.status-ot.progress {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.status-ot.wait {
  background: #fdf4ff;
  color: #86198f;
  border-color: #f5d0fe;
}

.status-ot.closed {
  background: #ecfdf3;
  color: #166534;
  border-color: #bbf7d0;
}

.budget-client {
  text-decoration: underline;
  cursor: pointer;
  color: var(--aqua-600);
  display: inline-block;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  font-size: 14px;
}

.items {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.items-head,
.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 80px;
  gap: 8px;
  align-items: center;
}

.item-detail-with-picker {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
  align-items: center;
}

.item-detail-with-picker .item-pick-btn {
  width: 38px;
  height: 38px;
  padding: 0;
}

.item-row input {
  width: 100%;
}

.hidden { display: none; }

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

  .side {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    transform: translateX(-110%);
    transition: transform 0.25s ease;
    z-index: 20;
    overflow-y: auto;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

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

  #toggle-side-top {
    display: inline-flex;
  }

  .table-row.budget-row {
    grid-template-columns: 1fr;
  }

  .list-head.budgets-head,
  .list-head.clients-head,
  .list-head.orders-head,
  .list-head.work-head,
  .list-head.local-head,
  .list-head.costs-head,
  .list-head.dashboard-today-head {
    grid-template-columns: 1fr;
  }

  .table-row.dashboard-today-row {
    grid-template-columns: 1fr;
  }

  .table-row.client-row {
    grid-template-columns: 1fr;
  }

  .table-row.order-row {
    grid-template-columns: 1fr;
  }

  .table-row.pump-row {
    grid-template-columns: 1fr;
  }

  .table-row.costs-row {
    grid-template-columns: 1fr;
  }

  .ledger-head,
  .ledger-row,
  .table-row.local-row {
    grid-template-columns: 1fr;
  }

  .ledger-head {
    display: none;
  }

  .table-row.client-row .stack {
    font-size: 13px;
  }

  .clients-split {
    grid-template-columns: 1fr;
  }

  .clients-results-table {
    max-height: none;
    overflow: visible;
  }

  .clients-detail-card {
    position: static;
    top: auto;
  }

  .catalog-split {
    grid-template-columns: 1fr;
  }

  .catalog-list-card {
    position: static;
    top: auto;
  }

  .catalog-table {
    max-height: none;
    overflow: visible;
  }
}

.side-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 41, 55, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 15;
}

.side-open .side {
  transform: translateX(0);
}

.side-open .side-backdrop {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  }

  .btn-group {
    grid-template-columns: 1fr;
  }

  .items-head,
  .item-row {
    grid-template-columns: 1fr;
  }

  .client-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-logo {
    width: 124px;
  }

  #toggle-side {
    display: none;
  }

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