:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #315b63;
  --primary-dark: #23474e;
  --danger: #a94442;
  --warning-bg: #fff7e6;
  --ok-bg: #eaf6ee;
  --shadow: 0 12px 32px rgba(31, 41, 51, 0.08);
}

* { box-sizing: border-box; }
html {
  width: 100%;
  overflow-x: hidden;
}
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  width: 100%;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 245px 1fr;
  min-width: 0;
}
.sidebar {
  background: #1f2933;
  color: #fff;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
}
.brand {
  display: block;
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 24px;
  letter-spacing: 0;
}
.nav {
  display: grid;
  gap: 6px;
}
.nav a,
.nav-button {
  display: block;
  width: 100%;
  color: #dce3ea;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.nav a.active,
.nav a:hover,
.nav-button:hover {
  background: rgba(255,255,255,0.09);
  color: #fff;
  text-decoration: none;
}
.content {
  padding: 28px;
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  min-width: 0;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: clamp(1.65rem, 3vw, 2.25rem); }
h2 { font-size: 1.1rem; }
h3 { font-size: .94rem; margin-top: 18px; color: var(--muted); }
p { color: var(--muted); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.stack-form,
.form-grid,
.sub-form {
  display: grid;
  gap: 14px;
}
label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: .92rem;
  font-weight: 600;
}
input, select, textarea {
  max-width: 100%;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
  color: var(--text);
  min-height: 44px;
}
input:focus, select:focus, textarea:focus {
  border-color: #89aeb5;
  box-shadow: 0 0 0 3px rgba(49, 91, 99, 0.12);
  outline: none;
}
textarea { min-height: 90px; resize: vertical; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 40px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  max-width: 100%;
}
button:hover, .button:hover { text-decoration: none; border-color: #b7c0cc; }
.primary,
.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.primary:hover,
.button.primary:hover { background: var(--primary-dark); }
.danger { color: var(--danger); border-color: #e6c9c8; }
.muted { color: var(--muted); }
.small { padding: 6px 9px; min-height: 32px; font-size: .86rem; }
.head-actions,
.actions,
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.panel,
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel { padding: 20px; margin-bottom: 18px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  padding: 16px;
  min-height: 96px;
}
.stat span { color: var(--muted); font-size: .9rem; }
.stat strong { display: block; font-size: 2rem; margin-top: 8px; }
.stat.due { background: var(--warning-bg); }
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.table-wrap { overflow-x: auto; }
.mobile-business-list { display: none; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
th, td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
}
small { color: var(--muted); }
.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef2f6;
  color: #344054;
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
  text-transform: capitalize;
}
.priority-alta { background: #fdecec; color: #8a2f2c; }
.priority-media { background: #fff3d6; color: #74520b; }
.priority-baja { background: var(--ok-bg); color: #276749; }

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 190px 190px auto auto;
  gap: 10px;
  margin-bottom: 16px;
  min-width: 0;
}
.mobile-business-card {
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  width: 100%;
  min-width: 0;
}
.mobile-card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  min-width: 0;
}
.mobile-card-head h2 {
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}
.mobile-card-head p {
  margin: 4px 0 0;
}
.mobile-card-meta {
  display: grid;
  gap: 10px;
  margin: 0;
}
.mobile-card-meta div {
  display: grid;
  grid-template-columns: minmax(96px, 34%) 1fr;
  gap: 10px;
  min-width: 0;
}
.mobile-card-meta dt {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}
.mobile-card-meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.empty-card p {
  margin: 0;
  text-align: center;
}
.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; }
.detail-grid {
  display: grid;
  grid-template-columns: minmax(290px, .8fr) 1.2fr;
  gap: 18px;
  min-width: 0;
}
.info-list {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px 14px;
}
.info-list dt { color: var(--muted); font-weight: 700; }
.info-list dd { margin: 0; }
.preline { white-space: pre-line; color: var(--text); }
.sub-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 16px;
}
.sub-form textarea { min-height: 72px; }
.sub-form.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}
.timeline {
  display: grid;
  gap: 10px;
}
.timeline-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.timeline-item summary {
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  flex-wrap: wrap;
  min-width: 0;
}
.inline { display: flex; grid-auto-flow: column; align-items: center; gap: 8px; }
.inline input { width: auto; }
.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px auto;
  gap: 8px;
  margin-top: 10px;
}
.flash, .alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.flash { background: var(--ok-bg); color: #276749; border: 1px solid #c9e9d2; }
.alert { background: #fdecec; color: #8a2f2c; border: 1px solid #f3c3c1; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    height: auto;
    top: 0;
    padding: 14px;
    box-shadow: 0 8px 24px rgba(31, 41, 51, 0.18);
  }
  .brand {
    margin-bottom: 12px;
    font-size: 1.05rem;
  }
  .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
    padding-bottom: 0;
  }
  .nav a,
  .nav-button {
    white-space: normal;
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    background: rgba(255,255,255,0.06);
    text-align: center;
  }
  .nav form { width: 100%; }
  .content { padding: 18px; }
  .page-head, .detail-grid { display: grid; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters, .form-grid, .sub-form, .sub-form.compact, .inline-form {
    grid-template-columns: 1fr;
  }
  .page-head {
    align-items: stretch;
    margin-bottom: 16px;
  }
  .page-head .button,
  .page-head button {
    width: 100%;
  }
  .head-actions { display: grid; grid-template-columns: 1fr; }
  .head-actions > *,
  .head-actions .button,
  .head-actions button { width: 100%; }
  .info-list { grid-template-columns: 1fr; }
  .info-list {
    gap: 4px;
  }
  .info-list dt {
    margin-top: 8px;
    font-size: .8rem;
  }
  .filters {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
  }
  .form-actions,
  .actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .button,
  button {
    width: 100%;
    min-height: 44px;
  }
  .small {
    min-height: 40px;
    justify-content: center;
  }
  .table-wrap {
    overflow: visible;
  }
  .business-list-panel {
    display: none;
  }
  .mobile-business-list {
    display: grid;
    gap: 0;
    width: 100%;
    min-width: 0;
  }
  table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 12px;
  }
  thead {
    display: none;
  }
  tr {
    display: grid;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 0;
  }
  td {
    display: grid;
    grid-template-columns: minmax(118px, 34%) 1fr;
    gap: 10px;
    border-bottom: 0;
    padding: 8px 12px;
    align-items: start;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .76rem;
    font-weight: 800;
  }
  td.empty {
    display: block;
    text-align: center;
  }
  td.empty::before {
    content: "";
  }
  td .actions,
  td.actions {
    align-items: stretch;
  }
  .timeline-item {
    padding: 10px;
  }
  .timeline-item summary {
    display: grid;
    gap: 8px;
  }
  .inline {
    align-items: flex-start;
  }
  .login-card {
    padding: 22px;
    box-shadow: none;
  }
}

@media (max-width: 560px) {
  body { background: #f7f8fa; }
  .content { padding: 14px; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1rem; }
  p { margin: 6px 0 0; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat {
    min-height: 78px;
    padding: 14px;
  }
  .stat strong { font-size: 1.7rem; }
  .panel {
    padding: 14px;
    border-radius: 8px;
    box-shadow: none;
  }
  td {
    grid-template-columns: minmax(88px, 36%) 1fr;
    padding: 8px 10px;
  }
}
