:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #edf2f0;
  --ink: #18221f;
  --muted: #64716d;
  --line: #dbe3df;
  --green: #157f63;
  --blue: #2766c2;
  --red: #ba3b46;
  --amber: #a86f00;
  --shadow: 0 18px 45px rgba(23, 34, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.45rem, 2.6vw, 2.1rem);
}

h2 {
  font-size: 1.02rem;
}

.user-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.user-strip a,
button {
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 32px 40px;
}

.filters {
  align-self: start;
  position: sticky;
  top: 108px;
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.company-filter {
  display: grid;
  gap: 8px;
  padding-bottom: 4px;
}

.operation-filter {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.operation-filter legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.company-options {
  display: grid;
  gap: 7px;
  max-height: 190px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.company-option {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
}

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

.quick-dates button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 7px 9px;
  font-size: 0.78rem;
}

.quick-dates button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.content {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab-button {
  min-height: 36px;
  background: transparent;
  color: var(--ink);
  padding: 8px 12px;
}

.tab-button.active {
  background: var(--ink);
  color: white;
}

.view-stack {
  display: grid;
  gap: 22px;
}

.view-stack[hidden] {
  display: none;
}

.status {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.status.error {
  color: var(--red);
  font-weight: 750;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.kpis article,
.panel,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpis article {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 16px;
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-button {
  min-height: 28px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 5px 8px;
  font-size: 0.72rem;
  line-height: 1;
}

.danger-link {
  min-height: 28px;
  border: 1px solid rgba(186, 59, 70, 0.35);
  background: rgba(186, 59, 70, 0.08);
  color: var(--red);
  padding: 5px 8px;
  font-size: 0.72rem;
  line-height: 1;
}

.danger-link:hover {
  background: rgba(186, 59, 70, 0.14);
}

.collapse-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 7px 10px;
  font-size: 0.78rem;
  line-height: 1;
}

.collapse-icon {
  display: inline-block;
  font-size: 0.9rem;
  transition: transform 0.16s ease;
}

.collapse-button.open .collapse-icon {
  transform: rotate(180deg);
}

.collapsible-detail {
  margin-top: 12px;
}

.row-detail-button {
  min-height: 30px;
  padding: 6px 9px;
}

.pl-account-detail-row > td,
.balance-account-detail-row > td {
  background: var(--surface-2);
  padding: 12px;
}

.inline-detail {
  display: grid;
  gap: 10px;
}

.inline-detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.inline-detail-head strong {
  color: var(--ink);
}

.journal-detail-row > td {
  padding: 0;
  background: var(--surface-2);
}

.journal-detail-row .inline-detail {
  margin: 8px 12px 14px;
  border: 1px solid var(--line);
  background: white;
}

.kpis.compact {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.investor-summary {
  padding: 18px;
}

.investor-summary .kpis article {
  box-shadow: none;
}

.kpis span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.kpis strong {
  font-size: 1.45rem;
  letter-spacing: 0;
}

.kpis small,
.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 22px;
}

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

.bank-controls,
.upload-form,
.invoice-controls {
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.invoice-controls {
  grid-template-columns: 180px minmax(220px, 360px) minmax(260px, 1fr);
}

.investor-interest-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 180px)) auto;
  gap: 14px;
  align-items: end;
}

.investor-interest-controls button {
  min-height: 42px;
  white-space: nowrap;
}

.investor-interest-controls button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.sort-button {
  min-height: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font: inherit;
  text-align: left;
  text-transform: uppercase;
}

.filter-row th {
  padding-top: 6px;
}

.column-filter {
  width: 100%;
  min-width: 110px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 6px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: none;
}

.sortable-header {
  position: relative;
  padding-right: 24px;
  cursor: pointer;
  user-select: none;
}

.sortable-header::after {
  position: absolute;
  right: 8px;
  content: "↕";
  color: var(--muted);
  font-size: .75rem;
}

.sortable-header[aria-sort="ascending"]::after {
  content: "↑";
  color: var(--ink);
}

.sortable-header[aria-sort="descending"]::after {
  content: "↓";
  color: var(--ink);
}

.sortable-header:focus-visible {
  outline: 2px solid #2766c2;
  outline-offset: -2px;
}

.column-filter::placeholder {
  color: var(--muted);
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: var(--surface-2);
}

.clickable-row.selected td {
  background: rgba(21, 127, 99, 0.12);
}

.upload-form {
  grid-template-columns: minmax(260px, 1fr) auto;
}

.drop-zone {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 86px;
  align-content: center;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 16px;
  cursor: pointer;
}

.drop-zone strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.drop-zone span {
  font-size: 0.82rem;
  font-weight: 700;
}

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

.drop-zone.dragging {
  border-color: var(--green);
  background: #dff3ec;
}

.bank-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.profit-loss-summary {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.investor-interest-summary {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.bank-summary article {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

.bank-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.bank-summary strong {
  font-size: 1.12rem;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head input {
  max-width: 260px;
}

.chart-box {
  position: relative;
  height: 320px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

td.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-totals td {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--surface-2);
  border-top: 2px solid var(--line);
  border-bottom: 0;
  color: var(--ink);
  font-weight: 850;
}

.table-totals .total-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.76rem;
}

.reconcile-results article {
  min-width: 0;
}

.reconcile-results h2 {
  margin-bottom: 8px;
}

.reconcile-table-wrap {
  max-width: 100%;
}

.reconcile-table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
  font-size: 0.82rem;
}

.reconcile-table th,
.reconcile-table td {
  padding: 7px 8px;
  vertical-align: top;
}

.reconcile-table .date-col,
.reconcile-table .date-cell {
  width: 1%;
  min-width: 94px;
}

.reconcile-table .entry-col,
.reconcile-table .entry-cell {
  width: 1%;
  min-width: 70px;
}

.reconcile-table .amount-col,
.reconcile-table .amount-cell {
  width: 1%;
  min-width: 112px;
}

.reconcile-table .source-col,
.reconcile-table .source-cell {
  width: 180px;
  max-width: 220px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.reconcile-table .concept-col,
.reconcile-table .concept-cell {
  white-space: normal;
  min-width: 240px;
  max-width: 520px;
  overflow-wrap: anywhere;
}

.reconcile-table .badge {
  margin-left: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.ok {
  background: #dff3ec;
  color: #07533f;
}

.badge.warn {
  background: #fff2d2;
  color: #744900;
}

.badge.bad {
  background: #fae1e4;
  color: #822633;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(21, 127, 99, 0.12), rgba(39, 102, 194, 0.1)),
    var(--bg);
}

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

.login-panel {
  padding: 30px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.password-field {
  position: relative;
  display: block;
}

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

.password-toggle {
  position: absolute;
  top: 50%;
  right: 5px;
  width: 36px;
  min-height: 34px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: var(--surface-2);
  color: var(--ink);
}

.alert {
  margin-top: 18px;
  padding: 11px 12px;
  border-radius: 6px;
  background: #fae1e4;
  color: var(--red);
  font-weight: 750;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 34, 31, 0.42);
}

.modal-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  width: min(1760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  margin: 12px auto;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(23, 34, 31, 0.22);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-head .muted {
  margin: 5px 0 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.35rem;
}

.detail-table-wrap {
  max-height: min(74vh, 820px);
}

.detail-table-wrap table {
  min-width: max-content;
}

.section-row td {
  background: var(--ink);
  color: white;
  font-weight: 850;
}

.family-row td {
  background: var(--surface-2);
  font-weight: 800;
}

.review-row td {
  color: var(--muted);
}

.modal-open {
  overflow: hidden;
}

.review-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: .82rem;
  font-weight: 800;
}

.review-status.critical { color: #9c2631; background: #fbeaec; }
.review-status.warning { color: #805500; background: #fff3d8; }
.review-status.ok { color: #116b53; background: #e5f4ef; }

.review-checks {
  display: grid;
  gap: 14px;
}

.review-check {
  border-left: 4px solid #87938f;
}

.review-check.critical { border-left-color: #ba3b46; }
.review-check.warning { border-left-color: #c48918; }
.review-check.info { border-left-color: #2766c2; }

.review-check-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.review-check-head h3 { margin: 0 0 5px; }
.review-check-head p { margin: 0; color: var(--muted); }

.review-check-actions {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.review-check-actions strong { font-size: 1.35rem; }
.review-check-actions > span:not(.badge) { color: var(--muted); font-weight: 700; }
.review-check-detail { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }

.partners-narrative {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.partners-message {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border-left: 4px solid #658177;
  background: var(--surface-2);
}

.partners-message span,
.partners-summary small { color: var(--muted); line-height: 1.4; }
.partners-message.positive { border-left-color: #157f63; }
.partners-message.negative { border-left-color: #ba3b46; }
.partners-message.warning { border-left-color: #c48918; }
.partners-summary article { align-content: start; }
.partners-summary small { display: block; margin-top: 5px; font-size: .78rem; }
.positive-value { color: #116b53; }
.negative-value { color: #a92f3a; }
.partners-project-chart { min-height: 390px; }

.connections-page { --accent: #7c3aed; --accent-soft: #f0eaff; --accent-strong: #5d29c7; }
.connections-page.theme-blue { --accent: #007aff; --accent-soft: #e7f2ff; --accent-strong: #005ecb; }
.connections-page.theme-mint { --accent: #0b9f7a; --accent-soft: #e2f7ef; --accent-strong: #08795d; }
.connections-page.theme-coral { --accent: #ef476f; --accent-soft: #ffebf0; --accent-strong: #c83256; }
.connections-page.theme-graphite { --accent: #475569; --accent-soft: #eef1f4; --accent-strong: #25313f; }
.connections-page.theme-amber { --accent: #d97706; --accent-soft: #fff3df; --accent-strong: #b45309; }
.connections-page .eyebrow { color: var(--accent-strong); }

.connections-layout {
  min-height: calc(100vh - 94px);
  display: grid;
  place-items: start center;
  padding: 52px 24px;
  background: radial-gradient(circle at top, var(--accent-soft), var(--bg) 48%);
}

.connections-content { width: min(680px, 100%); }
.connections-panel { border-radius: 24px; border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); box-shadow: 0 22px 54px color-mix(in srgb, var(--accent) 12%, transparent); }

.connection-list {
  display: grid;
  gap: 12px;
  margin: 20px 0 8px;
}

.connection-card {
  --accent: #7c3aed;
  --accent-soft: #f0eaff;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 16px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.connection-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.connection-card p { margin: 5px 0 0; }

.theme-dot { width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: #7c3aed; display: inline-block; }
.connection-card.theme-violet { --accent: #7c3aed; --accent-soft: #f0eaff; --accent-strong: #5d29c7; }
.connection-card.theme-blue { --accent: #007aff; --accent-soft: #e7f2ff; --accent-strong: #005ecb; }
.connection-card.theme-mint { --accent: #0b9f7a; --accent-soft: #e2f7ef; --accent-strong: #08795d; }
.connection-card.theme-coral { --accent: #ef476f; --accent-soft: #ffebf0; --accent-strong: #c83256; }
.connection-card.theme-graphite { --accent: #475569; --accent-soft: #eef1f4; --accent-strong: #25313f; }
.connection-card.theme-amber { --accent: #d97706; --accent-soft: #fff3df; --accent-strong: #b45309; }
.connection-card .theme-dot { background: var(--accent); }
.theme-form { display: flex; align-items: end; gap: 8px; }
.theme-form select { min-height: 34px; padding: 4px 8px; border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.theme-label { gap: 3px; font-size: .7rem; }

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

.connection-actions form { margin: 0; }
.connection-actions button { min-height: 34px; padding: 7px 10px; border-radius: 9px; background: var(--accent); }
.connection-actions .button-secondary { background: var(--accent-soft); color: var(--accent-strong); }
.connection-delete { width: 34px; padding: 0 !important; background: transparent !important; color: var(--red) !important; border: 1px solid color-mix(in srgb, var(--red) 38%, transparent) !important; font-size: 1.18rem; }

.connection-add-panel { margin-top: 14px; border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line)); border-radius: 16px; background: var(--surface); overflow: hidden; }
.connection-add-panel summary { cursor: pointer; padding: 14px 16px; color: var(--accent-strong); font-weight: 800; list-style: none; }
.connection-add-panel summary::-webkit-details-marker { display: none; }
.connection-add-content { padding: 0 16px 16px; border-top: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); }

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

.connection-form label {
  display: grid;
  gap: 7px;
}

.connection-form input { width: 100%; }

.connection-form button,
.connection-form .form-note { grid-column: 1 / -1; }

.form-note { margin: 0; }

@media (max-width: 1180px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar,
  .layout {
    padding-left: 18px;
    padding-right: 18px;
  }

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

  .filters {
    position: static;
  }

  .grid.two,
  .kpis {
    grid-template-columns: 1fr;
  }

  .bank-controls,
  .upload-form,
  .invoice-controls,
  .investor-interest-controls,
  .bank-summary {
    grid-template-columns: 1fr;
  }

  .partners-narrative {
    grid-template-columns: 1fr;
  }

  .review-check-head {
    align-items: stretch;
    flex-direction: column;
  }

  .review-check-actions {
    grid-template-columns: auto auto 1fr;
  }

  .kpis.compact {
    grid-template-columns: 1fr;
  }

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

  .panel-head input {
    max-width: none;
  }

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

  .connections-layout { padding: 28px 16px; }

  .connection-form { grid-template-columns: 1fr; }
}

/* Acceso y gestión de empresas: misma experiencia táctil que el Dashboard. */
@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }
  .topbar {
    position: static;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }
  .topbar h1 { font-size: 1.42rem; }
  .user-strip { justify-content: space-between; flex-wrap: wrap; gap: 8px; }
  .user-strip > span:not(.company-badge) { display: none; }
  .company-badge { max-width: calc(100vw - 188px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-company-button,
  .user-strip a { min-height: 40px; padding: 8px 11px; }

  .login-body { display: block; padding: max(28px, env(safe-area-inset-top)) 16px 24px; }
  .login-shell { width: 100%; }
  .login-panel { padding: 22px 18px; border-radius: 20px; }
  .login-panel h1 { font-size: 1.75rem; }
  .login-form { gap: 14px; }
  .login-form input,
  .login-form button { min-height: 46px; }

  .connections-layout { min-height: calc(100dvh - 1px); padding: 20px 12px 28px; }
  .connections-content { width: 100%; }
  .connections-panel { border-radius: 18px; padding: 16px; }
  .connection-list { margin-top: 14px; }
  .connection-card { padding: 13px; gap: 12px; }
  .connection-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .connection-actions form { min-width: 0; }
  .connection-actions button { width: 100%; min-height: 42px; }
  .connection-actions .theme-form { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .theme-form select { min-height: 42px; }
  .connection-delete { grid-column: 2; }
  .connection-add-panel summary { min-height: 48px; display: flex; align-items: center; }
  .connection-add-content { padding: 0 14px 14px; }
  .connection-form { gap: 13px; }
  .connection-form input,
  .connection-form select,
  .connection-form button { min-height: 44px; }
  .form-note { line-height: 1.45; }
}

@media (max-width: 380px) {
  .topbar-company-button,
  .user-strip a { font-size: .72rem; padding: 8px; }
  .company-badge { max-width: calc(100vw - 170px); }
  .connection-actions { grid-template-columns: 1fr; }
  .connection-delete { grid-column: auto; }
}

/* Perfil y acabados táctiles comunes a acceso, empresas y administración. */
.profile-layout { min-height: calc(100dvh - 98px); }
.profile-content { width: min(720px, 100%); }
.profile-panel { display: grid; gap: 2px; }
.profile-reset-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 42px;
  margin-top: 4px;
  padding: 9px 13px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: .86rem;
  font-weight: 800;
  text-decoration: none;
}
.temporary-password {
  display: grid;
  gap: 7px;
  margin: 14px 0 0;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: .8rem;
  font-weight: 800;
}
.temporary-password code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 1.05rem;
  letter-spacing: .08em;
  user-select: all;
}

@media (pointer: coarse) {
  button,
  .user-strip a,
  .profile-reset-link { min-height: 44px; }
  input,
  select { min-height: 44px; }
}

@media (max-width: 700px) {
  body.connections-page { min-height: 100dvh; }
  .topbar { padding-top: max(14px, env(safe-area-inset-top)); }
  .topbar { flex-direction: column; justify-content: flex-start; }
  .topbar > div:first-child { width: 100%; }
  .user-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; justify-content: stretch; }
  .user-strip > * { min-width: 0; }
  .user-strip a { display: inline-flex; align-items: center; justify-content: center; }
  .user-strip a,
  .topbar-company-button { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-strip .profile-link { background: var(--accent-soft); color: var(--accent-strong); }

  input,
  select,
  textarea { font-size: 16px; }
  .connections-layout { padding-bottom: max(28px, env(safe-area-inset-bottom)); }
  .connections-panel { min-width: 0; }
  .connections-panel .table-wrap { margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
  .connections-panel table { min-width: 660px; }
  .connections-panel .connection-form { grid-template-columns: 1fr; }
  .connections-panel .connection-form button { width: 100%; min-height: 46px; }
  .profile-layout { min-height: calc(100dvh - 1px); }
  .profile-content { width: 100%; }
  .profile-reset-link { width: 100%; min-height: 46px; text-align: center; }
}
