:root {
  --bg: #f5f8f7;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #687385;
  --line: #dfe5ec;
  --teal-950: #022c25;
  --teal-900: #064237;
  --teal-800: #075646;
  --teal-700: #047857;
  --teal-600: #059669;
  --blue-600: #2563eb;
  --green-600: #16a34a;
  --amber-500: #d99b18;
  --red-600: #dc2626;
  --violet-600: #7c3aed;
  --soft-teal: #e6f5f3;
  --soft-blue: #eaf1ff;
  --soft-green: #e9f8ef;
  --soft-amber: #fff5da;
  --soft-red: #fdecec;
  --shadow: 0 16px 38px rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; }

html {
  height: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
}

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

button { cursor: pointer; }

svg { width: 20px; height: 20px; flex: 0 0 auto; }

.app-root {
  height: 100vh;
  min-height: 100vh;
  min-width: 0;
}

.app-shell {
  height: 100vh;
  min-height: 100vh;
  min-width: 0;
  display: grid;
  grid-template-columns: clamp(238px, 21vw, 278px) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(circle at 30% 12%, rgba(16, 185, 129, 0.32), transparent 28%),
    radial-gradient(circle at 80% 82%, rgba(20, 184, 166, 0.22), transparent 30%),
    linear-gradient(155deg, #053f34 0%, #012f29 48%, #001d1a 100%);
  color: #fff;
  z-index: 20;
  box-shadow: 18px 0 42px rgba(1, 45, 38, 0.24);
  overflow: hidden;
}

.brand {
  min-height: 104px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 20px 16px 18px;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-icon {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, #0f8a68, #27c79a);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22);
}

.logo-mark {
  overflow: hidden;
  background: #fff;
  padding: 4px;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong,
.brand small { display: block; }

.brand strong { font-size: 17px; line-height: 1.12; }
.brand small { margin-top: 3px; color: rgba(255,255,255,0.72); }

.brand em {
  display: inline-flex;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #d7fff4;
  background: rgba(255,255,255,0.10);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.brand-button:hover {
  background: rgba(255,255,255,0.06);
}

.brand-button:focus-visible {
  outline: 3px solid rgba(16, 185, 129, 0.42);
  outline-offset: -3px;
}

.nav-list {
  padding: 18px 14px;
  overflow-y: auto;
}

.nav-item {
  width: 100%;
  min-height: 48px;
  margin-bottom: 6px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: rgba(255,255,255,0.86);
  background: transparent;
  text-align: left;
  font-weight: 750;
}

.nav-item:hover { background: rgba(255,255,255,0.10); }

.nav-item.active {
  color: #fff;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.12), transparent 38%),
    linear-gradient(135deg, rgba(16, 185, 129, 0.88), rgba(20, 184, 166, 0.48));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22), 0 12px 24px rgba(0,0,0,0.12);
}

.source-box {
  margin: 14px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 12px;
  background: rgba(255,255,255,0.10);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.source-box small,
.source-box strong,
.source-box span { display: block; }
.source-box small { color: rgba(255,255,255,0.64); }
.source-box strong { margin-top: 4px; }
.source-box span { margin-top: 5px; color: rgba(255,255,255,0.72); font-size: 13px; }

.content-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
  border-radius: 26px 0 0 0;
  overflow: hidden;
  box-shadow: -8px 0 34px rgba(15, 23, 42, 0.08);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 68px;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) minmax(240px, 420px) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(16px);
}

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar-title span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.mobile-menu { display: none; }

.global-search {
  position: relative;
  min-width: 0;
}

.global-search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.global-search input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px 0 42px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

.global-search input:focus,
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--teal-700);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.notification-btn {
  position: relative;
  width: 42px;
  height: 42px;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--ink);
  background: transparent;
}

.notification-btn:hover { background: #eef5f2; }

.notification-btn i {
  position: absolute;
  right: 8px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--teal-600);
  box-shadow: 0 0 0 3px #fff;
}

.profile-button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  color: var(--ink);
  background: #fff;
}

.profile-button:hover { background: #eef5f2; }

.profile-button svg { width: 16px; height: 16px; }

.profile-button-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

@media (max-width: 1440px) {
  .topbar {
    grid-template-columns: auto minmax(150px, 1fr) minmax(220px, 360px) auto;
    padding-right: 16px;
    padding-left: 16px;
  }

  .topbar-actions .secondary-btn span,
  .profile-button-name {
    display: none;
  }

  .profile-button {
    padding-right: 4px;
  }

  .primary-btn {
    padding: 0 14px;
  }
}

.profile-photo {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, var(--teal-900), var(--teal-600));
  box-shadow: 0 0 0 3px #fff, 0 8px 18px rgba(15, 23, 42, 0.18);
}

.profile-photo.small {
  width: 40px;
  height: 40px;
}

.profile-photo.large {
  width: 108px;
  height: 108px;
}

.profile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-screen {
  height: 100vh;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.20), transparent 32%),
    linear-gradient(145deg, #f8fbfa 0%, #eef7f4 55%, #ffffff 100%);
}

.login-card {
  width: min(1040px, 100%);
  min-height: min(640px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  border: 1px solid rgba(6, 66, 55, 0.10);
  border-radius: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 28px 80px rgba(2, 44, 37, 0.16);
}

.login-logo {
  display: grid;
  place-items: center;
  padding: 42px;
  background: linear-gradient(160deg, #ffffff, #f0faf7);
}

.login-logo img {
  width: min(360px, 84%);
  height: auto;
}

.login-form {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 48px;
  min-width: 0;
  overflow: auto;
  background: #fff;
}

.login-form h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.login-form p {
  margin: -6px 0 8px;
  color: var(--muted);
}

.login-form label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.login-submit { width: 100%; min-height: 48px; }
.login-register-shortcut {
  width: 100%;
  min-height: 46px;
}
.login-error { min-height: 20px; color: var(--red-600); font-weight: 850; }
.login-error.success { color: var(--green-700); }
.login-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}
.login-links button {
  border: 0;
  background: transparent;
  color: var(--green-700);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  padding: 4px 0;
  text-align: left;
}
.login-links button:hover { text-decoration: underline; }

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-btn,
.icon-btn,
.link-btn {
  border-radius: 8px;
  min-height: 42px;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-btn {
  padding: 0 16px;
  color: #fff;
  background: var(--teal-700);
}

.primary-btn:hover { background: var(--teal-600); }

.secondary-btn {
  padding: 0 14px;
  color: var(--teal-900);
  border: 1px solid var(--line);
  background: #fff;
}

.secondary-btn:hover { border-color: var(--teal-700); background: var(--soft-teal); }

.danger-btn {
  padding: 0 14px;
  color: #fff;
  background: var(--red-600);
}

.ghost-btn {
  padding: 0 10px;
  color: var(--teal-900);
  background: transparent;
}

.ghost-btn:hover { background: var(--soft-teal); }

.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

.icon-btn:hover { background: #eef3f6; }
.icon-btn.small { width: 34px; height: 34px; min-height: 34px; }
.icon-btn.small svg { width: 18px; height: 18px; }

.link-btn {
  min-height: 0;
  padding: 0;
  color: var(--teal-700);
  background: transparent;
  text-align: left;
  font-weight: 850;
}

.icon-link {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--green-600);
  text-decoration: none;
}

.icon-link:hover { background: var(--soft-green); }

.phone-cell {
  min-width: 210px;
  display: grid;
  gap: 6px;
}

.phone-cell strong {
  display: block;
  color: var(--ink);
  font-weight: 850;
}

.phone-number-link {
  width: fit-content;
  color: var(--teal-700);
  text-decoration: none;
  font-weight: 850;
}

.phone-number-link:hover {
  text-decoration: underline;
}

.phone-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.25;
}

.phone-line span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.phone-number-empty {
  color: var(--muted);
}

.phone-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.phone-actions.compact {
  margin-top: 8px;
}

.phone-action {
  min-height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 9px;
  color: var(--teal-900);
  background: var(--soft-teal);
  text-decoration: none;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.phone-action svg {
  width: 16px;
  height: 16px;
}

.phone-action.call {
  color: #1d4ed8;
  background: var(--soft-blue);
}

.phone-action.whatsapp {
  color: #0f6b32;
  background: var(--soft-green);
}

.phone-action.map {
  color: #7c2d12;
  background: #ffedd5;
}

.phone-action:hover {
  filter: brightness(0.97);
}

.phone-action {
  border: 0;
  cursor: pointer;
}

.phone-action.photo {
  color: #6d28d9;
  background: #f1ecff;
}

.phone-action.gallery {
  color: #075985;
  background: #e0f2fe;
}

.phone-action.document {
  color: #92400e;
  background: #fef3c7;
}

.gallery-card {
  width: min(1180px, 100%);
  grid-template-rows: auto minmax(0, 1fr);
}

.gallery-body {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background: #f8fafc;
}

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.gallery-grid {
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}

.gallery-thumb a {
  aspect-ratio: 1 / 1;
}

.gallery-empty {
  min-height: 220px;
}

.photo-section {
  grid-column: span 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.photo-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.photo-section-head strong,
.photo-section-head span {
  display: block;
}

.photo-section-head strong {
  color: var(--ink);
  font-size: 16px;
}

.photo-section-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 10px;
}

.photo-thumb {
  position: relative;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.photo-thumb a {
  display: block;
  aspect-ratio: 4 / 3;
  background: #e5eaf0;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.photo-thumb figcaption {
  min-height: 52px;
  display: grid;
  gap: 2px;
  padding: 8px 8px 4px;
}

.photo-tools {
  display: flex;
  gap: 6px;
  padding: 0 8px 8px;
}

.photo-tools .icon-mini {
  width: 32px;
  height: 32px;
}

.photo-thumb figcaption span,
.photo-thumb figcaption small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-thumb figcaption span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.photo-thumb figcaption small {
  color: var(--muted);
  font-size: 11px;
}

.photo-delete,
.photo-share {
  position: absolute;
  top: 6px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
}

.photo-delete {
  right: 6px;
  background: rgba(220, 38, 38, 0.92);
}

.photo-share {
  left: 6px;
  background: rgba(15, 118, 110, 0.92);
}

.photo-delete svg,
.photo-share svg {
  width: 16px;
  height: 16px;
}

.photo-empty {
  min-height: 72px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 14px;
  color: var(--muted);
  text-align: center;
  background: #fff;
}

.document-section {
  background: #fffaf0;
}

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

.document-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.document-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #92400e;
  background: #fef3c7;
}

.document-icon svg {
  width: 21px;
  height: 21px;
}

.document-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.document-info strong,
.document-info span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-info strong {
  color: var(--ink);
  font-size: 13px;
}

.document-info span {
  color: var(--muted);
  font-size: 12px;
}

.document-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.icon-mini {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--teal-900);
  background: #fff;
  text-decoration: none;
}

.icon-mini svg {
  width: 16px;
  height: 16px;
}

.document-open-btn {
  width: auto;
  min-width: 78px;
  grid-auto-flow: column;
  gap: 6px;
  padding: 0 10px;
  font-weight: 800;
}

.document-open-btn span {
  font-size: 12px;
}

.whatsapp-mini {
  color: #0f6b32;
  background: var(--soft-green);
}

.mail-mini {
  color: #075985;
  background: #e0f2fe;
}

.danger-mini {
  color: #b91c1c;
  background: #fee2e2;
}

@media (max-width: 720px) {
  .document-item {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .document-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

.main-view {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  overflow: auto;
  padding: 18px;
  background: #f7faf9;
}

.metric-grid,
.dashboard-grid,
.report-grid,
.settings-grid,
.finance-row {
  display: grid;
  gap: 14px;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 14px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(23, 32, 51, 0.05);
}

.metric-card {
  min-height: 118px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 9px;
}

.metric-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.metric-card p {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.metric-card small { color: var(--muted); }
.metric-card.success { background: linear-gradient(180deg, #fff, var(--soft-green)); }
.metric-card.progress { background: linear-gradient(180deg, #fff, var(--soft-blue)); }
.metric-card.warning { background: linear-gradient(180deg, #fff, var(--soft-amber)); }
.metric-card.danger { background: linear-gradient(180deg, #fff, var(--soft-red)); }
.metric-card.money { background: linear-gradient(180deg, #fff, #f1ecff); }

.dashboard-grid,
.report-grid,
.settings-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-12 { grid-column: span 12; }

.panel { padding: 16px; }

.panel-head {
  min-height: 42px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-bar label,
.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.clear-filters { margin-left: auto; }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

.password-field { min-width: 0; }

.password-control {
  position: relative;
  display: block;
  min-width: 0;
}

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

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle.is-visible {
  color: var(--green-700);
  background: #eef8f4;
}

.select { min-width: 170px; }

.textarea {
  min-height: 88px;
  padding-top: 10px;
  resize: vertical;
}

.table-panel { padding: 12px; }

.table-wrap {
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  background: #fff;
}

.data-table th,
.data-table td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  text-transform: uppercase;
}

.data-table td { font-size: 14px; }
.data-table td small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.35; max-width: 260px; }
.data-table tr:hover td { background: #fbfdfd; }

.row-actions {
  min-width: 78px;
  white-space: nowrap;
}

@media (min-width: 721px) and (max-width: 1400px) {
  .table-panel {
    padding: 10px;
  }

  .data-table {
    min-width: 0;
    table-layout: fixed;
  }

  .data-table th,
  .data-table td {
    padding: 9px 7px;
    font-size: 13px;
  }

  .data-table th:nth-child(1),
  .data-table td:nth-child(1) {
    width: 84px;
  }

  .data-table th:nth-child(2),
  .data-table td:nth-child(2) {
    width: 20%;
  }

  .data-table th:nth-child(3),
  .data-table td:nth-child(3) {
    width: 24%;
  }

  .data-table th:nth-child(4),
  .data-table td:nth-child(4) {
    width: 9%;
  }

  .data-table th:nth-child(6),
  .data-table td:nth-child(6) {
    width: 11%;
  }

  .data-table th:nth-child(7),
  .data-table td:nth-child(7) {
    width: 15%;
  }

  .data-table th:nth-child(9),
  .data-table td:nth-child(9) {
    width: 13%;
  }

  .data-table th:nth-child(12),
  .data-table td:nth-child(12) {
    width: 40px;
  }

  .data-table th:nth-child(5),
  .data-table td:nth-child(5),
  .data-table th:nth-child(8),
  .data-table td:nth-child(8),
  .data-table th:nth-child(10),
  .data-table td:nth-child(10),
  .data-table th:nth-child(11),
  .data-table td:nth-child(11) {
    display: none;
  }

  .data-table td small {
    max-width: 100%;
  }

  .phone-action {
    min-height: 28px;
    padding: 0 6px;
    font-size: 11px;
  }

  .phone-action span {
    max-width: 54px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .phone-actions {
    gap: 5px;
  }

  .row-actions {
    min-width: 0;
  }

  .row-actions .icon-btn.small {
    width: 30px;
    height: 30px;
    min-height: 30px;
  }
}

.empty-cell,
.empty-state,
.empty-drop {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.table-footer {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.1;
  white-space: nowrap;
}

.badge.neutral,
.badge.stage { color: #334155; background: #edf2f7; }
.badge.success { color: #0f6b32; background: var(--soft-green); }
.badge.progress { color: #1d4ed8; background: var(--soft-blue); }
.badge.warning { color: #8a5a00; background: var(--soft-amber); }
.badge.danger { color: #a51515; background: var(--soft-red); }

.bar-chart { display: grid; gap: 11px; }

.bar-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 14px;
}

.bar-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label strong { color: var(--muted); font-size: 13px; }

.bar-track {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #edf2f7;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-700), var(--blue-600));
}

.bar-chart.status .bar-track i { background: linear-gradient(90deg, var(--amber-500), var(--red-600)); }
.bar-chart.channel .bar-track i { background: linear-gradient(90deg, var(--green-600), var(--teal-700)); }
.bar-chart.city .bar-track i { background: linear-gradient(90deg, var(--blue-600), var(--violet-600)); }
.bar-chart.loss .bar-track i { background: linear-gradient(90deg, var(--red-600), var(--amber-500)); }

.action-list { display: grid; gap: 9px; }

.action-item,
.agenda-item,
.lead-card-main {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: #f8fafc;
  text-align: left;
}

.action-item {
  min-height: 68px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
  padding: 10px;
}

.action-item strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-item small { grid-column: 2; color: var(--muted); }

.kanban-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(248px, 1fr);
  gap: 14px;
  overflow-x: auto;
  min-height: calc(100vh - 134px);
  padding-bottom: 12px;
}

.kanban-column {
  min-height: calc(100vh - 176px);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.kanban-column.drag-over {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--teal-700);
}

.kanban-head {
  min-height: 70px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  background: #fff;
  border-radius: 12px 12px 0 0;
}

.kanban-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-head span { color: var(--teal-900); font-weight: 900; }
.kanban-head small { grid-column: 1 / -1; color: var(--muted); }

.kanban-cards {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px 18px 18px;
  overflow-y: auto;
}

.kanban-cards .empty-drop {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
}

.empty-stage-icon {
  width: 82px;
  height: 82px;
  border: 1px solid rgba(4, 120, 87, 0.22);
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--teal-700);
  background: linear-gradient(145deg, #ffffff, #effaf6);
}

.empty-stage-icon svg {
  width: 34px;
  height: 34px;
}

.empty-drop strong {
  color: var(--ink);
  font-size: 16px;
}

.empty-drop small {
  max-width: 220px;
  color: var(--muted);
  line-height: 1.5;
}

.lead-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(23, 32, 51, 0.06);
}

.lead-card-main {
  padding: 0;
  background: transparent;
}

.lead-card-main strong,
.lead-card-main span,
.lead-card small { display: block; }
.lead-card-main strong { color: var(--ink); }
.lead-card-main span,
.lead-card small { margin-top: 4px; color: var(--muted); line-height: 1.35; }

.lead-card-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.agenda-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.agenda-column { min-height: 360px; }
.agenda-column.danger { border-top: 4px solid var(--red-600); }
.agenda-column.progress { border-top: 4px solid var(--blue-600); }
.agenda-column.warning { border-top: 4px solid var(--amber-500); }

.count-pill {
  min-width: 34px;
  min-height: 26px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  color: var(--teal-900);
  background: var(--soft-teal);
  font-weight: 900;
}

.agenda-item {
  min-height: 76px;
  display: grid;
  gap: 4px;
  padding: 11px;
  margin-bottom: 9px;
}

.agenda-item:hover,
.action-item:hover { background: #eef8f6; }
.agenda-item span,
.agenda-item small { color: var(--muted); }

.more-note {
  padding: 12px;
  color: var(--muted);
  text-align: center;
}

.finance-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.definition-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 18px;
  margin: 0;
}

.definition-list dt { color: var(--muted); font-weight: 800; }
.definition-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

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

.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-list span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #edf2f7;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

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

.formula-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.formula-grid strong,
.formula-grid span { display: block; }
.formula-grid span { margin-top: 6px; color: var(--muted); }

.hidden-input { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  width: min(1120px, calc(100vw - 24px));
  max-height: min(840px, calc(100vh - 36px));
  max-height: min(840px, calc(100dvh - 36px));
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.profile-card {
  width: min(720px, 100%);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.profile-editor {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  overflow: auto;
}

.profile-editor-photo {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.profile-editor-fields {
  display: grid;
  align-content: start;
  gap: 14px;
}

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

.modal-head h2 { margin: 0; font-size: 22px; }
.modal-head span { display: block; margin-top: 4px; color: var(--muted); }

.form-grid {
  padding: 18px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.form-section {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 16px 0 2px;
  border-top: 1px solid var(--line);
}

.form-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.form-section-head strong {
  color: var(--ink);
  font-size: 15px;
}

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

.field span { color: var(--muted); }
.field.wide { grid-column: span 3; }
.form-section .field.wide { grid-column: 1 / -1; }

.calculated-strip {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  background: #f8fafc;
}

.calculated-strip > span:not(.badge) {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 800;
}

.modal-actions {
  min-height: 70px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-actions > div {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
}

.toast {
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0 16px;
  border-radius: 8px;
  color: #fff;
  background: #11312f;
  box-shadow: var(--shadow);
  font-weight: 850;
}

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-4,
  .span-5,
  .span-6,
  .span-7 { grid-column: span 12; }
  .agenda-grid { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .content-shell { border-radius: 0; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(86vw, 300px);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .topbar {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "menu title actions"
      "search search search";
  }
  .mobile-menu { grid-area: menu; }
  .topbar-title { grid-area: title; }
  .global-search { grid-area: search; }
  .topbar-actions { grid-area: actions; }
  .topbar-actions .secondary-btn span { display: none; }
  .profile-button-name { display: none; }
  .profile-button { padding-right: 4px; }
  .main-view { padding: 14px; }
  .form-grid,
  .form-section-grid { grid-template-columns: 1fr; }
  .field.wide,
  .form-section,
  .photo-section { grid-column: auto; }
  .formula-grid,
  .finance-row,
  .action-grid { grid-template-columns: 1fr; }
  .login-card {
    grid-template-columns: 1fr;
    width: min(620px, 100%);
    min-height: 0;
    max-height: none;
  }
  .login-logo { padding: 28px 24px 0; }
  .login-logo img { width: min(220px, 68%); }
  .login-form {
    align-content: start;
    padding: 26px 24px 32px;
    overflow: visible;
  }
  .profile-editor { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .filter-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .filter-bar label,
  .filter-bar .select {
    min-width: 0;
  }

  .clear-filters {
    margin-left: 0;
    justify-self: start;
  }

  .table-panel {
    padding: 10px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .data-table {
    background: transparent;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: grid;
    gap: 12px;
  }

  .data-table tr {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .data-table td {
    padding: 0;
    border-bottom: 0;
  }

  .data-table td + td {
    margin-top: 10px;
  }

  .data-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    line-height: 1.2;
    text-transform: uppercase;
  }

  .data-table td[data-label="Cliente"] .link-btn {
    font-size: 16px;
  }

  .phone-cell,
  .phone-actions {
    min-width: 0;
  }

  .phone-actions {
    gap: 7px;
  }

  .phone-action {
    min-height: 38px;
    flex: 1 1 118px;
  }

  .row-actions {
    min-width: 0;
    display: flex;
    gap: 8px;
  }

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

@media (max-width: 620px) {
  .metric-grid { grid-template-columns: 1fr; }
  .topbar-actions .primary-btn span { display: none; }
  .topbar-actions .secondary-btn { display: none; }
  .notification-btn { display: none; }
  .topbar {
    gap: 9px;
    padding: 10px 12px;
  }
  .topbar-title h1 {
    max-width: 100%;
    overflow: hidden;
    font-size: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-title span {
    font-size: 12px;
  }
  .global-search input {
    min-height: 44px;
    font-size: 15px;
  }
  .topbar-actions {
    gap: 6px;
  }
  .topbar-actions .primary-btn,
  .profile-button,
  .mobile-menu {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
  }
  .modal-backdrop { padding: 0; place-items: stretch; }
  .modal-card {
    width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .modal-actions { align-items: stretch; flex-direction: column; }
  .modal-actions > div { width: 100%; }
  .modal-actions button { flex: 1; }
  .login-screen {
    place-items: stretch;
    padding: 10px;
  }
  .login-card {
    width: 100%;
    min-height: calc(100dvh - 20px);
    border-radius: 12px;
  }
  .login-logo { padding: 18px 18px 0; }
  .login-logo img { width: min(170px, 56%); }
  .login-form {
    gap: 12px;
    padding: 20px 18px 24px;
  }
  .login-form h1 { font-size: 24px; }
  .login-form p { margin: -4px 0 2px; }
  .login-links { flex-direction: column; gap: 6px; }

  .main-view {
    padding: 10px;
  }

  .filter-bar {
    gap: 10px;
    margin-bottom: 10px;
  }

  .filter-bar label {
    gap: 5px;
    font-size: 12px;
  }

  .table-panel {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .data-table tbody {
    gap: 10px;
  }

  .data-table tr {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 8px 10px;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  }

  .data-table td {
    min-width: 0;
  }

  .data-table td + td {
    margin-top: 0;
  }

  .data-table td::before {
    margin-bottom: 3px;
    font-size: 10px;
  }

  .data-table td:nth-child(1)::before,
  .data-table td:nth-child(2)::before,
  .data-table td:nth-child(3)::before,
  .data-table td:nth-child(12)::before {
    display: none;
  }

  .data-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    color: var(--muted);
    font-size: 12px;
  }

  .data-table td:nth-child(1) strong {
    display: block;
    color: var(--ink);
    font-size: 14px;
  }

  .data-table td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
  }

  .data-table td:nth-child(2) .link-btn {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 16px;
    line-height: 1.2;
  }

  .data-table td:nth-child(2) small {
    max-width: 100%;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .data-table td:nth-child(3),
  .data-table td:nth-child(12) {
    grid-column: 1 / -1;
  }

  .data-table td:nth-child(n+4):not(:nth-child(12)) {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px 0 0;
    border-top: 1px solid #edf2f7;
  }

  .data-table td:nth-child(n+4):not(:nth-child(12))::before {
    margin: 0;
  }

  .data-table td:nth-child(8),
  .data-table td:nth-child(10),
  .data-table td:nth-child(11) {
    display: none;
  }

  .phone-cell {
    gap: 8px;
  }

  .phone-cell strong,
  .phone-number-link {
    overflow-wrap: anywhere;
  }

  .phone-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .phone-action {
    min-height: 40px;
    width: 100%;
    padding: 0 8px;
    font-size: 12px;
  }

  .phone-action span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions .icon-btn.small {
    width: 100%;
    min-height: 40px;
    background: #f8fafc;
  }

  .table-footer {
    padding: 4px 2px 0;
    font-size: 12px;
  }

  .modal-head {
    align-items: flex-start;
  }

  .form-grid {
    gap: 10px;
  }

  .form-section {
    padding: 12px;
  }

  .modal-actions {
    padding: 10px;
  }

  .modal-actions > div {
    gap: 8px;
  }

  .settings-grid {
    gap: 10px;
  }

  .definition-list {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .definition-list dt {
    font-size: 12px;
  }

  .definition-list dd {
    margin: 0 0 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #edf2f7;
    overflow-wrap: break-word;
    word-break: normal;
  }

  .definition-list dd:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
  }
}

@media (max-width: 520px) {
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .topbar-title h1 {
    font-size: 20px;
  }

  .modal-head {
    min-height: 64px;
    padding: 12px 14px;
  }

  .modal-head h2 {
    font-size: 20px;
  }

  .form-grid,
  .gallery-body {
    padding: 14px;
  }

  .calculated-strip {
    padding: 10px 14px;
  }
}
