:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2937;
  background: #f4f6f9;
  --blue: #0277f8;
  --blue-dark: #005fca;
  --border: #d6dde7;
  --muted: #64748b;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f4f6f9; }
button, input, textarea { font: inherit; }

.app-nav {
  min-height: 52px;
  padding: 0 18px;
  background: #1f2b5b;
  display: flex;
  align-items: center;
  gap: 28px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .055em;
  white-space: nowrap;
}
.nav-links { display: flex; align-items: stretch; min-height: 52px; overflow-x: auto; }
.nav-link {
  border: 0;
  background: transparent;
  color: #d7def5;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 650;
  cursor: default;
  border-bottom: 3px solid transparent;
}
.nav-link.active { color: #fff; border-bottom-color: #38a7ff; background: rgba(255,255,255,.06); }
.nav-link.pending { opacity: .72; }

.page-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.breadcrumbs { display: flex; gap: 7px; align-items: center; color: #64748b; font-size: 11px; margin-bottom: 5px; }
.breadcrumbs span:nth-child(2) { color: var(--blue); font-weight: 700; }
h1 { margin: 0; color: #075aa8; font-size: 24px; font-weight: 750; }
.header-actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }

.page-shell { padding: 18px 24px 42px; }
.staging-banner {
  background: #edf6ff;
  border: 1px solid #b9d9ff;
  color: #164c84;
  padding: 10px 13px;
  border-radius: 7px;
  font-size: 12px;
  margin-bottom: 14px;
}

.search-card {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 175px 230px;
  align-items: end;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.search-block label { display: block; font-size: 11px; color: #334155; font-weight: 700; margin-bottom: 5px; }
input, textarea {
  width: 100%;
  border: 1px solid #c7d0dd;
  border-radius: 5px;
  background: #fff;
  color: #111827;
  font-size: 14px;
  font-weight: 400;
  padding: 8px 9px;
}
input::placeholder, textarea::placeholder { color: #94a3b8; font-size: 12px; }
input:focus, textarea:focus { outline: 2px solid rgba(2,119,248,.13); border-color: var(--blue); }
.record-card { padding: 7px 11px; background: #f8fafc; border-left: 3px solid var(--blue); min-height: 58px; }
.record-card span { display: block; text-transform: uppercase; color: #64748b; font-size: 10px; font-weight: 800; }
.record-card strong { display: block; font-size: 24px; line-height: 1.15; color: #0f172a; margin-top: 3px; }
.connection-status { font-size: 11px; color: #64748b; text-align: right; padding-bottom: 8px; }
.connection-status.error { color: #b91c1c; }

.table-panel { background: transparent; }
.table-scroll { overflow-x: auto; }
.customer-table { width: 100%; min-width: 1180px; border-collapse: collapse; font-size: 11px; }
.customer-table th {
  background: #f1f4f8;
  color: #005da8;
  font-weight: 750;
  padding: 8px 9px;
  border: 1px solid #d4dae2;
  text-align: left;
  white-space: nowrap;
}
.customer-table td {
  background: #fff;
  padding: 7px 9px;
  border: 1px solid #d4dae2;
  color: #334155;
  vertical-align: middle;
}
.customer-table .main-row td { border-bottom-color: #cbd5e1; }
.customer-table .company-name { font-weight: 700; color: #26384c; }
.select-col { width: 34px; text-align: center !important; }
.select-col input, .row-select { width: auto; }
.actions-head { width: 240px; text-align: right !important; }
.actions-cell { text-align: right; }
.action-wrap { display: flex; justify-content: flex-end; gap: 5px; align-items: center; }
.detail-spacer { width: 34px; background: #fff !important; padding: 0 !important; }
.detail-cell { padding: 6px 8px 9px !important; background: #f8fafc !important; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.detail-table th { background: #f5f5f5; color: #858b93; font-weight: 650; padding: 6px 8px; border: 1px solid #d8dce2; }
.detail-table td { background: #fff; color: #333; padding: 6px 8px; border: 1px solid #d8dce2; }
.group-gap td { height: 9px; padding: 0; border: 0; background: transparent; }
.empty-cell { padding: 32px !important; text-align: center; color: #94a3b8 !important; }

.btn {
  border-radius: 5px;
  border: 1px solid transparent;
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn.small { min-height: 30px; padding: 5px 10px; font-size: 11px; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.success { background: #20a755; color: #fff; }
.btn.success:hover { background: #168c46; }
.btn.secondary { background: #fff; color: #26384c; border-color: #b9d2ef; }
.btn.secondary:hover { background: #f7fbff; }
.btn.danger { background: #fff; color: #c62828; border-color: #f2aaaa; }
.btn.danger:hover { background: #fff5f5; }
button:disabled { opacity: .55; cursor: not-allowed; }

.compact-action {
  min-width: 29px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  padding: 0 7px;
}
.compact-action.edit { background: #38a9e8; }
.compact-action.delete { background: #ef5350; }
.compact-action.docs { background: #38a9e8; }
.compact-action.wo { background: #176fd1; }
.compact-action.proposal { background: #8d98a8; }
.compact-action.job { background: #2cb35e; }
.compact-action.pending { opacity: .72; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15,23,42,.5);
}
.modal-backdrop.hidden { display: none; }
.modal {
  width: min(1100px, 100%);
  max-height: 92vh;
  background: #fff;
  border-radius: 11px;
  box-shadow: 0 24px 70px rgba(15,23,42,.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.import-modal { width: min(720px, 100%); }
.modal-header { flex: 0 0 auto; padding: 14px 18px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.modal-kicker { color: var(--blue); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.modal-header h2 { margin: 2px 0 0; font-size: 18px; color: #172033; }
.circle-close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #161d2c; color: #fff; font-size: 21px; line-height: 1; cursor: pointer; }
.modal-body { padding: 18px 20px 22px; overflow-y: auto; }
.modal-footer { flex: 0 0 auto; padding: 12px 18px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 8px; background: #fff; }
.section-title { margin: 4px 0 10px; padding-bottom: 5px; border-bottom: 1px solid #e6eaf0; font-size: 12px; color: #075ea8; font-weight: 800; }
.section-title:not(:first-child) { margin-top: 20px; }
.form-grid { display: grid; gap: 12px; align-items: end; }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; font-weight: 650; color: #3b4657; }
.field span.required, .required { color: #d32f2f; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.active-field { display: flex; align-items: center; gap: 7px; padding: 8px 0 1px; font-size: 12px; font-weight: 650; }
.active-field input { width: auto; }
.help-text { color: #556274; font-size: 12px; line-height: 1.55; margin-top: 0; }
.import-box { border: 1px dashed #9fc4ef; border-radius: 8px; padding: 16px; background: #f8fbff; }
.import-box p { color: #64748b; font-size: 11px; line-height: 1.5; margin-bottom: 0; }
.import-status { min-height: 20px; margin-top: 12px; font-size: 12px; color: #334155; }
.import-status.error { color: #b91c1c; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2000;
  max-width: 360px;
  background: #172033;
  color: #fff;
  border-radius: 7px;
  padding: 10px 13px;
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(15,23,42,.22);
}
.toast.hidden { display: none; }
.toast.error { background: #9f1d1d; }

@media (max-width: 1050px) {
  .app-nav { align-items: flex-start; flex-direction: column; gap: 0; padding-top: 12px; }
  .nav-links { width: 100%; }
  .search-card { grid-template-columns: 1fr 160px; }
  .connection-status { grid-column: 1 / -1; text-align: left; }
  .grid-7, .grid-6, .grid-5 { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 700px) {
  .page-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; }
  .page-shell, .page-header { padding-left: 14px; padding-right: 14px; }
  .search-card { grid-template-columns: 1fr; }
  .grid-7, .grid-6, .grid-5 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .span-4 { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .grid-7, .grid-6, .grid-5 { grid-template-columns: 1fr; }
  .span-2, .span-4 { grid-column: auto; }
  .modal-backdrop { padding: 10px; }
}
