:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #6f736f;
  --line: #dfe3dc;
  --panel: #ffffff;
  --soft: #f4f6f1;
  --soft-2: #eef5f8;
  --accent: #0e7c66;
  --accent-strong: #095745;
  --warn: #a56700;
  --danger: #b33636;
  --cat-fijo: #dff3ff;
  --cat-fijo-corrido: #d7efe4;
  --cat-corrido: #e7f8dc;
  --cat-pareja: #fff0c7;
  --cat-parlet: #f0ddff;
  --cat-final: #ffe0e0;
  --cat-inicio: #dff0ea;
  --cat-centena: #e4e8ff;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(32, 33, 36, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(14, 124, 102, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(42, 87, 141, 0.08), transparent 40%),
    var(--soft);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: #fbfcf8;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand small,
.muted,
.legal-note span,
.session-card small,
.eyebrow {
  color: var(--muted);
}

.brand strong,
.brand small,
.session-card strong,
.session-card small {
  display: block;
}

.session-card,
.legal-note,
.feature-panel,
.login-panel,
.panel,
.table-wrap {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.session-card,
.legal-note {
  padding: 14px;
}

.legal-note {
  margin-top: auto;
  font-size: 0.88rem;
}

.legal-note strong,
.legal-note span {
  display: block;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button,
.ghost-button,
.primary-button,
.danger-button,
.small-button {
  min-height: 40px;
  border-radius: var(--radius);
  padding: 0 14px;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: #e7f1ed;
  color: var(--accent-strong);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.topbar h1,
.login-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.inline-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.inline-filter select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.inline-result-input {
  width: 118px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.draw-group {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.view {
  display: grid;
  gap: 18px;
}

.auth-grid,
.login-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.login-panel,
.feature-panel,
.panel {
  padding: 22px;
}

.auth-form,
.demo-logins,
.cards-grid,
.form-grid,
.line-grid,
.stats-grid {
  display: grid;
  gap: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 22px 0 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.auth-tabs button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tabs button.active {
  background: #fff;
  color: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(32, 33, 36, 0.08);
}

.auth-form.hidden,
.hidden {
  display: none !important;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.google-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.google-button:hover {
  transform: translateY(-1px);
  background: #f8faf7;
}

.role-choice-panel {
  max-width: 780px;
}

.role-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.role-choice-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 28px rgba(32, 33, 36, 0.08);
}

.role-choice-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.role-choice-card strong {
  color: var(--accent-strong);
  font-size: 1.08rem;
}

.role-choice-card span {
  color: var(--muted);
  line-height: 1.45;
}

.demo-logins {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
}

.choice-button {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
}

.choice-button:hover,
.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.small-button:hover {
  transform: translateY(-1px);
}

.choice-button span,
.choice-button strong {
  display: block;
}

.choice-button span {
  color: var(--muted);
}

.choice-button strong {
  margin-top: 8px;
}

.feature-panel {
  display: grid;
  align-content: center;
  gap: 12px;
}

.metric-row,
.entry-header,
.connection-row,
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.metric-row:last-child {
  border-bottom: 0;
}

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

.stat {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.stat span,
.stat strong {
  display: block;
}

.stat span {
  color: var(--muted);
  font-size: 0.88rem;
}

.stat strong {
  margin-top: 8px;
  font-size: 1.6rem;
}

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

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

.field {
  display: grid;
  gap: 7px;
}

.field[hidden] {
  display: none;
}

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

.field label {
  font-weight: 700;
}

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

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.dual-number-input {
  display: grid;
  grid-template-columns: minmax(56px, 1fr) auto minmax(56px, 1fr);
  align-items: center;
  gap: 8px;
}

.dual-number-input span {
  display: grid;
  min-width: 22px;
  place-items: center;
  color: var(--accent-strong);
  font-weight: 900;
}

.dual-number-input input {
  text-align: center;
}

.line-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf8;
}

.limit-notice {
  padding: 12px 14px;
  border: 1px solid #c9ded6;
  border-radius: var(--radius);
  background: #eef8f4;
  color: var(--accent-strong);
}

.limit-notice:empty {
  display: none;
}

.edited-alert {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid #f0b94d;
  border-left: 5px solid #d97a00;
  border-radius: var(--radius);
  background: #fff3d8;
  color: #6d3b00;
}

.edited-alert span {
  color: #855000;
}

.edited-alert.compact {
  padding: 10px 12px;
}

.voided-alert {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid #d86d6d;
  border-left: 5px solid #b33636;
  border-radius: var(--radius);
  background: #ffe9e9;
  color: #761f1f;
}

.voided-alert.compact {
  padding: 10px 12px;
}

.line-grid {
  grid-template-columns: 1.1fr 1fr 1fr auto;
  align-items: end;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.danger-button {
  background: #ffecec;
  color: var(--danger);
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  background: #edf4f2;
  color: var(--accent-strong);
  font-weight: 800;
}

.link-button {
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e8f2ee;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.status.pending {
  background: #fff2d8;
  color: var(--warn);
}

.status.rejected,
.status.blocked {
  background: #ffecec;
  color: var(--danger);
}

.notification-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.notify-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #b33636;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
}

.preview-list,
.connection-list,
.entry-list,
.profile-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.preview-item,
.connection-row,
.entry-card,
.profile-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.entry-card,
.profile-card {
  display: grid;
  gap: 10px;
}

.detail-list {
  display: grid;
  gap: 14px;
}

.detail-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.detail-card-head,
.detail-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-index {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #eef5f8;
  font-weight: 900;
}

.detail-meta {
  justify-content: flex-start;
  color: var(--muted);
}

.contribution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.contribution-chip {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: var(--radius);
}

.contribution-chip span {
  font-size: 1.1rem;
  font-weight: 900;
}

.contribution-chip small {
  color: var(--muted);
}

.detail-mini-list {
  display: grid;
  gap: 8px;
}

.detail-mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf8;
}

.detail-mini-row > div {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.lookup-results {
  margin-top: 14px;
}

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

.lookup-group {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.table-toolbar.compact {
  margin-bottom: 8px;
}

.edited-card,
.edited-row {
  background: #fff9ea;
}

.edited-status {
  background: #ffe3aa;
  color: #7a4100;
}

.voided-row,
.voided-card {
  background: #fff0f0;
  text-decoration-color: rgba(179, 54, 54, 0.35);
}

.voided-status {
  background: #ffd5d5;
  color: #8f2727;
}

.entry-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--soft-2);
  color: #244252;
  font-weight: 700;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: #202124;
  font-weight: 800;
}

.cat-fijo { background: var(--cat-fijo); }
.cat-fijo_corrido { background: var(--cat-fijo-corrido); }
.cat-corrido { background: var(--cat-corrido); }
.cat-pareja { background: var(--cat-pareja); }
.cat-parlet { background: var(--cat-parlet); }
.cat-final { background: var(--cat-final); }
.cat-inicio { background: var(--cat-inicio); }
.cat-centena { background: var(--cat-centena); }

.cat-cell {
  border-radius: 6px;
}

.chat-panel {
  border-color: #c9ded6;
}

.chat-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.chat-thread-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
}

.chat-thread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 190px;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
}

.chat-thread.active {
  border-color: var(--accent);
  background: #e9f5f0;
}

.chat-thread span,
.chat-thread strong,
.chat-thread small {
  display: block;
}

.chat-thread small {
  max-width: 140px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message {
  max-width: 75%;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #f3f5ef;
}

.chat-message.mine {
  justify-self: end;
  background: #e2f3ed;
}

.chat-message strong,
.chat-message span,
.chat-message small {
  display: block;
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.chat-compose input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.floating-chat-button {
  position: fixed;
  right: 0;
  top: 50%;
  z-index: 30;
  min-height: 46px;
  border-radius: 999px 0 0 999px;
  padding: 0 14px 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  box-shadow: var(--shadow);
  transform: translateY(-50%);
  writing-mode: vertical-rl;
}

.floating-chat-button span {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  margin-left: 6px;
  place-items: center;
  border-radius: 50%;
  background: #b33636;
}

.floating-chat-window {
  position: fixed;
  z-index: 31;
  width: min(430px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 110px));
  overflow: auto;
}

.floating-chat-panel {
  box-shadow: 0 24px 70px rgba(32, 33, 36, 0.24);
}

.chat-drag-handle {
  cursor: move;
  user-select: none;
}

.drag-hint {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #edf4f2;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
}

.table-wrap {
  overflow: auto;
}

.inner-table {
  margin-top: 14px;
  box-shadow: none;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  background: #f7f9f3;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.empty {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.64);
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #202124;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav,
  .stats-grid,
  .cards-grid,
  .form-grid,
  .auth-grid,
  .role-choice-grid,
  .login-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .metric-row,
  .entry-header,
  .connection-row,
  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .demo-logins,
  .line-grid {
    grid-template-columns: 1fr;
  }
}
