/*
 * BaseBuild · estilos de la aplicación
 *
 * Un solo archivo para toda la app (antes eran nueve que se corregían entre sí).
 * La paleta (:root) va al principio: usa siempre sus variables, no colores escritos a mano.
 * Las secciones conservan el orden de carga anterior.
 */

:root {
  --brand: #2455df;
  --brand-strong: #1945c1;
  --brand-deep: #1d4198;
  --brand-ink: #1b3a8f;
  --brand-soft: #edf3ff;
  --brand-soft-strong: #dbe6ff;
  --brand-border: #cbdafa;
  --navy: #101d3a;
  --navy-hover: #253757;
  --navy-border: #35415b;
  --accent: #d99a22;
  --text: #101d3a;
  --text-muted: #475872;
  --text-subtle: #5b6a82;
  --on-brand: #fff;
  --on-dark: #e2e9f8;
  --on-dark-muted: #b7c5df;
  --bg: #f2f5fa;
  --surface: #fff;
  --surface-alt: #f7f9fc;
  --neutral-soft: #eef1f6;
  --border: #dce4f1;
  --border-strong: #bfc9da;
  --focus: #5382ff;
  --success: #117b50;
  --success-soft: #e9f9f2;
  --success-border: #bde5d1;
  --warning: #8a5a00;
  --warning-soft: #fff5dc;
  --warning-border: #f0d38d;
  --danger: #b5273b;
  --danger-solid: #dc4b5c;
  --danger-soft: #fff0f2;
  --danger-soft-strong: #ffe5e9;
  --danger-border: #ffd2d8;
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 24px;
  --fs-2xl: 32px;
  --shadow: 0 12px 34px rgba(16,29,58,.08);
  --shadow-sm: 0 3px 13px rgba(26,31,50,.03);
  --radius: 14px;
  --font: ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
/* ═══ app ═══════════════════════════════════════════ */

* {
  box-sizing: border-box;
}

html {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-body {
  min-height: 100vh;
  background: var(--surface);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(420px,1.1fr) minmax(480px,.9fr);
  min-height: 100vh;
}

.login-brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px;
  background: radial-gradient(circle at 15% 85%,rgba(83,130,255,.35),transparent 32%),linear-gradient(135deg,var(--navy),var(--brand-deep) 55%,var(--brand));
  overflow: hidden;
}

.login-brand:before,
.login-brand:after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  width: 520px;
  height: 520px;
  right: -270px;
  top: -180px;
}

.login-brand:after {
  width: 360px;
  height: 360px;
  right: -170px;
  top: -100px;
}

.login-brand-inner {
  position: relative;
  z-index: 1;
  max-width: 580px;
  color: var(--on-brand);
}

.brand-pill {
  display: inline-flex;
  padding: 8px 13px;
  background: rgba(255,255,255,.11);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 99px;
  font-size: var(--fs-xs);
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 750;
}

.login-brand h1 {
  font-size: clamp(46px,5vw,74px);
  line-height: 1.01;
  letter-spacing: -.055em;
  margin: 24px 0;
}

.login-brand p {
  font-size: var(--fs-lg);
  line-height: 1.65;
  color: rgba(255,255,255,.72);
  max-width: 520px;
}

.login-proof {
  display: flex;
  gap: 24px;
  margin-top: 44px;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: rgba(255,255,255,.82);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px;
}

.login-card {
  width: min(100%,430px);
}

.mobile-login-logo {
  display: none;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: .105em;
  font-weight: 800;
  font-size: var(--fs-xs);
}

.login-card h2,
.page-heading h1 {
  font-size: var(--fs-2xl);
  line-height: 1.15;
  letter-spacing: -.035em;
  margin: 0;
}

.login-helper {
  color: var(--text-muted);
  margin: 10px 0 30px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field>span:first-child {
  font-size: var(--fs-sm);
  font-weight: 750;
}

.field input,
.field textarea,
.field select,
.search-wide input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 13px 14px;
  color: var(--text);
  outline: none;
  transition: .2s;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.search-wide input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(36,85,223,.11);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 60px;
}

.show-password {
  position: absolute;
  right: 10px;
  top: 8px;
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 6px;
  font-size: var(--fs-xs);
  font-weight: 750;
}

.checkbox {
  display: flex;
  gap: 8px;
  align-items: center;
}

.checkbox input {
  accent-color: var(--brand);
}

.text-link {
  color: var(--brand);
  font-weight: 750;
  font-size: var(--fs-sm);
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 760;
  font-size: var(--fs-sm);
  transition: transform .18s,box-shadow .18s,background .18s;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 8px 18px rgba(36,85,223,.2);
}

.button-primary:hover {
  background: var(--brand-strong);
}

.button-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.button-block {
  width: 100%;
  min-height: 50px;
  justify-content: space-between;
  padding-inline: 19px;
}

.login-support {
  text-align: center;
  color: var(--text-subtle);
  font-size: var(--fs-xs);
  margin: 25px 0;
}

.form-alert {
  padding: 12px 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: var(--fs-sm);
}

.app-shell {
  display: grid;
  grid-template-columns: 245px minmax(0,1fr);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 245px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.sidebar-brand {
  height: 79px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 23px;
  gap: 10px;
}

.sidebar-brand img {
  width: 146px;
}

.sidebar-brand>span {
  font-size: var(--fs-xs);
  font-weight: 900;
  letter-spacing: .13em;
  background: var(--brand-soft);
  color: var(--brand);
  padding: 4px 5px;
  border-radius: 4px;
}

.nav-list {
  padding: 18px 12px;
  overflow-y: auto;
  flex: 1;
}

.nav-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--text-subtle);
  font-weight: 800;
  margin: 17px 12px 8px;
}

.nav-label:first-child {
  margin-top: 0;
}

.nav-item {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 650;
  margin: 2px 0;
}

.nav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: var(--fs-lg);
}

.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg,var(--brand),var(--navy));
  color: var(--on-brand);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 800;
}

.sidebar-user>span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 2px;
  flex: 1;
}

.sidebar-user strong {
  font-size: var(--fs-xs);
}

.sidebar-user small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.sidebar-user form button {
  border: 0;
  background: transparent;
  color: var(--text-subtle);
}

.app-main {
  grid-column: 2;
  min-width: 0;
}

.top-header {
  height: 79px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.menu-button {
  display: none;
  border: 0;
  background: transparent;
  font-size: var(--fs-xl);
}

.global-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(45vw,520px);
  height: 39px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-alt);
  color: var(--text-subtle);
}

.global-search input {
  border: 0;
  outline: 0;
  background: transparent;
  min-width: 0;
  flex: 1;
  font-size: var(--fs-xs);
}

.global-search kbd {
  font: var(--fs-xs) var(--font);
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  padding: 3px 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-date {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  font-weight: 700;
}

.content {
  padding: 31px 34px 55px;
  max-width: 1480px;
  margin: 0 auto;
}

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

.page-heading h1 {
  font-size: var(--fs-2xl);
}

.page-heading p:last-child {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.page-heading.compact {
  align-items: center;
}

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

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

.metric-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 19px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 112px;
  box-shadow: 0 3px 13px rgba(26,31,50,.03);
}

.metric-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: var(--fs-lg);
  font-weight: 800;
  flex: none;
}

.metric-icon.gold {
  background: var(--warning-soft);
  color: var(--warning);
}

.metric-icon.coral {
  background: var(--danger-soft);
  color: var(--danger);
}

.metric-icon.green {
  background: var(--success-soft);
  color: var(--success);
}

.metric-card p {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 650;
  margin: 0 0 3px;
}

.metric-card strong {
  font-size: var(--fs-xl);
  letter-spacing: -.035em;
}

.metric-card small {
  display: block;
  color: var(--text-subtle);
  font-size: var(--fs-xs);
  margin-top: 5px;
}

.metric-card small b {
  color: var(--success);
}

.metric-link {
  margin-left: auto;
  color: var(--text-subtle);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0,1.45fr) minmax(320px,.8fr);
  gap: 18px;
}

.side-column {
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 3px 13px rgba(26,31,50,.025);
}

.panel-header {
  padding: 20px 22px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h2,
.expense-form h2,
.receipt-uploader h2 {
  font-size: var(--fs-md);
  margin: 0 0 4px;
}

.panel-header p,
.expense-form>p,
.receipt-uploader>p {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0;
}

.timeline {
  padding: 1px 22px 18px;
}

.job-row {
  display: grid;
  grid-template-columns: 40px 16px minmax(0,1fr);
  gap: 9px;
  align-items: center;
  min-height: 77px;
}

.job-row time {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 700;
}

.timeline-mark {
  width: 9px;
  height: 9px;
  background: var(--border-strong);
  border-radius: 50%;
  position: relative;
}

.timeline-mark:before {
  content: "";
  position: absolute;
  width: 1px;
  height: 68px;
  background: var(--border);
  left: 4px;
  top: 9px;
}

.job-row:last-child .timeline-mark:before {
  display: none;
}

.timeline-mark.active {
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.job-card {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.job-card h3 {
  font-size: var(--fs-sm);
  margin: 4px 0 3px;
}

.job-card p {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0;
}

.technician-avatar {
  width: 29px;
  height: 29px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: var(--on-brand);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.balance-value {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 22px;
}

.balance-value strong {
  font-size: var(--fs-xl);
  letter-spacing: -.04em;
}

.balance-value span {
  font-size: var(--fs-xs);
  background: var(--success-soft);
  color: var(--success);
  padding: 4px 7px;
  border-radius: 99px;
  font-weight: 800;
}

.balance-caption {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0;
  padding: 0 22px;
}

.bar-chart {
  height: 13px;
  margin: 18px 22px 13px;
  background: var(--neutral-soft);
  border-radius: 99px;
  position: relative;
  overflow: hidden;
}

.bar {
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 99px;
}

.bar.revenue {
  background: var(--brand);
}

.bar.expenses {
  background: var(--accent);
  height: 5px;
  top: 4px;
}

.legend {
  border-top: 1px solid var(--border);
  padding: 13px 22px;
  display: grid;
  gap: 9px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend i.purple {
  background: var(--brand);
}

.legend i.gold {
  background: var(--accent);
}

.legend b {
  margin-left: auto;
  color: var(--text);
}

.alert-count {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 800;
}

.alert-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 21px;
  border-top: 1px solid var(--border);
}

.alert-row:hover {
  background: var(--surface-alt);
}

.alert-symbol {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 900;
}

.alert-symbol.expense {
  background: var(--warning-soft);
  color: var(--warning);
}

.alert-row>span:nth-child(2) {
  display: grid;
  gap: 3px;
  flex: 1;
}

.alert-row strong {
  font-size: var(--fs-sm);
}

.alert-row small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.alert-row>b {
  color: var(--text-subtle);
}

.table-panel {
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  gap: 10px;
  padding: 17px;
  border-bottom: 1px solid var(--border);
}

.search-wide {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  color: var(--text-subtle);
}

.search-wide input {
  padding: 10px;
  border: 0;
  background: var(--surface-alt);
}

.client-row {
  display: grid;
  grid-template-columns: 42px minmax(200px,1.2fr) minmax(180px,1fr) 120px 20px;
  align-items: center;
  gap: 13px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.client-row:first-child {
  border-top: 0;
}

.client-row:hover {
  background: var(--surface-alt);
}

.client-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 900;
}

.client-main,
.client-contact {
  display: grid;
  gap: 4px;
}

.client-main strong,
.client-contact strong {
  font-size: var(--fs-sm);
}

.client-main small,
.client-contact small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.open-jobs {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.open-jobs b {
  color: var(--text);
}

.row-chevron {
  color: var(--text-subtle);
}

.expense-layout {
  display: grid;
  grid-template-columns: minmax(300px,.65fr) minmax(420px,1fr);
  gap: 18px;
}

.receipt-uploader,
.expense-form {
  padding: 24px;
}

.step-badge {
  width: 25px;
  height: 25px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 900;
  margin-bottom: 16px;
}

.upload-zone {
  margin-top: 22px;
  min-height: 250px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  padding: 30px;
}

.upload-zone:hover {
  border-color: var(--brand);
  background: var(--surface-alt);
}

.upload-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.camera-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--brand);
  color: var(--on-brand);
  display: grid;
  place-items: center;
  font-size: var(--fs-2xl);
  margin-bottom: 16px;
}

.upload-zone strong {
  font-size: var(--fs-sm);
}

.upload-zone small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 6px;
}

.privacy-note {
  text-align: center;
  font-size: var(--fs-xs)!important;
  margin-top: 14px!important;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
  margin-top: 22px;
}

.span-2 {
  grid-column: span 2;
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 5px;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
}

.empty-state>span {
  margin: auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.empty-state h3 {
  font-size: var(--fs-sm);
  margin: 14px 0 4px;
}

.empty-state p {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.empty-state.standalone {
  max-width: 620px;
  margin: 13vh auto;
}

.empty-state.standalone h1 {
  font-size: var(--fs-2xl);
}

.mobile-nav,
.sidebar-backdrop {
  display: none;
}

@media (max-width:1100px) {
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .side-column {
    grid-template-columns: 1fr 1fr;
  }
  .expense-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width:760px) {
  body {
    padding-bottom: 67px;
  }
  .login-shell {
    display: block;
  }
  .login-brand {
    display: none;
  }
  .login-panel {
    min-height: 100vh;
    padding: 30px 22px;
    align-items: flex-start;
  }
  .login-card {
    margin-top: 5vh;
  }
  .mobile-login-logo {
    display: block;
    margin-bottom: 52px;
  }
  .mobile-login-logo img {
    width: 178px;
  }
  .app-shell {
    display: block;
  }
  .sidebar {
    transform: translateX(-103%);
    transition: transform .25s;
    box-shadow: 20px 0 50px rgba(16,13,75,.15);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15,18,35,.35);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: .2s;
  }
  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
  .app-main {
    display: block;
  }
  .top-header {
    height: 64px;
    padding: 0 16px;
  }
  .menu-button {
    display: block;
  }
  .global-search {
    width: auto;
    flex: 1;
    margin: 0 14px;
  }
  .global-search kbd,
  .header-date {
    display: none;
  }
  .content {
    padding: 23px 16px 30px;
  }
  .page-heading {
    align-items: flex-start;
    display: grid;
  }
  .page-heading h1 {
    font-size: var(--fs-xl);
  }
  .heading-actions {
    width: 100%;
  }
  .heading-actions .button {
    flex: 1;
  }
  .metrics-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin-inline: -16px;
    padding: 0 16px 5px;
  }
  .metric-card {
    min-width: 238px;
    scroll-snap-align: start;
  }
  .dashboard-grid {
    display: block;
  }
  .side-column {
    display: grid;
    grid-template-columns: 1fr;
    margin-top: 15px;
  }
  .panel-header {
    padding-inline: 17px;
  }
  .timeline {
    padding-inline: 14px;
  }
  .job-row {
    grid-template-columns: 36px 12px 1fr;
  }
  .job-card {
    padding: 11px;
  }
  .mobile-nav {
    position: fixed;
    display: grid;
    grid-template-columns: repeat(5,1fr);
    align-items: end;
    left: 0;
    right: 0;
    bottom: 0;
    height: 67px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 24;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav a {
    height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-weight: 700;
  }
  .mobile-nav a>span {
    font-size: var(--fs-lg);
  }
  .mobile-nav a.active {
    color: var(--brand);
  }
  .mobile-nav .mobile-create {
    color: var(--brand);
    transform: translateY(-6px);
  }
  .mobile-nav .mobile-create>span {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--brand);
    color: var(--on-brand);
    display: grid;
    place-items: center;
    box-shadow: 0 8px 18px rgba(36,85,223,.3);
    font-size: var(--fs-xl);
  }
  .client-row {
    grid-template-columns: 42px 1fr 20px;
  }
  .client-contact,
  .open-jobs {
    display: none;
  }
  .table-toolbar {
    flex-wrap: wrap;
  }
  .search-wide {
    flex-basis: 100%;
  }
  .expense-layout {
    display: block;
  }
  .expense-form {
    margin-top: 15px;
  }
  .form-grid {
    display: block;
  }
  .form-actions {
    display: grid;
  }
  .form-actions .button {
    width: 100%;
  }
}
/* ═══ refinements ═══════════════════════════════════════════ */

@media (max-width:760px) {
  .metrics-grid {
    scrollbar-width: none;
  }
  .metrics-grid::-webkit-scrollbar {
    display: none;
  }
}

.field-link {
  float: right;
  color: var(--brand);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.create-popover {
  position: relative;
}

.create-popover>summary {
  list-style: none;
}

.create-popover>summary::-webkit-details-marker {
  display: none;
}

.popover-card {
  position: absolute;
  right: 0;
  top: 54px;
  width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(16,29,58,.18);
  padding: 22px;
  z-index: 19;
}

.popover-card h2 {
  font-size: var(--fs-lg);
  margin: 0 0 18px;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.toast-success {
  background: var(--success-soft);
  border: 1px solid var(--success-border);
  color: var(--success);
  padding: 12px 15px;
  border-radius: 10px;
  margin: -10px 0 18px;
  font-size: var(--fs-xs);
  font-weight: 700;
}

.supplier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 18px;
}

.supplier-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr 16px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: .18s;
}

.supplier-card:hover {
  border-color: var(--brand-border);
  box-shadow: 0 8px 20px rgba(36,85,223,.08);
  transform: translateY(-1px);
}

.supplier-avatar {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 900;
}

.supplier-title h2 {
  font-size: var(--fs-sm);
  margin: 0 0 4px;
}

.supplier-title p {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0;
}

.supplier-card dl {
  grid-column: 2/3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 4px 0 0;
}

.supplier-card dl div {
  display: grid;
  gap: 2px;
}

.supplier-card dt {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  color: var(--text-subtle);
}

.supplier-card dd {
  font-size: var(--fs-xs);
  font-weight: 700;
  margin: 0;
}

.supplier-card>b {
  grid-column: 3;
  grid-row: 1/4;
  color: var(--text-subtle);
}

.supplier-terms {
  grid-column: 2/3;
  font-size: var(--fs-xs);
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 99px;
  padding: 5px 8px;
  justify-self: start;
}

.responsive-table {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;
}

th {
  text-align: left;
  background: var(--surface-alt);
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: var(--fs-xs);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

td strong {
  color: var(--text);
}

tbody tr:hover {
  background: var(--surface-alt);
}

.stock {
  font-weight: 800;
}

.stock.low {
  color: var(--danger);
}

.row-action {
  font-size: var(--fs-lg);
  color: var(--text-subtle);
}

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

@media (max-width:760px) {
  .popover-card {
    position: fixed;
    left: 16px;
    right: 16px;
    top: 78px;
    width: auto;
    max-height: calc(100vh - 100px);
    overflow: auto;
  }
  .supplier-grid {
    padding: 12px;
  }
  .supplier-card dl {
    grid-template-columns: 1fr;
  }
  .supplier-card dl div:nth-child(2) {
    display: none;
  }
  .mini-grid {
    display: block;
  }
}

.order-dialog {
  width: min(760px,calc(100% - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 28px 80px rgba(16,29,58,.28);
}

.order-dialog::backdrop {
  background: rgba(18,23,42,.55);
  backdrop-filter: blur(3px);
}

.order-dialog-card {
  padding: 24px;
}

.order-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
}

.order-dialog-header h2 {
  margin: 0;
  font-size: var(--fs-xl);
}

.order-dialog-header p:last-child {
  margin: 7px 0 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.dialog-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: var(--bg);
  font-size: var(--fs-xl);
  color: var(--text-muted);
}

.order-dialog-fields {
  margin-top: 20px;
}

.order-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.order-dialog-actions>a {
  margin-right: auto;
}

@media (max-width:760px) {
  .order-dialog {
    width: calc(100% - 20px);
    max-height: calc(100vh - 20px);
  }
  .order-dialog-card {
    padding: 18px;
  }
  .order-dialog-fields {
    display: block;
  }
  .order-dialog-actions {
    display: grid;
  }
  .order-dialog-actions>a {
    margin-right: 0;
  }
  .order-dialog-actions .button {
    width: 100%;
  }
}
/* ═══ details ═══════════════════════════════════════════ */

.supplier-detail-grid {
  display: grid;
  grid-template-columns: minmax(320px,.75fr) minmax(380px,1.25fr);
  gap: 18px;
}

.detail-card,
.detail-stats {
  padding: 24px;
}

.detail-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.supplier-avatar.large {
  width: 56px;
  height: 56px;
  font-size: var(--fs-sm);
}

.detail-identity h2 {
  font-size: var(--fs-lg);
  margin: 0 0 4px;
}

.detail-identity p {
  color: var(--success);
  font-size: var(--fs-xs);
  margin: 0;
  font-weight: 800;
}

.detail-list {
  display: grid;
  margin: 9px 0 0;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.detail-list dt {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.detail-list dd {
  font-size: var(--fs-sm);
  font-weight: 700;
  margin: 0;
  text-align: right;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
}

.detail-stats>div:not(.empty-state) {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.detail-stats span {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.detail-stats strong {
  display: block;
  font-size: var(--fs-xl);
  margin-top: 5px;
}

.detail-stats>h2,
.detail-stats>.empty-state {
  grid-column: 1/-1;
}

.detail-stats>h2 {
  font-size: var(--fs-sm);
  margin: 16px 0 0;
}

.detail-stats>.empty-state {
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.detail-identity .client-avatar.large {
  width: 56px;
  height: 56px;
  font-size: var(--fs-sm);
}

.client-history-nav {
  margin: 24px 0 16px;
  flex-wrap: wrap;
}

.client-history {
  margin-top: 18px;
  padding: 24px;
  scroll-margin-top: 24px;
  min-width: 0;
}

.client-history .page-heading {
  margin-bottom: 16px;
}

.client-history h2 {
  margin: 0;
  font-size: var(--fs-lg);
}

.client-history-scroll {
  overflow-x: auto;
}

.client-history table {
  width: 100%;
  border-collapse: collapse;
}

.client-history th,
.client-history td {
  padding: 14px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border,var(--border));
}

.client-history th {
  font-size: var(--fs-xs);
}

.client-history td {
  font-size: var(--fs-sm);
}

.client-history td .heading-actions {
  flex-wrap: wrap;
}

.client-history-empty {
  padding: 12px 0;
  color: var(--text-muted);
}

@media (max-width:760px) {
  .client-history {
    padding: 16px;
  }
  .client-history .page-heading {
    align-items: stretch;
    flex-direction: column;
  }
  .client-history table {
    min-width: 620px;
  }
  .client-history-nav .button {
    flex: 1;
    text-align: center;
  }
}

@media (max-width:900px) {
  .supplier-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width:760px) {
  .detail-card,
  .detail-stats {
    padding: 18px;
  }
  .detail-stats {
    grid-template-columns: 1fr;
  }
  .detail-list div {
    display: grid;
    gap: 4px;
  }
  .detail-list dd {
    text-align: left;
  }
}

.document-company {
  display: grid;
  grid-template-columns: 180px minmax(180px,.7fr) minmax(320px,1.3fr) auto;
  align-items: center;
  gap: 22px;
  padding: 20px 24px;
  margin-bottom: 18px;
}

.document-company img {
  width: 155px;
}

.document-company>div>span,
.document-company dt {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.document-company h2 {
  font-size: var(--fs-lg);
  margin: 4px 0;
}

.document-company p,
.document-company dd {
  font-size: var(--fs-xs);
  margin: 0;
}

.document-company dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.document-company dl div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
}

.document-company .text-link {
  white-space: nowrap;
}

.billing-settings-layout {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 18px;
}

.settings-section {
  padding: 24px;
}

.settings-actions {
  grid-column: 1/-1;
  display: flex;
  justify-content: flex-end;
}

@media (max-width:1000px) {
  .document-company {
    grid-template-columns: 150px 1fr;
  }
  .document-company dl {
    grid-column: 1/-1;
  }
  .billing-settings-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width:760px) {
  .document-company {
    grid-template-columns: 1fr;
  }
  .document-company dl {
    grid-column: auto;
  }
  .document-company dl div {
    grid-template-columns: 1fr;
  }
  .document-company .text-link {
    white-space: normal;
  }
  .settings-section {
    padding: 18px;
  }
  .settings-actions .button {
    width: 100%;
  }
}

.client-expense-summary {
  margin-top: 18px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.client-expense-summary>div {
  display: grid;
  gap: 4px;
}

.client-expense-summary span,
.client-expense-summary small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.client-expense-summary strong {
  font-size: var(--fs-xl);
}

@media (max-width:760px) {
  .client-expense-summary {
    align-items: stretch;
    flex-direction: column;
  }
  .client-expense-summary .button {
    width: 100%;
  }
}
/* ═══ forms ═══════════════════════════════════════════ */

.record-form {
  max-width: 900px;
  margin: 0 auto;
  padding: 26px;
}

.form-section {
  display: flex;
  gap: 13px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 19px;
  margin-bottom: 22px;
}

.form-section .step-badge {
  margin: 0;
}

.form-section h2 {
  font-size: var(--fs-md);
  margin: 0 0 4px;
}

.form-section p {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0;
}

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

.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 4px;
}

.calculation {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 15px;
  margin-bottom: 18px;
}

.calculation span {
  font-size: var(--fs-xs);
  font-weight: 700;
}

.calculation strong {
  color: var(--brand);
}

.calculation small {
  grid-column: 1/-1;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

@media (max-width:760px) {
  .record-form {
    padding: 19px;
  }
  .form-grid.wide {
    display: block;
  }
  .record-actions {
    display: grid;
  }
  .record-actions .button {
    width: 100%;
  }
}

.upload-preview {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 7px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.upload-preview[hidden] {
  display: none;
}

.upload-preview img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 10px;
  object-fit: contain;
}

.upload-preview b {
  max-width: 100%;
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

.expense-documents {
  grid-column: 1/-1;
}

.expense-documents>p {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.expense-documents article {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-alt);
}

.expense-documents article>a:first-child,
.expense-documents article>img {
  width: 112px;
  height: 112px;
  flex: none;
}

.expense-documents img {
  width: 100%;
  height: 100%;
  border-radius: 9px;
  object-fit: cover;
}

.expense-documents article>div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.expense-documents article strong {
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

.expense-documents article small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.document-file-icon {
  width: 70px;
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 900;
}

[data-other-supplier][hidden] {
  display: none!important;
}

.expense-submit-status {
  display: grid;
  grid-template-columns: 28px 1fr;
  column-gap: 10px;
  align-items: center;
  margin: 3px 0 17px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--brand);
}

.expense-submit-status[hidden] {
  display: none;
}

.expense-submit-status>span {
  grid-row: 1/3;
  width: 24px;
  height: 24px;
  border: 3px solid var(--brand-border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: expense-spin .75s linear infinite;
}

.expense-submit-status strong {
  font-size: var(--fs-xs);
}

.expense-submit-status small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.expense-layout.is-submitting .button[data-expense-submit] {
  cursor: wait;
  opacity: .72;
}

.expense-layout.is-submitting .upload-zone,
.expense-layout.is-submitting select,
.expense-layout.is-submitting input {
  pointer-events: none;
}

@keyframes expense-spin {
  to {
    transform: rotate(360deg);
  }
}

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

.button-danger:hover {
  background: var(--danger-soft-strong);
}

.heading-actions {
  flex-wrap: wrap;
}

.heading-actions form {
  display: inline-flex;
}

.document-client-picker {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: end;
  gap: 12px;
}

.document-client-picker .field {
  margin-bottom: 18px;
}

.quick-client-button {
  margin-bottom: 18px;
  white-space: nowrap;
}

.inline-client {
  margin: 2px 0 20px;
  padding: 18px;
  border: 1px solid var(--brand-border);
  border-radius: 14px;
  background: var(--surface-alt);
}

.inline-client[hidden] {
  display: none;
}

.inline-client-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.inline-client-heading>div {
  display: grid;
  gap: 3px;
}

.inline-client-heading strong {
  font-size: var(--fs-sm);
}

.inline-client-heading small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.inline-client-actions {
  display: flex!important;
  align-items: center;
  gap: 8px;
}

.inline-client-actions>span {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: var(--fs-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.inline-client-actions button {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: var(--fs-xs);
  font-weight: 750;
}

.document-lines {
  margin: 5px 0 20px;
}

.document-lines-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 14px;
}

.document-lines-heading h2 {
  margin: 0 0 5px;
  font-size: var(--fs-md);
}

.document-lines-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.document-lines-heading>div:last-child {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.document-lines-heading .button {
  padding: 9px 12px;
  font-size: var(--fs-xs);
}

.document-line-list {
  display: grid;
  gap: 12px;
}

.document-line {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 6px 22px rgba(30,35,70,.04);
}

.document-line>header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 13px;
}

.document-line>header>div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.document-line>header small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.line-kind {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.line-kind.labor {
  color: var(--brand);
  background: var(--brand-soft);
}

.line-kind.material {
  color: var(--success);
  background: var(--success-soft);
}

.line-remove {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--fs-lg);
  cursor: pointer;
}

.line-fields {
  display: grid;
  grid-template-columns: minmax(220px,2fr) repeat(2,minmax(115px,1fr)) minmax(78px,.6fr) minmax(125px,1fr);
  gap: 10px;
  align-items: end;
}

.line-fields.material-fields {
  grid-template-columns: minmax(210px,2fr) repeat(3,minmax(105px,1fr)) minmax(78px,.6fr) minmax(125px,1fr);
}

.line-fields .field {
  margin: 0;
}

.line-result {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-alt);
  min-height: 62px;
  align-content: center;
}

.line-result span {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.line-result strong {
  font-size: var(--fs-sm);
  color: var(--brand);
}

@media (max-width:900px) {
  .line-fields,
  .line-fields.material-fields {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .line-description {
    grid-column: 1/-1;
  }
  .document-lines-heading {
    display: grid;
  }
}

@media (max-width:560px) {
  .line-fields,
  .line-fields.material-fields {
    display: block;
  }
  .line-fields>* {
    margin-bottom: 10px;
  }
  .document-line>header>div {
    display: grid;
  }
  .document-client-picker {
    display: block;
  }
  .quick-client-button {
    width: 100%;
    margin-top: -7px;
  }
  .inline-client-heading {
    align-items: flex-start;
  }
  .inline-client-actions {
    align-items: flex-end!important;
  }
}

.internal-lines-panel {
  margin-top: 16px;
  padding: 22px;
}

.internal-lines-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.internal-lines-heading h2 {
  margin: 3px 0 0;
  font-size: var(--fs-lg);
}

.internal-lines-heading>span {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: var(--fs-xs);
  font-weight: 800;
}

.internal-lines-table {
  overflow: auto;
}

.internal-lines-row {
  display: grid;
  grid-template-columns: minmax(250px,1.7fr) minmax(260px,1fr) 145px;
  align-items: center;
  gap: 20px;
  padding: 13px 8px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
}

.internal-lines-row.header {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.internal-lines-row>span:first-child {
  display: grid;
  gap: 4px;
}

.internal-lines-row>span:first-child b {
  color: var(--brand);
  font-size: var(--fs-xs);
  text-transform: uppercase;
}

.internal-lines-row strong {
  text-align: right;
  font-size: var(--fs-xs);
}

@media (max-width:720px) {
  .internal-lines-heading {
    align-items: flex-start;
    display: grid;
  }
  .internal-lines-row {
    grid-template-columns: minmax(190px,1.5fr) minmax(220px,1fr) 120px;
  }
}

.employee-access-summary {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.employee-access-summary .panel {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.employee-access-summary span {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
}

.employee-access-summary strong {
  font-size: var(--fs-lg);
}

.employee-access-summary small {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.employee-account-form {
  max-width: 1000px;
}

.employee-account-form .access-section {
  margin-top: 16px;
}

.password-field>div {
  display: flex;
  position: relative;
}

.password-field>div input {
  padding-right: 60px;
}

.password-field>div button {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 800;
  cursor: pointer;
}

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

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

.document-line>header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  justify-content: initial;
  gap: 10px;
}

.line-drag-handle {
  display: grid;
  place-items: center;
  width: 32px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: var(--fs-lg);
  line-height: 1;
  cursor: grab;
  user-select: none;
}

.line-drag-handle:hover,
.line-drag-handle:focus {
  border-color: var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand);
  outline: none;
}

.line-drag-handle:active {
  cursor: grabbing;
}

.document-line.is-dragging {
  opacity: .45;
  border-color: var(--brand);
  box-shadow: 0 12px 30px rgba(36,85,223,.18);
}
/* Desglose por tipo de IVA: sus filas forman parte de la rejilla de .calculation. */

.calculation .calculation-rates {
  display: contents;
}
/* ═══ documents ═══════════════════════════════════════════ */

.document-company {
  grid-template-columns: 160px minmax(0,.7fr) minmax(0,1.3fr);
  gap: 18px 22px;
  overflow: hidden;
}

.document-company>* {
  min-width: 0;
}

.document-company .text-link {
  grid-column: 2/-1;
  justify-self: end;
  white-space: normal;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto 20px;
}

.preview-toolbar>div {
  display: grid;
  gap: 3px;
  flex: 1;
}

.preview-toolbar small {
  color: var(--text-muted);
}

.document-preview-sheet {
  width: min(100%,900px);
  min-height: 1120px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(16,29,58,.12);
  padding: 0 58px 42px;
}

.preview-document-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 -58px 48px;
  padding: 30px 58px;
  background: linear-gradient(135deg,var(--navy),var(--brand));
  color: var(--on-brand);
}

.preview-document-header>div {
  display: grid;
  gap: 8px;
}

.preview-document-header img {
  width: 190px;
  filter: brightness(0) invert(1);
}

.preview-document-header small {
  letter-spacing: .13em;
  font-size: var(--fs-xs);
}

.preview-document-header span {
  font-size: var(--fs-xs);
  letter-spacing: .12em;
}

.preview-document-header strong {
  font-size: var(--fs-xl);
}

.preview-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 55px;
}

.preview-parties span,
.preview-meta span,
.preview-summary>div>span {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.preview-parties h2 {
  font-size: var(--fs-lg);
  margin: 9px 0;
}

.preview-parties p {
  font-size: var(--fs-xs);
  margin: 5px 0;
  color: var(--text-muted);
}

.preview-meta {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 18px;
  border-block: 1px solid var(--border);
  padding: 18px 0;
  margin: 35px 0;
}

.preview-meta div {
  display: grid;
  gap: 7px;
}

.preview-meta strong {
  font-size: var(--fs-xs);
}

.preview-lines {
  min-width: 0;
  margin-bottom: 38px;
}

.preview-lines th:first-child,
.preview-lines td:first-child {
  width: 65%;
}

.preview-lines th,
.preview-lines td {
  padding: 14px;
}

.preview-summary {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 60px;
}

.preview-summary p {
  font-size: var(--fs-xs);
  line-height: 1.6;
}

.preview-summary dl {
  margin: 0;
}

.preview-summary dl div {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: var(--fs-xs);
}

.preview-summary .total {
  background: var(--brand);
  color: var(--on-brand);
  border-radius: 8px;
  font-size: var(--fs-sm);
  font-weight: 800;
}

.document-preview-sheet footer {
  display: flex;
  justify-content: space-between;
  margin-top: 170px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

@media (max-width:900px) {
  .document-company {
    grid-template-columns: 140px 1fr;
  }
  .document-company .text-link {
    grid-column: 2;
  }
  .document-preview-sheet {
    min-height: auto;
    padding-inline: 30px;
  }
  .preview-document-header {
    margin-inline: -30px;
    padding-inline: 30px;
  }
}

@media (max-width:760px) {
  .document-company {
    grid-template-columns: 1fr;
  }
  .document-company .text-link {
    grid-column: auto;
    justify-self: start;
  }
  .preview-toolbar {
    display: grid;
  }
  .preview-toolbar .button {
    width: 100%;
  }
  .document-preview-sheet {
    padding-inline: 20px;
  }
  .preview-document-header {
    margin-inline: -20px;
    padding: 24px 20px;
  }
  .preview-document-header img {
    width: 145px;
  }
  .preview-parties,
  .preview-summary {
    grid-template-columns: 1fr;
    gap: 25px;
  }
  .preview-meta {
    grid-template-columns: 1fr;
  }
  .document-preview-sheet footer {
    margin-top: 70px;
    display: grid;
    gap: 6px;
  }
}

@media print {
  .sidebar,
  .top-header,
  .mobile-nav,
  .preview-toolbar {
    display: none!important;
  }
  .app-shell,
  .app-main {
    display: block;
  }
  .content {
    padding: 0;
  }
  .document-preview-sheet {
    width: 210mm;
    min-height: 297mm;
    border: 0;
    box-shadow: none;
    margin: 0;
  }
}
/* ═══ planning ═══════════════════════════════════════════ */

.agenda-panel {
  overflow: hidden;
}

.agenda-toolbar {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.agenda-nav,
.agenda-date {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agenda-nav strong {
  margin-left: 12px;
  font-size: var(--fs-lg);
}

.agenda-date input {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
}

.agenda-scroll {
  overflow: auto;
}

.agenda-time-grid {
  display: grid;
  grid-template-columns: 64px repeat(var(--days),minmax(0,1fr));
  padding-bottom: 16px;
}

.agenda-time-grid.week-mode {
  min-width: 880px;
}

.time-corner,
.time-day-heading {
  padding: 14px;
  text-align: center;
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.time-corner {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}

.time-day-heading span,
.time-day-heading b {
  display: block;
}

.time-day-heading span {
  color: var(--text-subtle);
  font-size: var(--fs-xs);
}

.time-day-heading b {
  font-size: var(--fs-lg);
  margin-top: 4px;
}

.time-day-heading.is-today {
  background: var(--brand-soft);
  color: var(--brand);
}

.hour-axis {
  position: relative;
  height: 780px;
  background: var(--surface-alt);
}

.hour-axis span {
  position: absolute;
  left: 8px;
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  line-height: 16px;
}

.hour-axis span:last-child {
  transform: translateY(-100%);
}

.time-day {
  position: relative;
  height: 780px;
  border-left: 1px solid var(--border);
  background: repeating-linear-gradient(to bottom,transparent 0,transparent 59px,var(--border) 59px,var(--border) 60px);
}

.time-event {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  position: absolute;
  border: 1px solid var(--brand-border);
  border-left: 3px solid var(--brand);
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  text-align: left;
  padding: 5px 7px;
  overflow: hidden;
  cursor: pointer;
  min-width: 0;
}

.time-event span,
.time-event b,
.time-event small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time-event span {
  font-size: var(--fs-xs);
}

.time-event b {
  font-size: var(--fs-xs);
  margin: 3px 0;
}

.time-event small {
  font-size: var(--fs-xs);
}

.time-event.status-completed,
.time-event.status-invoiced {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}

.time-event.status-in_progress {
  background: var(--warning-soft);
  border-color: var(--warning-border);
  color: var(--warning);
}

.time-event.status-cancelled {
  background: var(--neutral-soft);
  border-color: var(--border);
  color: var(--text-muted);
}

.agenda-note {
  padding: 15px 20px;
  color: var(--text-muted);
  background: var(--surface-alt);
  font-size: var(--fs-xs);
}

.month-weekday {
  text-align: center;
  padding: 12px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.day-number {
  display: inline-block;
  padding: 6px 9px;
  font-weight: 700;
  border-radius: 50%;
}

.day-number.is-today {
  background: var(--brand);
  color: white;
}

.month-event {
  display: block;
  width: 100%;
  border: 0;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-radius: 5px;
  font: inherit;
  font-size: var(--fs-xs);
  text-align: left;
  margin-top: 6px;
  padding: 8px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.month-event small {
  display: block;
}

.agenda-overflow {
  padding: 20px;
  border-top: 1px solid var(--border);
}

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

#materiales {
  scroll-margin-top: 100px;
}

.purchase-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.purchase-row p {
  margin: 6px 0;
}

.purchase-row small {
  color: var(--text-muted);
}

.purchase-row.is-purchased {
  opacity: .75;
}

.purchase-row.is-purchased h3 {
  text-decoration: line-through;
}

.finance-kpis {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 16px;
  margin: 20px 0;
}

.finance-kpis article {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
}

.finance-kpis span,
.finance-kpis small {
  display: block;
  color: var(--text-muted);
}

.finance-kpis strong {
  display: block;
  font-size: var(--fs-2xl);
  margin: 9px 0;
  color: var(--text);
}

.finance-filters {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  padding: 20px;
}

.finance-filters .field {
  margin: 0;
}

.finance-table {
  width: 100%;
  border-collapse: collapse;
}

.finance-table th,
.finance-table td {
  padding: 14px 18px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.finance-table th:first-child,
.finance-table td:first-child {
  text-align: left;
  white-space: normal;
}

.finance-table th {
  color: var(--text-subtle);
  font-size: var(--fs-xs);
}

.finance-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.finance-bar {
  display: flex;
  gap: 3px;
  flex-direction: column;
  min-width: 100px;
}

.finance-bar i {
  height: 7px;
  background: var(--brand);
  border-radius: 4px;
}

.finance-bar b {
  height: 7px;
  background: var(--accent);
  border-radius: 4px;
}

.finance-help {
  padding: 18px;
  color: var(--text-muted);
  line-height: 1.7;
}

.finance-table-wrap {
  overflow: auto;
}

.finance-heading {
  padding: 20px;
}

.finance-empty {
  padding: 24px;
  color: var(--text-muted);
}

@media (max-width:760px) {
  .agenda-toolbar {
    padding: 12px;
    gap: 12px;
  }
  .agenda-nav strong {
    font-size: var(--fs-sm);
    margin-left: 4px;
  }
  .agenda-date {
    width: 100%;
  }
  .agenda-date input {
    flex: 1;
    min-width: 0;
  }
  .finance-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }
  .finance-kpis article {
    padding: 14px;
  }
  .finance-kpis strong {
    font-size: var(--fs-xl);
  }
  .finance-columns {
    grid-template-columns: 1fr;
  }
  .purchase-row {
    display: block;
  }
  .purchase-row form {
    margin-top: 12px;
  }
  .time-event b {
    font-size: var(--fs-xs);
  }
}

.agenda-month-ranges {
  min-width: 770px;
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7,minmax(0,1fr));
}

.month-range-week {
  display: grid;
  grid-template-columns: repeat(7,minmax(0,1fr));
  grid-template-rows: 42px repeat(var(--lanes),34px) minmax(14px,1fr);
  row-gap: 4px;
  min-height: 126px;
  border-top: 1px solid var(--border);
  isolation: isolate;
}

.month-range-day {
  border-right: 1px solid var(--border);
  z-index: -1;
  background: var(--surface);
}

.month-range-day.is-muted {
  background: var(--surface-alt);
}

.month-range-date {
  justify-self: start;
  align-self: center;
  margin-left: 7px;
}

.month-range-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  margin: 0 4px;
  padding: 6px 9px;
  border: 1px solid var(--brand-border);
  border-left: 3px solid var(--brand);
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font: inherit;
  font-size: var(--fs-xs);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.month-range-bar.is-multi {
  background: var(--brand-soft-strong);
  font-weight: 700;
}

.month-range-bar .range-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.month-range-bar small {
  font-size: var(--fs-xs);
  white-space: nowrap;
  font-weight: 400;
}

.month-range-bar.continues-before {
  border-radius: 0 7px 7px 0;
  border-left: 1px solid var(--brand-border);
  margin-left: 0;
}

.month-range-bar.continues-after {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  margin-right: 0;
}

.month-range-bar:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
}

.month-range-bar.status-completed,
.month-range-bar.status-invoiced {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}

.month-range-bar.status-in_progress {
  background: var(--warning-soft);
  border-color: var(--warning-border);
  color: var(--warning);
}

.month-range-bar.status-cancelled {
  background: var(--neutral-soft);
  border-color: var(--border);
  color: var(--text-muted);
}
/* ═══ attendance ═══════════════════════════════════════════ */

.attendance {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.attendance .page-heading {
  margin-bottom: 0;
}

.attendance-section {
  padding: clamp(16px, 2.5vw, 28px);
  min-width: 0;
  scroll-margin-top: 90px;
}

.attendance-section h2 {
  margin: 0;
  font-size: var(--fs-lg);
}

.attendance-section h3 {
  font-size: var(--fs-md);
}

.attendance-section p,
.attendance-muted {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.attendance-section-heading,
.attendance-clock {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.attendance-section-heading > span {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.attendance-section-heading p {
  margin: 6px 0 0;
}

.attendance-clock {
  background: var(--brand-soft);
  border-color: var(--border);
}

.attendance-clock h2 {
  margin: 10px 0 0;
  font-size: clamp(22px, 3.5vw, 30px);
}

.attendance-clock p {
  margin: 6px 0;
  color: var(--text);
}

.attendance-clock button {
  min-height: 52px;
}

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

.attendance-filter {
  align-items: end;
}

.attendance-filter .field {
  margin: 0;
  min-width: 0;
}

.attendance-filter input {
  min-height: 44px;
  padding: 9px 11px;
}

.attendance-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attendance-jump a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--navy);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.attendance-jump a:hover {
  background: var(--brand-soft);
}

.attendance .attendance-badge {
  display: inline-block;
  background: var(--neutral-soft);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 5px 9px;
  font-size: var(--fs-xs);
  font-weight: 750;
}

.attendance-badge[data-state="working"] {
  background: var(--success-soft);
  color: var(--success);
}

.attendance-badge[data-state="paused"] {
  background: var(--warning-soft);
  color: var(--warning);
}

.attendance-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 14px;
}

.attendance-metrics > div {
  padding: 12px;
  border-radius: 10px;
  background: var(--bg);
}

.attendance-metrics span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.attendance-metrics strong {
  font-size: clamp(15px, 2.8vw, 22px);
  font-variant-numeric: tabular-nums;
}

.attendance-metrics small {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.attendance-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.attendance-list li {
  border-top: 1px solid var(--border);
}

.attendance-team a,
.attendance-entries li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  padding: 10px 8px;
  font-size: var(--fs-sm);
}

.attendance-team a[aria-current],
.attendance-team a:hover {
  background: var(--bg);
}

.attendance-team small,
.attendance-entries small {
  color: var(--text-muted);
}

.attendance-entries small {
  display: block;
  margin-top: 3px;
}

.attendance-day {
  margin-top: 16px;
}

.attendance-day h3 {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 0;
}

.attendance-day h3 small {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.attendance-details {
  margin: 10px 0 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  scroll-margin-top: 90px;
}

.attendance-details > summary {
  cursor: pointer;
  padding: 13px;
  font-size: var(--fs-sm);
  font-weight: 750;
  line-height: 1.4;
}

.attendance-details-body {
  padding: 0 12px 12px;
}

.attendance-events {
  padding-inline-start: 20px;
  font-size: var(--fs-sm);
}

.attendance-event {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  overflow-wrap: anywhere;
}

.attendance-form {
  display: grid;
  gap: 12px;
  align-items: start;
}

.attendance-form .field,
.attendance-form p {
  margin: 0;
}

.attendance-form > button {
  justify-self: start;
}

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

.attendance-time-input,
.attendance .field {
  min-width: 0;
}

.attendance .field input {
  min-width: 0;
}

.attendance-offset {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.attendance-offset select {
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
}

.attendance-pause {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.attendance-pause .attendance-actions {
  margin-top: 8px;
}

.attendance [data-add-pause] {
  margin-top: 10px;
}

.attendance [hidden] {
  display: none;
}

.attendance form[aria-busy="true"] button[type="submit"],
.attendance form[aria-busy="true"] button:not([type]) {
  opacity: .7;
  cursor: wait;
}

@media (max-width: 600px) {
  .attendance-clock form,
  .attendance-download {
    width: 100%;
  }
  .attendance-clock button,
  .attendance-download a {
    flex: 1 1 130px;
  }
  .attendance-fields {
    grid-template-columns: 1fr;
  }
  .attendance-team a {
    justify-content: flex-start;
  }
  .attendance-team a strong {
    flex-basis: 100%;
  }
}
/* ═══ invoice-archive ═══════════════════════════════════════════ */

.archive-controls {
  margin-bottom: 24px;
  padding: 22px 24px;
}

.invoice-preview-open {
  overflow: hidden;
}

.invoice-preview-modal {
  width: min(1100px,94vw);
  max-width: 94vw;
  height: 92dvh;
  max-height: 92dvh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-alt);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(16,29,58,.25);
}

.invoice-preview-modal[open] {
  display: flex;
  flex-direction: column;
}

.invoice-preview-modal::backdrop {
  background: rgba(16,29,58,.6);
}

.invoice-preview-modal>header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid var(--border);
}

.invoice-preview-modal h2 {
  font-size: var(--fs-md);
  margin: 0;
  overflow-wrap: anywhere;
}

.invoice-preview-modal header button {
  flex-shrink: 0;
  min-height: 44px;
}

.invoice-preview-status {
  font-size: var(--fs-xs);
  margin: 0;
  padding: 8px 20px;
  color: var(--text-muted);
}

.invoice-preview-status:empty {
  display: none;
}

.invoice-preview-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.invoice-preview-body>iframe {
  width: 100%;
  height: 100%;
  min-height: 300px;
  border: 0;
  background: white;
}

.invoice-preview-body>img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: auto;
}

.invoice-preview-body .document-preview-sheet {
  margin: 0 auto;
  box-sizing: border-box;
}

@media (max-width:600px) {
  .invoice-preview-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .invoice-preview-modal>header {
    padding: 12px;
  }
  .invoice-preview-body {
    padding: 6px;
  }
}

.archive-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.archive-filter,
.archive-downloads {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

.archive-downloads form {
  margin: 0;
}

.archive-period {
  display: grid;
  gap: 8px;
  min-width: 240px;
}

.archive-period label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
}

.archive-period select {
  width: 100%;
  min-height: 46px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-alt);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}

.archive-controls .button,
.archive-month-header .button {
  min-height: 46px;
  padding: 11px 17px;
  border-radius: 11px;
  font-size: var(--fs-sm);
  line-height: 22px;
  box-shadow: none;
  white-space: normal;
  text-align: center;
}

.archive-reset {
  padding: 12px 4px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  min-height: 44px;
}

.archive-help {
  margin: 16px 0 0;
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--text-muted);
}

.archive-note {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin: 0 0 22px;
  line-height: 1.6;
}

.archive-month-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.archive-month-header h2 {
  margin: 0;
  font-size: var(--fs-lg);
  line-height: 1.3;
}

.archive-month-header>span {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.archive-month-header form {
  margin: 0 0 0 auto;
}

.archive-controls :is(a,button,select):focus-visible,
.archive-month-header button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (max-width:700px) {
  .archive-controls {
    padding: 16px;
  }
  .archive-filter {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    align-items: end;
  }
  .archive-period {
    min-width: 0;
  }
  .archive-reset {
    grid-column: 1/-1;
    padding: 0;
    min-height: 32px;
  }
  .archive-downloads {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
  }
  .archive-downloads .button {
    width: 100%;
  }
  .archive-month-header {
    padding: 16px;
    gap: 10px;
  }
  .archive-month-header h2 {
    width: 100%;
    font-size: var(--fs-lg);
  }
  .archive-month-header>span {
    flex: 1;
  }
  .archive-month-header .button {
    padding: 9px 12px;
    min-height: 44px;
  }
}
/* ═══ basebuild ═══════════════════════════════════════════ */

.app-body {
  background: var(--bg);
}

.app-body .sidebar {
  background: var(--navy);
  color: white;
  border-color: var(--navy-border);
}

.app-body .sidebar-brand {
  color: white;
  border-color: var(--navy-border);
  font-size: var(--fs-xl);
  letter-spacing: -.04em;
}

.app-body .sidebar-brand img {
  width: 36px;
}

.app-body .sidebar .nav-label,
.app-body .sidebar-user small {
  color: var(--on-dark-muted);
}

.app-body .sidebar .nav-item {
  color: var(--on-dark);
  font-size: var(--fs-sm);
  min-height: 42px;
}

.app-body .sidebar .nav-item:hover {
  background: var(--navy-hover);
  color: white;
}

.app-body .sidebar .nav-item.active {
  background: var(--brand);
  color: white;
}

.app-body .sidebar .nav-icon,
.app-body .sidebar-user button {
  color: inherit;
}

.app-body .sidebar-user {
  border-color: var(--navy-border);
}

.bb-login-brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -.06em;
}

.login-body .bb-login-brand img {
  width: 43px;
}

.bb-hero {
  padding: clamp(24px, 4vw, 48px);
  margin-bottom: 26px;
  border-radius: 20px;
  color: white;
  background: linear-gradient(112deg, var(--navy) 18%, var(--brand-deep));
}

.bb-hero h1 {
  font-size: clamp(29px, 4vw, 48px);
  margin: 6px 0 0;
  letter-spacing: -.05em;
  overflow-wrap: anywhere;
}

.bb-hero p {
  margin: 0;
  color: var(--on-dark);
  font-size: var(--fs-md);
}

.bb-actions {
  margin: 0 0 27px;
}

.bb-actions h2,
.bb-section-title {
  font-size: var(--fs-xl);
  letter-spacing: -.025em;
  margin: 0 0 11px;
}

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

.bb-action {
  display: grid;
  grid-template-columns: 46px minmax(0,1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  min-height: 80px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.bb-action:hover,
.bb-home .metric-card:hover {
  border-color: var(--brand);
  background: var(--surface-alt);
}

.bb-action:focus-visible,
.bb-home a:focus-visible,
.sidebar a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.bb-action strong,
.bb-action small {
  display: block;
}

.bb-action strong {
  font-size: var(--fs-md);
  line-height: 1.25;
}

.bb-action small {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.3;
}

.bb-action-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: var(--fs-xl);
}

.bb-arrow {
  color: var(--brand);
  font-size: var(--fs-lg);
}

.bb-home .metric-card {
  min-width: 0;
}

.bb-home .metric-card p {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.bb-home .metric-card small,
.bb-home .panel-header p {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.bb-home .panel-header h2 {
  font-size: var(--fs-lg);
}

.bb-home .job-row {
  grid-template-columns: 54px 16px minmax(0, 1fr);
}

.bb-home .job-card h3 a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bb-empty-note {
  padding: 0 22px 16px;
  color: var(--text-muted);
}

@media (max-width: 1050px) {
  .bb-action-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .bb-home .metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    margin-inline: 0;
    padding: 0;
    gap: 8px;
  }
  .bb-home .metric-card {
    padding: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .bb-home .metric-card .metric-link {
    display: none;
  }
  .bb-home .job-row {
    grid-template-columns: 46px 10px minmax(0,1fr);
  }
  .app-body .mobile-nav a {
    font-size: var(--fs-xs);
  }
}

.app-body .content > .page-heading h1,
.app-body .content > .page-heading > div h1 {
  font-size: clamp(26px, 3.6vw, 38px);
  line-height: 1.14;
  letter-spacing: -.04em;
}

.app-body .content .page-heading p:not(.eyebrow) {
  color: var(--text-muted);
}

.app-body .content .button,
.login-body .button,
.bb-activation .button {
  min-height: 44px;
}

.app-body .content .button-primary,
.login-body .button-primary,
.bb-activation .button-primary {
  background: var(--brand);
  color: white;
}

.app-body .content .button-primary:hover,
.login-body .button-primary:hover,
.bb-activation .button-primary:hover {
  background: var(--brand-strong);
}

.app-body .content .button-secondary {
  background: white;
}

.app-body .content .panel,
.app-body .content .detail-card {
  border-color: var(--border);
}

.app-body .content .field > span {
  font-size: var(--fs-sm);
}

.app-body .content .field input:not([type="checkbox"]):not([type="radio"]),
.app-body .content .field select,
.login-body .field input {
  min-height: 44px;
}

.app-body .content :is(input,select,textarea,button,a):focus-visible,
.login-body :is(input,button,a):focus-visible,
.bb-activation :is(input,button,a):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.bb-activation {
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 100vh;
  background: var(--bg);
}

.bb-activation .login-card {
  margin: 0;
  width: min(100%,420px);
}

.bb-activation .bb-login-brand img {
  width: 40px;
  height: 40px;
}

@media (max-width:760px) {
  .app-body .content .page-heading {
    max-width: 100%;
  }
  .app-body .content .heading-actions {
    flex-wrap: wrap;
  }
  .app-body .content .heading-actions .button {
    flex: 1 1 140px;
  }
  .app-body .content :is(.responsive-table,.preview-lines) {
    max-width: 100%;
  }
}

@media (max-width:760px) {
  .app-body .sidebar:not(.open) {
    box-shadow: none;
  }
}

.bb-menu-settings {
  padding: 20px;
}

.bb-menu-settings fieldset {
  border: 0;
  padding: 0;
  min-width: 0;
}

.bb-menu-settings legend {
  font-size: var(--fs-lg);
  font-weight: 750;
  margin-bottom: 12px;
}

.bb-menu-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.bb-menu-options .checkbox {
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 48px;
  padding: 10px 12px;
  cursor: pointer;
}

@media (max-width: 760px) {
  .app-body .bb-custom-mobile-nav {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
  }
}

.technician-unassigned {
  flex: none;
  padding: 4px 9px;
  border: 1px dashed var(--border);
  border-radius: 99px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}

.login-card .button-block {
  margin-top: 8px;
}

.detail-identity p {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.supplier-detail-grid {
  align-items: start;
}
/* ═══ iconos ═══════════════════════════════════════════ */

.icon {
  display: inline-block;
  flex: none;
  width: 1.25em;
  height: 1.25em;
  vertical-align: -0.25em;
}

.nav-icon {
  display: grid;
  place-items: center;
}

.nav-icon .icon,
.sidebar-user form button .icon {
  width: 20px;
  height: 20px;
}

.mobile-nav a > span .icon {
  width: 22px;
  height: 22px;
}

.metric-icon .icon,
.bb-action-icon .icon,
.menu-button .icon {
  width: 22px;
  height: 22px;
}

.global-search .icon {
  width: 16px;
  height: 16px;
}

.metric-link .icon,
.bb-arrow .icon {
  width: 18px;
  height: 18px;
}
/* ═══ insignias de estado (status_badge() en config/bootstrap.php) ═══ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--neutral-soft);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-info {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

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

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

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
/* ═══ pestañas: vistas de una misma sección (no acciones) ═══ */

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
  margin: 0 0 16px;
  padding: 4px;
  border-radius: 12px;
  background: var(--neutral-soft);
}

.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a[aria-current="page"],
.tabs a.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 2px 6px rgba(16,29,58,.08);
}

.tabs small {
  color: var(--text-subtle);
  font-size: var(--fs-xs);
  font-weight: 500;
}

@media (max-width: 760px) {
  .tabs {
    display: flex;
  }
  .tabs a {
    flex: 1;
    justify-content: center;
    padding-inline: 10px;
    text-align: center;
  }
}

.agenda-toolbar .tabs {
  margin: 0;
}
/* Texto libre dentro de una ficha (condiciones, instrucciones). */

.detail-text {
  grid-column: 1 / -1;
  margin: 0;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
/* Foco visible con teclado: una sola regla para toda la app. */

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
/* Archivo de facturas y gastos */

.archive-month {
  margin-top: 20px;
}

.archive-file {
  min-width: 220px;
  max-width: 340px;
  margin: 8px 0;
  overflow-wrap: anywhere;
}

.archive-file-name {
  display: block;
  max-width: 340px;
  overflow-wrap: anywhere;
}

.archive-file-link {
  display: inline-block;
  padding: 10px 8px 10px 0;
}

#materiales {
  margin-top: 24px;
}
/* Aviso de borrador sin validez fiscal en la vista previa */

.draft-warning {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.5;
}
/* Lista de opciones (rectificar factura): cada opción, con su botón a la izquierda del texto. Viene de main (forms.css). */

.choice-list {
  margin: 0 0 18px;
  padding: 12px 16px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.choice-list legend {
  padding: 0 6px;
  font-weight: 700;
}

.choice-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 8px 0;
  font-weight: 400;
  text-align: left;
}

.choice-list label + label {
  border-top: 1px solid var(--border);
}

.choice-list input {
  flex: none;
  width: auto;
  margin-top: 3px;
  accent-color: var(--brand);
}

.choice-list small {
  color: var(--text-muted);
}
/* ═══ tarjeta de trabajo del técnico ═══ */

.job-card-tec {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 18px;
}

.job-card-tec > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.job-when {
  font-size: var(--fs-sm);
  font-weight: 800;
}

.job-card-tec h2 {
  margin: 0;
  font-size: var(--fs-lg);
  line-height: 1.3;
}

.job-client {
  margin: -6px 0 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.job-contact {
  display: grid;
  gap: 6px;
}

.job-contact-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--brand);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.job-contact-link.is-empty {
  color: var(--text-muted);
  font-weight: 500;
}

@media (max-width: 760px) {
  .button-block-mobile {
    width: 100%;
  }
}
/* ═══ móvil: tablas como tarjetas (data-label lo pone app.js) ═══ */

@media (max-width: 760px) {
  table.table-cards {
    min-width: 0;
  }
  .table-cards thead {
    display: none;
  }
  .table-cards,
  .table-cards tbody,
  .table-cards tr,
  .table-cards td {
    display: block;
    width: 100%;
  }
  .table-cards tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  .table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    border: 0;
    text-align: right;
  }
  .table-cards td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-align: left;
  }
  .table-cards td:not([data-label]) {
    justify-content: flex-end;
  }
}
/* Parte de trabajo: tiempo rápido y selectores de foto */

.quick-minutes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-minutes .button {
  min-height: 40px;
  padding: 8px 14px;
}

input[type="file"] {
  max-width: 100%;
  font-size: var(--fs-sm);
}

input[type="file"]::file-selector-button {
  min-height: 44px;
  margin-right: 12px;
  padding: 10px 16px;
  border: 1px solid var(--brand-border);
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ═══ logo de la empresa en sus documentos ═══ */

.company-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.company-logo img {
  display: block;
  width: auto;
  max-width: 180px;
  height: auto;
  max-height: 56px;
  object-fit: contain;
  filter: none;
}

.company-logo-name {
  font-size: var(--fs-lg);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.logo-settings {
  margin-bottom: 18px;
}

.logo-settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.logo-settings-preview {
  display: grid;
  place-items: center;
  min-width: 200px;
  min-height: 80px;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
}

.logo-settings-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.logo-settings-form .field {
  margin: 0;
}

/* Gasto: botones para calcular base e IVA desde el total. */
.tax-split { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: var(--fs-xs); }
.tax-split .button { padding: 4px 10px; min-height: 0; font-size: var(--fs-xs); }

/* Eliminar, separado de las acciones de crear */
.heading-actions form:has(> .button-danger) {
  margin-right: 12px;
}

@media (min-width: 1101px) {
  .metrics-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Error de un campo concreto (formularios rechazados por el servidor). */
.field-error { display: block; margin-top: 4px; color: var(--danger); font-size: var(--fs-xs); }
[aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft); }

/* Separación uniforme entre las tarjetas y rejillas seguidas de una ficha. */
.content > :is(.panel, .supplier-detail-grid) + :is(.panel, .supplier-detail-grid) { margin-top: 20px; }

/* En pantallas anchas, los botones de la cabecera no se parten en dos filas: cede el título. */
@media (min-width: 900px) {
  .page-heading > .heading-actions { flex-shrink: 0; justify-content: flex-end; }
}

/* Facturas emitidas: filas compactas, importes a la derecha sin partirse. */
.invoice-archive-table td, .invoice-archive-table th { vertical-align: middle; }
.invoice-archive-table .amount { text-align: right; white-space: nowrap; }
.invoice-archive-table .archive-number { display: block; font-weight: 700; color: var(--text); white-space: nowrap; }
.invoice-archive-table .archive-number + small { display: block; color: var(--text-muted); font-size: var(--fs-xs); }
.invoice-archive-table .invoice-doc-links { white-space: nowrap; }
.invoice-archive-table .invoice-doc-links .text-link { display: inline; }
.invoice-archive-table .archive-number + small { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* Costes del trabajo: separa «Guardar coste» del botón o aviso de factura que va debajo. */
.work-billing > form + :is(form, p) { margin-top: 16px; }

/* Plan y pago */
.plan-status, .plan-card { padding: 24px; }
.plan-status h2, .plan-card h2 { margin: 0 0 .5rem; font-size: var(--fs-lg); }
.plan-status p { color: var(--text-muted); margin: 0; }
.plan-status form { margin-top: 1rem; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }
.plan-card { display: flex; flex-direction: column; gap: .5rem; }
.plan-card p { margin: 0; color: var(--text-muted); }
.plan-price { margin: .25rem 0 !important; }
.plan-card form { margin-top: auto; padding-top: 1.25rem; }
.plan-card .button { width: 100%; }
.plan-featured { border-color: var(--brand-border); box-shadow: 0 0 0 2px var(--brand-soft-strong); }
.plan-price strong { font-size: var(--fs-2xl); color: var(--text); line-height: 1.1; }
.plan-warning { font-size: var(--fs-sm); color: var(--warning) !important; background: var(--warning-soft); border: 1px solid var(--warning-border); border-radius: 8px; padding: .5rem .75rem; }
.plan-footnote { color: var(--text-subtle); font-size: var(--fs-sm); margin-top: 1rem; }
.plan-notice { margin-bottom: 1rem; }
