:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #dde4ee;
  --soft: #eef3f8;
  --brand: #24528f;
  --brand-2: #1687a7;
  --danger: #c63d3d;
  --success: #087a52;
  --warning: #a25c00;
  --shadow: 0 14px 34px rgba(15, 23, 42, .09);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}

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

.hidden { display: none !important; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(47,86,159,.16), transparent 32%),
    linear-gradient(135deg, #eef4fb, #ffffff);
}

.login-panel {
  width: min(440px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.login-panel img {
  display: block;
  max-width: 210px;
  max-height: 110px;
  object-fit: contain;
  margin: 0 auto 16px;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

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

.login-panel form,
.field {
  display: grid;
  gap: 8px;
}

.login-panel form { gap: 16px; }

.login-panel label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  color: #354268;
}

.login-panel button,
.primary {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  min-height: 40px;
  padding: 9px 15px;
  font-weight: 800;
}

.login-panel small { min-height: 18px; color: var(--danger); }

.auth-help {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.auth-help p {
  margin: 0;
  font-weight: 750;
}

.auth-help-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-help .auth-secondary-form {
  padding: 14px;
  border-radius: 10px;
  background: var(--soft);
}

.auth-help small.success-text {
  color: var(--success);
}

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

.sidebar {
  background: #edf2f7;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 248px;
  z-index: 6;
}

.logo-box {
  min-height: 116px;
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  color: #1d75a1;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.logo-box img {
  max-width: 170px;
  max-height: 90px;
  object-fit: contain;
}

.brand-link {
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  transition: transform .18s ease, opacity .18s ease;
}

.brand-link:hover {
  opacity: .88;
  transform: translateY(-1px);
}

.brand-link:focus-visible {
  outline: 3px solid rgba(32, 103, 170, .3);
  outline-offset: 3px;
}

.login-brand-link { margin: 0 auto; }

#nav {
  display: grid;
  gap: 3px;
  padding: 0 10px 18px;
}

.nav-item,
.nav-group-title {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 9px;
  min-height: 38px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #415071;
  text-align: left;
  font-weight: 700;
}

.nav-group-title {
  justify-content: space-between;
  margin-top: 6px;
}

.nav-item {
  padding-left: 28px;
  font-weight: 600;
}

.nav-item:hover,
.nav-item.active,
.nav-group-title.active {
  background: #dbe4ef;
  color: var(--brand);
}

.nav-icon {
  display: inline-block;
  width: 18px;
  margin-right: 4px;
  text-align: center;
  color: #7182a5;
}

.main {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 58px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 4;
}

.top-left,
.top-right,
.toolbar,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-left h2 {
  margin: 0;
  font-size: 20px;
}

.top-right {
  color: #1f2944;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #e1e5ed;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #4a5570;
}

.icon-btn,
.ghost,
.secondary,
.danger {
  border: 1px solid var(--line);
  background: #f7f9fc;
  color: var(--brand);
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 750;
}

.icon-btn {
  width: 40px;
  padding: 0;
  display: grid;
  place-items: center;
}

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

.content {
  padding: 26px;
  display: grid;
  gap: 18px;
}

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 450px;
  gap: 18px;
  align-items: start;
}

.welcome h1 {
  margin: 0;
  font-size: 30px;
}

.welcome p {
  margin: 8px 0 16px;
  color: var(--muted);
}

.filter-box {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 2px 7px rgba(10, 30, 70, .05);
}

.filter-box small {
  display: block;
  color: var(--muted);
  margin-bottom: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  align-items: end;
}

.dashboard-filter .filter-grid {
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
}

.dashboard-filter .filter-actions {
  display: inline-flex;
  gap: 8px;
  align-items: end;
  justify-content: flex-end;
  white-space: nowrap;
}

.dashboard-filter .filter-actions button {
  flex: 0 0 auto;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 14px;
}

.card,
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 7px rgba(10, 30, 70, .05);
}

.card {
  min-height: 138px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #27365b;
  font-weight: 800;
}

.card strong {
  display: block;
  margin-top: 18px;
  font-size: 28px;
}

.trend {
  display: inline-flex;
  width: fit-content;
  margin-top: 4px;
  border-radius: 999px;
  background: #e1f5ec;
  color: #087a52;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.help-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 30px;
  border-radius: 12px;
  color: white;
  background: linear-gradient(135deg, #173f79, #2165a9);
}

.help-hero h1,
.help-topic h2,
.help-quick h2,
.help-notes h2 { margin: 0; }

.help-hero p { margin: 8px 0 0; color: #dbeafe; }
.help-kicker { display: block; margin-bottom: 5px; color: #93c5fd; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.help-quick { margin-top: 16px; }
.help-quick ol { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 16px 0 0; padding: 0; list-style-position: inside; }
.help-quick li { padding: 12px; border-radius: 8px; background: #f3f7fc; color: #44516c; }
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.help-topic { min-width: 0; overflow: hidden; }
.help-shot { display: block; aspect-ratio: 16 / 8.2; overflow: hidden; border-bottom: 1px solid var(--line); background: #eef3f9; }
.help-shot img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: top left; transition: transform .2s ease; }
.help-shot:hover img { transform: scale(1.015); }
.help-topic-body { padding: 16px; }
.help-topic-body p { min-height: 42px; margin: 8px 0 14px; color: var(--muted); }
.help-notes { margin-top: 16px; }
.help-notes ul { margin: 12px 0 0; padding-left: 22px; color: #44516c; }
.help-notes li + li { margin-top: 8px; }

@media (max-width: 900px) {
  .help-quick ol,
  .help-grid { grid-template-columns: 1fr; }
  .help-hero { align-items: flex-start; flex-direction: column; }
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  gap: 18px;
}

.dashboard-panel-stack {
  min-width: 0;
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel {
  overflow: hidden;
}

.panel-head {
  min-height: 62px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h3 {
  margin: 0;
  font-size: 17px;
}

.sticky-collection-panel {
  overflow: visible;
}

.sticky-toolbar-head {
  position: sticky;
  top: 58px;
  z-index: 3;
  background: var(--panel, #fff);
  box-shadow: 0 8px 14px rgba(31, 41, 68, .08);
}

.panel-body {
  padding: 18px;
}

.search {
  border: 0;
  background: #e4e9f0;
  color: #51617e;
  border-radius: 9px;
  min-height: 40px;
  min-width: 320px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: #f8f9fc;
  color: var(--ink);
  border-radius: 8px;
  min-height: 39px;
  padding: 8px 11px;
}

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

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  padding: 13px 16px;
  font-size: 14px;
}

th {
  background: #f4f6fa;
  color: #68769a;
  font-size: 12px;
  text-transform: uppercase;
}

.sort-btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.sort-btn:hover {
  color: var(--brand);
}

tr:hover td { background: #f9fbfe; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid #dce3ee;
  color: #52617f;
  background: #f6f8fb;
  white-space: nowrap;
}

.pill.ok {
  color: var(--success);
  border-color: #bee7d7;
  background: #e8f7f0;
}

.pill.warn {
  color: var(--warning);
  border-color: #f0ddb7;
  background: #fff5df;
}

.pill.bad {
  color: var(--danger);
  border-color: #efc2c2;
  background: #fff0f0;
}

.empty {
  padding: 48px 18px;
  color: var(--muted);
  text-align: center;
}

.pipeline {
  display: grid;
  gap: 13px;
}

.stage-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  font-weight: 800;
}

.stage-line small {
  color: var(--muted);
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
  margin-top: 8px;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

.mini-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.mini {
  background: #e8f5ef;
  border-radius: 10px;
  padding: 16px;
}

.mini:nth-child(1) { background: #eef1f7; }
.mini small { color: var(--muted); }
.mini strong {
  display: block;
  font-size: 22px;
  margin-top: 10px;
}

.market-line {
  display: flex;
  align-items: stretch;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 2px;
}

.market-chip {
  display: inline-flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
}

.market-chip.metal {
  min-width: 230px;
}

.market-chip.muted {
  background: #eef1f7;
}

.market-chip small,
.market-chip em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.market-chip strong {
  font-size: 17px;
}

.metal-sparkline {
  width: 180px;
  height: 34px;
  display: block;
  border-bottom: 1px solid #d8e0ec;
}

.metal-sparkline.empty-line {
  height: 6px;
}

.empty.compact {
  margin-top: 10px;
  padding: 10px;
}

dialog {
  width: min(920px, calc(100vw - 24px));
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(18, 31, 55, .35);
  backdrop-filter: blur(2px);
}

.dialog-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h3 {
  margin: 0;
  font-size: 24px;
}

#recordForm {
  padding: 20px 24px 24px;
  display: grid;
  gap: 16px;
}

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

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

.field label {
  color: #4d5876;
  font-size: 13px;
  font-weight: 800;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.photo-editor {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  background: #f8f9fc;
  border-radius: 10px;
  padding: 12px;
}

.photo-preview {
  width: 86px;
  height: 86px;
  border-radius: 10px;
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: white;
  color: var(--muted);
  font-size: 12px;
}

.photo-preview img,
.avatar-mini {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-controls {
  display: grid;
  gap: 8px;
}

.photo-controls small,
.ruc-result {
  color: var(--muted);
  font-size: 12px;
}

.person-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
}

.avatar-mini {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.avatar-mini.initials {
  display: grid;
  place-items: center;
  background: #dfe7f2;
  color: #2f569f;
  font-size: 12px;
}

.mini-link {
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

.mini-link:hover {
  text-decoration: underline;
}

.import-box {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  border: 1px solid var(--line);
  background: #f8f9fc;
  border-radius: 10px;
  padding: 14px;
  margin-top: 14px;
}

.import-preview {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

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

.form-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  padding-top: 4px;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.relation-field select {
  min-height: 38px;
}

.relation-value-select {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.relation-search-result,
.opportunity-process small {
  color: var(--muted);
  min-height: 16px;
  font-size: 12px;
}

.opportunity-code {
  border: 1px dashed #b9c7dd;
  background: #f3f7fc;
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
  font-weight: 800;
}

.opportunity-code label {
  display: grid;
  gap: 6px;
}

.opportunity-code input {
  max-width: 280px;
}

.opportunity-code small {
  color: var(--muted);
  font-weight: 500;
}

.items-editor {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.items-editor header {
  background: #f4f6fa;
  border-bottom: 1px solid var(--line);
  min-height: 48px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.items-table {
  width: 100%;
  min-width: 760px;
}

.items-table input,
.items-table select {
  width: 100%;
  min-height: 34px;
}

.items-summary {
  padding: 12px;
  background: #fbfcfe;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  font-weight: 900;
}

.readonly {
  opacity: .85;
  pointer-events: none;
}

.link-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 0;
  font: inherit;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.detail-page {
  display: grid;
  gap: 16px;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px 0 8px;
}

.detail-header h3 {
  margin: 0 0 4px;
  font-size: 24px;
}

.detail-header p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr);
  gap: 16px;
}

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

.detail-fields div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.detail-fields span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-fields strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.contact-detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 0;
}

.contact-detail-head img,
.avatar-mini {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-mini {
  display: inline-grid;
  place-items: center;
  background: var(--soft);
  color: var(--brand);
  font-weight: 900;
}

.activities-panel {
  border-color: #c7d7f4;
}

.activity-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.activity-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.activity-card span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.activity-card p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  background: #112246;
  color: white;
  border-radius: 9px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Visual refinement: compact, calmer CRM surface. */
.app {
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  width: 236px;
  background: #f8fafc;
  box-shadow: 1px 0 0 rgba(15, 23, 42, .03);
}

.logo-box {
  min-height: 96px;
  padding: 10px;
}

.logo-box img {
  max-width: 150px;
  max-height: 74px;
}

#nav {
  gap: 2px;
  padding: 0 9px 14px;
}

.nav-item,
.nav-group-title {
  min-height: 34px;
  border-radius: 7px;
  padding: 7px 10px;
  color: #4b5563;
  font-size: 13px;
  font-weight: 650;
}

.nav-group-title {
  margin-top: 4px;
  font-weight: 760;
}

.nav-item {
  padding-left: 24px;
}

.nav-item:hover,
.nav-item.active,
.nav-group-title.active {
  background: #e8eef6;
  color: #1f4f88;
}

.main {
  grid-column: 2;
}

.topbar {
  height: 52px;
  padding: 0 18px;
  background: rgba(255,255,255,.9);
}

.top-left h2 {
  font-size: 17px;
  font-weight: 760;
}

.top-right {
  font-size: 13px;
}

.avatar {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.content {
  padding: 20px;
  gap: 14px;
}

.hero-row,
.grid-two {
  gap: 14px;
}

.welcome h1 {
  font-size: 24px;
  font-weight: 780;
}

.welcome p {
  margin: 6px 0 12px;
}

.stats {
  gap: 12px;
}

.card,
.panel,
.filter-box {
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}

.card {
  min-height: 104px;
  padding: 14px;
}

.card-head {
  font-size: 13px;
  font-weight: 760;
}

.card strong {
  margin-top: 12px;
  font-size: 22px;
}

.trend,
.pill {
  font-size: 11px;
  font-weight: 760;
}

.panel-head {
  min-height: 50px;
  padding: 11px 14px;
}

.panel-head h3 {
  font-size: 15px;
  font-weight: 780;
}

.panel-body {
  padding: 14px;
}

.toolbar,
.row-actions,
.top-left,
.top-right {
  gap: 8px;
}

.login-panel button,
.primary,
.secondary,
.danger,
.ghost,
.icon-btn {
  min-height: 34px;
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 760;
}

.icon-btn {
  width: 34px;
}

input,
select,
textarea {
  min-height: 35px;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
}

.search {
  min-height: 35px;
  min-width: 260px;
  border-radius: 7px;
  background: #eef2f7;
  font-size: 13px;
}

th,
td {
  padding: 9px 12px;
  font-size: 13px;
}

th {
  font-size: 11px;
  letter-spacing: 0;
  color: #64748b;
}

table {
  min-width: 820px;
}

tr:hover td {
  background: #f7fafd;
}

.link-button,
.person-cell {
  font-weight: 760;
}

.market-chip {
  min-width: 136px;
  border-radius: 7px;
  padding: 9px 10px;
}

.market-chip strong {
  font-size: 15px;
}

.mini {
  border-radius: 8px;
  padding: 12px;
}

.mini strong {
  font-size: 18px;
  margin-top: 6px;
}

dialog {
  border-radius: 10px;
}

.dialog-head {
  min-height: 50px;
  padding: 11px 18px;
}

.dialog-head h3,
.detail-header h3 {
  font-size: 19px;
  font-weight: 780;
}

#recordForm {
  padding: 16px 20px 20px;
  gap: 14px;
}

.form-grid,
.detail-fields {
  gap: 12px;
}

.field label {
  font-size: 12px;
  font-weight: 760;
}

.items-editor,
.opportunity-code,
.photo-editor,
.import-box,
.activity-card {
  border-radius: 8px;
}

.items-editor header {
  min-height: 42px;
  padding: 8px 10px;
}

.items-table input,
.items-table select {
  min-height: 32px;
}

.items-summary {
  padding: 10px;
}

.detail-fields {
  padding: 14px;
}

.detail-fields span,
.activity-card span {
  font-size: 11px;
}

.empty {
  padding: 34px 14px;
}

.dark {
  --bg: #101725;
  --panel: #182234;
  --ink: #f2f5fb;
  --muted: #aab5ca;
  --line: #29364f;
  --soft: #202d44;
}

.dark .card,
.dark .panel,
.dark .topbar,
.dark .login-panel,
.dark .filter-box {
  background: var(--panel);
}

.dark .sidebar {
  background: #151f30;
}

.dark input,
.dark select,
.dark textarea,
.dark .search,
.dark .icon-btn,
.dark .ghost,
.dark .secondary,
.dark th {
  background: #202d44;
  color: var(--ink);
}

@media (max-width: 1100px) {
  .app { grid-template-columns: 248px minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    width: 248px;
    height: 100vh;
    overflow-y: auto;
    min-height: 0;
  }
  .main { grid-column: 2; }
  #nav {
    grid-template-columns: 1fr;
  }
  .hero-row,
  .grid-two,
  .stats {
    grid-template-columns: 1fr;
  }
  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  .dashboard-filter .filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  .dashboard-filter .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .app { grid-template-columns: 248px minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    width: 248px;
    height: 100vh;
    overflow-y: auto;
    min-height: 0;
  }
  .main { grid-column: 2; }
  .content { padding: 16px; }
  .topbar {
    height: auto;
    padding: 12px;
    align-items: flex-start;
    flex-direction: column;
  }
  .top-right {
    flex-wrap: wrap;
  }
  #nav {
    grid-template-columns: 1fr;
  }
  .toolbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }
  .search,
  .primary,
  .secondary,
  .danger {
    width: 100%;
  }
  .form-grid,
  .filter-grid,
  .mini-cards,
  .import-box,
  .opportunity-code,
  .detail-grid,
  .detail-fields {
    grid-template-columns: 1fr;
  }
  .dashboard-filter .filter-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-filter .filter-actions {
    justify-content: stretch;
  }
  .dashboard-filter .filter-actions .primary,
  .dashboard-filter .filter-actions .icon-btn {
    flex: 1 1 0;
    width: auto;
  }

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


.market-chip.fx {
  width: 230px;
  min-width: 230px;
}

.market-chip.gold {
  background: linear-gradient(180deg, #fff8df, #f5d36c);
  border-color: #d4a719;
}

.market-chip.silver {
  background: linear-gradient(180deg, #ffffff, #d9dde4);
  border-color: #aab2bf;
}

.market-chip.copper {
  background: linear-gradient(180deg, #fff0e8, #c87942);
  border-color: #9d512a;
}

.market-chip.zinc {
  background: linear-gradient(180deg, #f7fbfd, #9fb4bf);
  border-color: #6f8792;
}

.market-chip.gold small,
.market-chip.gold em,
.market-chip.silver small,
.market-chip.silver em,
.market-chip.copper small,
.market-chip.copper em,
.market-chip.zinc small,
.market-chip.zinc em {
  color: #253044;
}

.market-chip.weather.weather-card {
  text-decoration: none;
  cursor: pointer;
  width: 268px;
  min-width: 268px;
  height: 190px;
  position: relative;
  overflow: hidden;
  gap: 0;
  padding: 0;
  border: 1px solid #1d3b61;
  background: #0e1b31;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

.weather-card-top {
  display: grid;
  grid-template-columns: 34px 78px 1fr 12px;
  align-items: center;
  gap: 7px;
  min-height: 58px;
  padding: 8px 9px 6px;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.12) 0 1px, transparent 2px),
    linear-gradient(135deg, #172943, #0d1a2e 70%);
}

.weather-moon {
  width: 34px;
  height: 34px;
  display: block;
  border-radius: 50%;
  background: #ffad2f;
  box-shadow: inset 10px 0 0 #172943;
}

.weather-temp {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  font-size: 40px;
  line-height: 1;
  font-weight: 300;
  letter-spacing: 0;
}

.weather-temp sup {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
}

.weather-alert {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #f6f8fb;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
}

.weather-alert-mark {
  width: 15px;
  height: 15px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #ff7938;
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
}

.weather-arrow {
  color: #e6edf7;
  font-size: 24px;
  line-height: 1;
}

.weather-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(8, 18, 34, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.weather-tabs span {
  display: grid;
  place-items: center;
  min-height: 25px;
  color: #edf4ff;
  font-size: 11px;
  font-weight: 700;
}

.weather-tabs .active {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px 3px 0 0;
}

.weather-map {
  position: relative;
  display: block;
  height: 80px;
  overflow: hidden;
  background:
    linear-gradient(100deg, #a8dded 0 42%, transparent 42%),
    repeating-linear-gradient(22deg, rgba(126, 93, 54, 0.25) 0 2px, transparent 2px 7px),
    linear-gradient(105deg, #f5c16a 0 46%, #e99b45 46% 62%, #d6d9d6 62% 100%);
}

.weather-zone {
  position: absolute;
  inset: -18px 78px -12px 118px;
  background: rgba(255, 118, 40, 0.36);
  border-left: 1px solid rgba(173, 74, 27, 0.45);
  border-right: 1px solid rgba(173, 74, 27, 0.45);
  transform: rotate(-10deg);
}

.weather-map::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(150deg, transparent 0 8px, rgba(94, 76, 53, 0.18) 8px 9px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.08));
  pointer-events: none;
}

.weather-map-label {
  position: absolute;
  z-index: 1;
  color: rgba(38, 48, 60, 0.82);
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.65);
}

.weather-map-label.north {
  left: 50px;
  top: 22px;
}

.weather-map-label.east {
  right: 16px;
  top: 42px;
}

.weather-map-label.center {
  left: 108px;
  bottom: 6px;
  color: #5b4a34;
  font-size: 18px;
}

.weather-pin {
  position: absolute;
  z-index: 2;
  left: 122px;
  top: 51px;
  width: 13px;
  height: 13px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #f2b544;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.weather-expand {
  position: absolute;
  z-index: 3;
  top: 7px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(28, 36, 45, 0.48);
  color: #ffffff;
  font-size: 17px;
}

.weather-details {
  display: block;
  min-height: 27px;
  padding: 6px 9px;
  overflow: hidden;
  background: rgba(16, 29, 48, 0.96);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.market-panel .panel-head h3,
.panel-head h3 {
  line-height: 1.25;
}

.market-chip {
  white-space: normal;
}

.market-chip.fx {
  width: 230px;
  min-width: 230px;
}

.market-chip em {
  display: grid;
  gap: 2px;
  line-height: 1.2;
  white-space: normal;
}


.product-grouped-list {
  display: grid;
  gap: 16px;
  padding: 14px;
}

.collection-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.collection-summary span {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.collection-summary small {
  color: var(--muted);
  font-weight: 700;
}

.collection-summary strong {
  color: var(--primary);
  font-size: 18px;
}

.dark .collection-summary {
  background: #111a2a;
}

.product-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.product-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #f6f8fb;
  border-bottom: 1px solid var(--line);
}

.product-group-head h4 {
  margin: 0;
  font-size: 15px;
}

.product-group-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.product-group .table-wrap {
  border-radius: 0;
}

.dark .product-group {
  background: var(--panel);
}

.dark .product-group-head {
  background: #182235;
}

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


.market-chip.weather.weather-card:focus-visible {
  outline: 3px solid #7ec8ff;
  outline-offset: 3px;
}

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

.sunat-notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #f0c36a;
  border-radius: 10px;
  background: #fff8df;
  color: #6b4d00;
}

#recordForm fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.sunat-totals {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding: 14px 4px 4px;
  color: var(--muted);
}

.sunat-totals strong { color: var(--text); }

.sunat-tax-result {
  padding: 12px 14px;
  border: 1px solid #9fc2e8;
  border-radius: 10px;
  background: #eef6ff;
}

.sunat-reference-summary {
  border: 1px solid #cad7e8;
  border-radius: 10px;
  background: #f6f9fd;
  padding: 12px;
}

.sunat-reference-grid {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(180px, 1.3fr);
  gap: 7px 12px;
  margin-top: 9px;
}

.sunat-reference-grid span {
  color: var(--muted);
  font-size: 12px;
}

.pdf-product-table {
  min-width: 980px;
}

.pdf-product-table textarea {
  min-height: 72px;
  min-width: 300px;
  resize: vertical;
}

.pdf-product-table input,
.pdf-product-table select,
.pdf-product-table textarea {
  width: 100%;
}

.pdf-product-table td:first-child,
.pdf-product-table th:first-child {
  width: 58px;
  text-align: center;
}

.pdf-product-table td:first-child input {
  width: auto;
}

.sunat-tax-result div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.sunat-tax-result strong { color: #12376c; }
.sunat-tax-result span { text-align: right; }
.sunat-tax-result small { display: block; margin-top: 7px; color: #4c5878; }

.dark .sunat-tax-result {
  border-color: #335d88;
  background: #14273a;
}

.sunat-installments > span {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.sunat-installments table { min-width: 520px; }
.sunat-installments th:first-child,
.sunat-installments td:first-child { width: 64px; text-align: center; }
.sunat-installments small.error { color: var(--danger); font-weight: 800; }

.sunat-notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #f0c36a;
  border-radius: 10px;
  background: #fff8df;
  color: #6b4d00;
}

#recordForm fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.sunat-totals {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding: 14px 4px 4px;
  color: var(--muted);
}

.sunat-totals strong { color: var(--text); }

@media (max-width: 900px) {
  body { overflow-x: hidden; }
  .app { display: block; min-width: 0; }
  .main { width: 100%; min-width: 0; }
  .sidebar {
    width: min(82vw, 300px);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 8px 0 24px rgba(15, 23, 42, .18);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 29;
    border: 0;
    background: rgba(15, 23, 42, .45);
  }
  .app.nav-open .nav-backdrop { display: block; }
  .mobile-menu-btn {
    display: inline-grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: white;
    color: var(--brand);
    font-size: 22px;
    cursor: pointer;
  }
  .topbar { padding: 10px 12px; }
  .top-left { min-width: 0; width: 100%; }
  .top-left h2 { overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
  .content { width: 100%; min-width: 0; padding: 12px; }
  .hero-row { display: grid; grid-template-columns: 1fr; }
  .welcome h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card,
  .panel { min-width: 0; }
  .table-wrap { max-width: calc(100vw - 24px); overscroll-behavior-inline: contain; }
  dialog { width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: 14px 14px 0 0; }
  #recordForm { max-height: calc(94dvh - 56px); overflow-x: hidden; overflow-y: auto; padding: 14px; }
  #recordForm .field,
  #recordForm .form-grid { min-width: 0; }
  #recordForm input,
  #recordForm select,
  #recordForm textarea { max-width: 100%; width: 100%; }
  .sunat-totals { align-items: flex-end; flex-direction: column; gap: 6px; }
  .sunat-totals { align-items: flex-end; flex-direction: column; gap: 6px; }
  .dialog-head { position: sticky; top: 0; z-index: 2; background: white; padding: 11px 14px; }
}

@media (max-width: 520px) {
  .topbar { align-items: center; flex-direction: row; }
  .top-right { flex: 0 0 auto; flex-wrap: nowrap; }
  .top-right .avatar,
  #userDisplay { display: none; }
  #themeBtn { width: auto; }
  .content { padding: 10px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stats .card { min-height: 96px; padding: 11px; }
  .stats .card strong { font-size: 18px; }
  .toolbar .search { min-width: 0; width: 100%; }
  .panel-body { padding: 12px; }
  .help-hero { padding: 20px; }
  .help-shot { aspect-ratio: 16 / 9; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .form-actions button { width: 100%; }
  input,
  select,
  textarea { font-size: 16px; }
  input[type="file"] { overflow: hidden; }
}


/* Acciones compactas y consistentes */
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}
.icon-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 7px;
  line-height: 1;
}
.icon-btn svg,
.linkedin-link svg {
  width: 20px;
  height: 20px;
  display: block;
}
.icon-btn.danger,
.icon-btn.delete-action {
  color: #d92d20;
  border-color: #f1b6b1;
  background: #fff5f4;
}
.icon-btn.pdf-action { color: #c62828; }
.icon-btn.outlook-action { color: #0f6cbd; }
.linkedin-link {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  vertical-align: middle;
}
.avatar-stack {
  position: relative;
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
}
.avatar-stack > .avatar-mini {
  grid-area: 1 / 1;
  object-fit: cover;
}
.contact-avatar-stack {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
}
.contact-avatar-stack > .avatar-mini {
  width: 46px;
  height: 46px;
}
.payment-terms-other {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}
.purchase-code {
  padding: 13px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--soft);
}
.purchase-code label { display: grid; gap: 6px; font-weight: 800; }
.purchase-code small { display: block; color: var(--muted); margin-top: 6px; }
.purchase-history {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 8px;
}
.purchase-history p { margin: 7px 0; color: var(--muted); }

/* Contactos: un registro por línea, adaptable al ancho disponible */
.contact-list {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px;
}
.contact-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.35fr) minmax(150px, 1fr) minmax(120px, .8fr) minmax(125px, .78fr) minmax(210px, 1.25fr) minmax(125px, .72fr) auto;
  grid-template-areas: "primary company role phone email network actions";
  gap: 12px;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.contact-primary { grid-area: primary; }
.contact-company { grid-area: company; }
.contact-role { grid-area: role; }
.contact-phone { grid-area: phone; }
.contact-email { grid-area: email; }
.contact-network { grid-area: network; }
.contact-row-actions { grid-area: actions; }
.contact-primary,
.contact-field,
.contact-field span,
.contact-field strong {
  min-width: 0;
}
.contact-primary .view-link {
  display: inline-flex;
  max-width: 100%;
  text-align: left;
}
.contact-primary .person-cell {
  min-width: 0;
}
.contact-primary .person-cell > span:last-child,
.contact-field span,
.contact-field strong,
.contact-field a {
  overflow-wrap: anywhere;
  word-break: normal;
}
.contact-field {
  display: grid;
  gap: 4px;
  align-content: center;
}
.contact-field small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .025em;
}
.contact-field strong,
.contact-field span {
  font-size: 13px;
}
.contact-network > span {
  display: flex;
  align-items: center;
  gap: 7px;
}
.contact-row-actions {
  justify-self: end;
  white-space: nowrap;
}
.contact-row-actions .actions-cell {
  justify-content: flex-end;
}
.utility-panel .panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
}
.utility-summary {
  margin-bottom: 16px;
}
.utility-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.utility-option {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}
.utility-option strong {
  color: var(--navy);
}
.utility-option p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}
.utility-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}
.data-tool-result {
  min-height: 20px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef5ff;
  color: var(--navy);
  font-weight: 700;
}
@media (max-width: 1180px) {
  .contact-row {
    grid-template-columns: minmax(210px, 1.3fr) minmax(150px, 1fr) minmax(180px, 1.1fr) auto;
    grid-template-areas:
      "primary company role actions"
      "primary phone email network";
  }
}
@media (max-width: 760px) {
  .contact-list { padding: 8px; }
  .contact-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "primary actions"
      "company company"
      "role role"
      "phone phone"
      "email email"
      "network network";
    gap: 10px;
  }
  .contact-row-actions { align-self: start; }
  .contact-field {
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: baseline;
  }
}

/* Menú de cuenta y administración */
.user-menu-wrap { position: relative; }
.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 4px 9px 4px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: inherit;
  cursor: pointer;
}
.user-menu-trigger strong { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-chevron { color: var(--muted); }
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 120;
  width: min(310px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(20, 39, 75, .18);
}
.user-menu[hidden], .user-menu [hidden] { display: none !important; }
.user-menu > button,
.user-menu details button,
.user-menu summary {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.user-menu > button:hover,
.user-menu details button:hover,
.user-menu summary:hover { background: var(--soft); }
.user-menu details button { padding-left: 24px; color: var(--muted); }
.user-menu summary { font-weight: 800; }
.user-menu-separator { height: 1px; margin: 6px 4px; background: var(--line); }
.user-menu .danger-menu-item { color: #c62828; font-weight: 800; }
.settings-form { display: grid; gap: 16px; }
.settings-form fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.settings-form legend { padding: 0 6px; color: var(--navy, #12376c); font-weight: 800; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.settings-grid label,
.admin-user-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.settings-grid .wide { grid-column: span 2; }
.settings-grid input,
.settings-grid select,
.settings-grid textarea,
.admin-user-form input,
.admin-user-form select {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: inherit;
}
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.admin-users-layout { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(420px, 1.6fr); gap: 18px; align-items: start; }
.admin-user-form { display: grid; gap: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.admin-user-form h4 { margin: 0 0 4px; }
.admin-user-form .checkbox-line { display: flex; align-items: center; gap: 8px; }
.admin-user-form .checkbox-line input { width: auto; }
.admin-user-list { display: grid; gap: 8px; }
.admin-user-row { display: grid; grid-template-columns: minmax(210px, 1fr) 125px 100px auto; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; }
.admin-user-row > div { display: grid; gap: 3px; min-width: 0; }
.admin-user-row a { overflow-wrap: anywhere; font-size: 12px; }
.dark .user-menu,
.dark .user-menu-trigger,
.dark .settings-grid input,
.dark .settings-grid select,
.dark .settings-grid textarea,
.dark .admin-user-form input,
.dark .admin-user-form select { background: #172033; color: #edf3ff; }
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-users-layout { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .user-menu-trigger strong { max-width: 115px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .wide { grid-column: auto; }
  .admin-user-row { grid-template-columns: 1fr auto; }
  .admin-user-row > span { grid-column: 1; }
  .admin-user-row > button { grid-column: 2; grid-row: 1 / span 2; }
}

/* Oportunidades: una oportunidad por línea sin quiebres internos */
.collection-opportunities {
  width: 100%;
  min-width: 1080px;
  table-layout: fixed;
}
.collection-opportunities th,
.collection-opportunities td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.collection-opportunities th:nth-child(1), .collection-opportunities td:nth-child(1) { width: 155px; }
.collection-opportunities th:nth-child(2), .collection-opportunities td:nth-child(2) { width: 220px; }
.collection-opportunities th:nth-child(3), .collection-opportunities td:nth-child(3) { width: 190px; }
.collection-opportunities th:nth-child(4), .collection-opportunities td:nth-child(4) { width: 125px; }
.collection-opportunities th:nth-child(5), .collection-opportunities td:nth-child(5) { width: 140px; }
.collection-opportunities th:nth-child(6), .collection-opportunities td:nth-child(6) { width: 110px; }
.collection-opportunities th:last-child, .collection-opportunities td:last-child {
  width: 150px;
  overflow: visible;
  text-overflow: clip;
}



/* Empresas: una empresa por línea; Ciudad se mantiene en la ficha, no en el listado. */
.collection-companies {
  width: 100%;
  min-width: 940px;
  table-layout: fixed;
}
.collection-companies th,
.collection-companies td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.collection-companies th:nth-child(1), .collection-companies td:nth-child(1) { width: 230px; }
.collection-companies th:nth-child(2), .collection-companies td:nth-child(2) { width: 150px; }
.collection-companies th:nth-child(3), .collection-companies td:nth-child(3) { width: 190px; }
.collection-companies th:nth-child(4), .collection-companies td:nth-child(4) { width: 115px; }
.collection-companies th:nth-child(5), .collection-companies td:nth-child(5) { width: 160px; }
.collection-companies th:last-child, .collection-companies td:last-child {
  width: 150px;
  overflow: visible;
  text-overflow: clip;
}

.collection-opportunities td:nth-child(1),
.collection-opportunities td:nth-child(1) .link-button {
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}


/* Listados compactos v64 */
.collection-companies {
  min-width: 1080px;
  table-layout: auto;
}
.collection-companies th:nth-child(1),
.collection-companies td:nth-child(1) {
  width: auto;
  min-width: 280px;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}
.collection-companies td:nth-child(1) .link-button {
  white-space: nowrap;
}

.collection-opportunities {
  min-width: 1160px;
}
.collection-opportunities th:nth-child(1),
.collection-opportunities td:nth-child(1) {
  width: 165px;
  white-space: nowrap;
}
.collection-opportunities td:nth-child(1) .link-button {
  display: inline-block;
  max-width: none;
  font-size: 11px;
  white-space: nowrap;
}
.collection-opportunities .row-actions {
  flex-wrap: nowrap;
  gap: 3px;
  min-width: max-content;
}
.collection-opportunities .icon-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
}
.collection-opportunities th:last-child,
.collection-opportunities td:last-child {
  width: 210px;
  min-width: 210px;
  white-space: nowrap;
  overflow: visible;
}


/* Opportunity project economic balance v71 */
.project-balance { padding: 14px; }
.project-balance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 12px;
}
.project-balance-card {
  border: 1px solid #d9e2ef;
  border-radius: 10px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 5px;
}
.project-balance-card.contract { border-left: 4px solid #315ea8; }
.project-balance-card.income { border-left: 4px solid #17835b; }
.project-balance-card.expense { border-left: 4px solid #c05b36; }
.project-balance-card span,
.project-balance-card small { color: #64748b; }
.project-balance-card span { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.project-balance-card strong { color: #10213a; font-size: 19px; }
.project-balance-card strong.positive { color: #087550; }
.project-balance-card strong.negative { color: #b42318; }
.project-balance-warning {
  margin-top: 12px;
  border: 1px solid #f0c86e;
  border-radius: 8px;
  background: #fff8e6;
  color: #754c00;
  padding: 10px 12px;
}
.project-balance-rate { margin: 10px 0 0; color: #5f6f86; font-size: 12px; }
.project-balance-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.project-balance-details > section {
  min-width: 0;
  border: 1px solid #e1e7f0;
  border-radius: 9px;
  overflow: hidden;
}
.project-balance-details h4 { margin: 0; padding: 11px 13px; background: #f5f8fc; color: #173a70; }
.project-balance-table { min-width: 560px; }
.balance-missing { color: #a15c00; font-weight: 700; }
@media (max-width: 980px) {
  .project-balance-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .project-balance-details { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .project-balance-grid { grid-template-columns: 1fr; }
}


/* Invoice PDF accounting v75 */
.project-balance-card.invoice { border-left: 4px solid #1261a0; }
.project-balance-card.pending { border-left: 4px solid #d49a20; }
.invoice-read-status { display: block; margin-top: 7px; color: #315b91; font-weight: 700; }


.purchase-opportunity-picker {
  display: grid;
  gap: 6px;
}

.purchase-opportunity-picker input[type="search"] {
  width: 100%;
}






.po-catalog-cell {
  position: relative;
  min-width: 320px;
  overflow: visible;
}

.po-catalog-cell .po-catalog-combobox {
  width: 100%;
  min-height: 38px;
  border: 1px solid #9fb2cf;
  background: #fff;
}

.po-catalog-cell .po-catalog {
  display: none;
}

.po-catalog-results {
  position: absolute;
  z-index: 1500;
  top: calc(100% - 2px);
  left: 8px;
  right: 8px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #9fb2cf;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 45, 85, 0.2);
}

.po-catalog-result {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid #e4eaf3;
  border-radius: 0;
  background: #fff;
  color: #17243b;
  text-align: left;
  cursor: pointer;
}

.po-catalog-result:hover,
.po-catalog-result:focus {
  background: #eaf2ff;
  outline: none;
}

.po-catalog-result-empty {
  padding: 12px;
  color: #60708a;
}


.project-balance-table th.number-cell,
.project-balance-table td.number-cell {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
