:root {
  color-scheme: light;
  --navy: #071a2b;
  --navy-2: #12344f;
  --green: #1eaa70;
  --green-dark: #138257;
  --sky: #eaf6fb;
  --paper: #ffffff;
  --bg: #f3f6f8;
  --text: #142331;
  --muted: #657482;
  --border: #dce5ea;
  --danger: #c93f4d;
  --warning: #cf7d16;
  --shadow: 0 10px 30px rgba(7, 26, 43, 0.08);
  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: var(--bg);
  color: var(--text);
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
.hidden {
  display: none !important;
}
.muted,
.help-text {
  color: var(--muted);
}
.help-text {
  font-size: 0.88rem;
  margin-bottom: 0;
}
.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--green-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}
h1,
h2,
h3 {
  margin-top: 0;
}
h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.8rem, 5vw, 2.5rem);
}
h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
}
h3 {
  font-size: 1.05rem;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: radial-gradient(
    circle at 15% 15%,
    #164b66 0,
    var(--navy) 42%,
    #04111c 100%
  );
}
.login-card {
  width: min(100%, 440px);
  padding: clamp(1.5rem, 5vw, 2.5rem);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}
.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 1.25rem;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--green), #5ed89f);
  color: white;
  font-size: 1.8rem;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(30, 170, 112, 0.28);
}
.brand-mark.small {
  width: 40px;
  height: 40px;
  margin: 0;
  border-radius: 12px;
  font-size: 1.2rem;
}
.form-stack,
.form-grid,
.inline-form {
  display: grid;
  gap: 1rem;
}
label {
  display: grid;
  gap: 0.42rem;
  color: #344755;
  font-size: 0.86rem;
  font-weight: 700;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.78rem 0.85rem;
  background: white;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(30, 170, 112, 0.12);
}
textarea {
  resize: vertical;
}
.primary,
.secondary,
.danger,
.ghost,
.link-button {
  border: 0;
  border-radius: 10px;
  font-weight: 800;
}
.primary {
  padding: 0.78rem 1rem;
  background: var(--green);
  color: white;
}
.primary:hover {
  background: var(--green-dark);
}
.secondary {
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border);
  background: white;
  color: var(--navy-2);
}
.danger {
  padding: 0.7rem 0.95rem;
  border: 1px solid #efc1c6;
  background: #fff1f2;
  color: var(--danger);
}
.danger:hover {
  background: #fde2e5;
}
.ghost {
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
.link-button {
  padding: 0;
  background: transparent;
  color: var(--green-dark);
}

.app-shell {
  min-height: 100vh;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: var(--navy);
  color: white;
  box-shadow: 0 3px 18px rgba(7, 26, 43, 0.2);
}
.brand-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-inline span {
  display: block;
  color: #b9cbd6;
  font-size: 0.78rem;
}
.nav-tabs {
  position: sticky;
  top: 68px;
  z-index: 15;
  display: flex;
  gap: 0.35rem;
  padding: 0.6rem max(1rem, calc((100vw - 1180px) / 2));
  overflow-x: auto;
  background: white;
  border-bottom: 1px solid var(--border);
}
.nav-button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  padding: 0.62rem 0.9rem;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}
.nav-button.active {
  background: var(--sky);
  color: var(--navy-2);
}
.page-content {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.6rem 0 4rem;
}
.section-heading,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.section-heading {
  margin-bottom: 1.25rem;
}
.heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.sync-control {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.sync-control .help-text {
  margin: 0;
  max-width: 260px;
}
.panel-heading h3 {
  margin-bottom: 0;
}
.panel {
  margin-bottom: 1.15rem;
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow);
}
.banner {
  margin-bottom: 1.15rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: #fff7e8;
  border: 1px solid #f0d6a9;
  color: #7a4b0a;
  font-size: 0.9rem;
}
.banner.ready {
  background: #eaf9f2;
  border-color: #bce8d3;
  color: #126440;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.15rem;
}
.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 900px) {
  .dashboard-columns {
    grid-template-columns: 1fr;
  }
}
.stat-card {
  padding: 1rem;
  border-radius: 15px;
  background: var(--paper);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-value {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--navy);
  font-size: 1.8rem;
  font-weight: 900;
}
.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
}
.ticket-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}
.ticket-row {
  display: grid;
  grid-template-columns: 85px 1fr auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem;
  border-radius: 12px;
  background: #f8fafb;
  border: 1px solid #e8eef1;
}
.ticket-row p {
  margin: 0.18rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  border-radius: 999px;
  padding: 0.28rem 0.52rem;
  background: #edf2f5;
  color: #425763;
  font-size: 0.72rem;
  font-weight: 850;
}
.badge.URGENT {
  background: #fdebed;
  color: #a52331;
}
.badge.HIGH {
  background: #fff1df;
  color: #9a5708;
}
.badge.RESOLVED,
.badge.VERIFIED,
.badge.CLOSED {
  background: #e6f7ef;
  color: #106b44;
}
.badge.EN_ROUTE,
.badge.ON_SITE {
  background: #e4f3fb;
  color: #17628c;
}
.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.wide {
  grid-column: 1 / -1;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
}
.form-actions {
  gap: 0.65rem;
}
.inline-form {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}
.checkbox-field {
  align-content: center;
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 0.78rem 0;
}
.checkbox-field input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
}
.catalog-table {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.table-panel {
  overflow: hidden;
  padding: 0;
}
.data-table {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
th,
td {
  padding: 0.82rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  font-size: 0.84rem;
}
th {
  background: #f7fafb;
  color: #536773;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
tr:last-child td {
  border-bottom: 0;
}
.table-action {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  min-width: 240px;
}
.table-action select {
  padding: 0.48rem;
}
.table-action button {
  padding: 0.5rem 0.65rem;
}
.technician-actions {
  min-width: auto;
}
.icon-button {
  min-width: 40px;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0.4rem;
  font-size: 1.05rem;
}
.empty-state {
  padding: 1.4rem;
  text-align: center;
  color: var(--muted);
}
.connection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.connection-card {
  padding: 1.2rem;
  border-radius: 16px;
  background: white;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.connection-card p {
  margin-bottom: 0;
  color: var(--muted);
}
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: var(--warning);
}
.status-dot.ready {
  background: var(--green);
}
.code-block {
  display: block;
  padding: 0.9rem;
  border-radius: 10px;
  overflow-wrap: anywhere;
  background: #071a2b;
  color: #d9f7ea;
}
.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  max-width: min(420px, calc(100% - 2rem));
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--navy);
  color: white;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.error {
  background: var(--danger);
}

@media (max-width: 880px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .page-content {
    width: min(100% - 1rem, 1180px);
    padding-top: 1rem;
  }
  .topbar {
    padding: 0 0.75rem;
  }
  .brand-inline strong {
    font-size: 0.9rem;
  }
  .section-heading {
    align-items: flex-end;
  }
  .stats-grid,
  .form-grid,
  .form-grid.compact,
  .inline-form,
  .connection-grid {
    grid-template-columns: 1fr;
  }
  .ticket-row {
    grid-template-columns: 70px 1fr;
  }
  .ticket-row > :last-child {
    grid-column: 2;
  }
  .form-actions {
    justify-content: stretch;
  }
  .form-actions button {
    width: 100%;
  }
}

/* Panel oscuro de chatbot RAPIZ */
:root {
  color-scheme: dark;
  --navy: #2e353b;
  --navy-2: #3d4851;
  --green: #08bd91;
  --green-dark: #079b79;
  --sky: #456f9a;
  --paper: #333a40;
  --bg: #46515b;
  --text: #f4f7f9;
  --muted: #b8c1c8;
  --border: #4c555d;
  --danger: #df3548;
  --warning: #f4b400;
  --shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.app-shell {
  display: grid;
  grid-template-columns: 254px minmax(0, 1fr);
  grid-template-rows: 48px minmax(calc(100vh - 48px), auto);
  background: var(--bg);
}

.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  height: 48px;
  padding: 0 1rem 0 0.7rem;
  background: #30373d;
  border-bottom: 1px solid #44505a;
  box-shadow: none;
}

.brand-inline {
  width: 244px;
  justify-content: center;
}

.brand-inline > div:last-child {
  display: none;
}

.robot-mark {
  background: transparent;
  box-shadow: none;
  font-size: 1.45rem;
}

.topbar-session {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: #cbd3d8;
  font-size: 0.82rem;
}

.nav-tabs {
  position: sticky;
  top: 48px;
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.35rem 0.65rem 1rem;
  overflow-y: auto;
  background: #30373d;
  border: 0;
  border-right: 1px solid #44505a;
}

.sidebar-search {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.65rem;
  padding: 0.62rem 0.75rem;
  border: 1px solid #56616a;
  border-radius: 4px;
  color: #8fa0ac;
  background: #3a4249;
  font-size: 0.82rem;
}

.online-indicator {
  padding: 0.15rem 0.75rem 0.55rem;
  color: #cbd3d8;
  font-size: 0.78rem;
}

.online-indicator span {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: #08b936;
}

.nav-button {
  width: 100%;
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  flex: 0 0 auto;
  padding: 0.7rem 0.75rem;
  color: #c5ccd1;
  border-radius: 4px;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 500;
}

.nav-button.active {
  background: #4576a5;
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  padding: 1rem 0.75rem 0.25rem;
  border-top: 1px solid #465058;
  color: #bfc8ce;
  font-size: 0.76rem;
}

.page-content {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1rem 1rem 4rem;
}

.section-heading {
  margin-bottom: 1rem;
}

h2 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 400;
}

.eyebrow {
  color: #79d8bd;
}

.panel,
.connection-card {
  border-radius: 5px;
  background: #30373d;
  border-color: #414b53;
}

.panel-heading {
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #414b53;
}

.quick-panel {
  padding: 1rem 1.2rem 1.35rem;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.quick-action {
  min-height: 49px;
  border: 0;
  border-radius: 5px;
  background: #08bc91;
  color: #fff;
  font-size: 1rem;
}

.quick-action:hover {
  background: #06a981;
}

.quick-action span {
  margin-right: 0.35rem;
}

.banner {
  border-color: #696240;
  background: #5b5538;
  color: #fff0b2;
}

.banner.ready {
  border-color: #237a64;
  background: #245c50;
  color: #d9fff4;
}

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

.stat-card {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  padding: 0.9rem;
  border: 0;
  border-radius: 5px;
  color: white;
}

.stat-card.cyan {
  background: #209db0;
}

.stat-card.green {
  background: #24a746;
}

.stat-card.amber {
  background: #f3b500;
  color: #172128;
}

.stat-card.red {
  background: #db3347;
}

.stat-value,
.stat-label {
  color: inherit;
}

.stat-value {
  font-size: 1.55rem;
}

.stat-more {
  margin-top: auto;
  text-align: center;
  font-size: 0.78rem;
}

label {
  color: #dce3e7;
}

input,
select,
textarea {
  border-color: #56616a;
  background: #3b444b;
  color: #f6f8f9;
}

.secondary {
  border-color: #657079;
  background: #404951;
  color: #f0f4f6;
}

.link-button {
  color: #68dab9;
}

.ticket-row,
th {
  background: #394148;
}

.ticket-row {
  border-color: #4b555d;
}

td,
th {
  border-color: #4b555d;
}

.assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
}

.assistant-statuses {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.connection-pill {
  padding: 0.42rem 0.65rem;
  border-radius: 999px;
  border: 1px solid #69737b;
  color: #d7dde1;
  font-size: 0.75rem;
}

.connection-pill.ready,
.connection-pill.safe {
  border-color: #159c78;
  background: rgba(8, 189, 145, 0.15);
  color: #8af0d2;
}

.chat-panel {
  padding: 0;
  overflow: hidden;
}

.chat-messages {
  height: min(58vh, 590px);
  min-height: 390px;
  overflow-y: auto;
  padding: 1.2rem;
  background:
    linear-gradient(rgba(48, 55, 61, 0.96), rgba(48, 55, 61, 0.96)),
    radial-gradient(circle at 70% 30%, #16705e, transparent 38%);
}

.chat-message {
  max-width: 82%;
  display: flex;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.chat-message > div:last-child {
  padding: 0.75rem 0.9rem;
  border-radius: 4px 12px 12px;
  background: #414a51;
  box-shadow: var(--shadow);
}

.chat-message p {
  margin: 0.25rem 0 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-message small {
  display: block;
  margin-top: 0.5rem;
  color: #92a1aa;
}

.user-message {
  flex-direction: row-reverse;
  margin-left: auto;
}

.user-message > div:last-child {
  border-radius: 12px 4px 12px 12px;
  background: #087f65;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #08bd91;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.7rem;
  padding: 0.9rem;
  border-top: 1px solid #4b555d;
}

.chat-form textarea {
  min-height: 55px;
  resize: none;
}

.chat-form button {
  height: 55px;
}

.prompt-panel {
  align-self: start;
}

.suggestion-button {
  width: 100%;
  margin-bottom: 0.65rem;
  padding: 0.75rem;
  border: 1px solid #52616a;
  border-radius: 6px;
  background: #3a444b;
  color: #e3e9ec;
  text-align: left;
}

.suggestion-button:hover {
  border-color: #08bd91;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .quick-actions,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .prompt-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .prompt-panel h3,
  .prompt-panel p {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .topbar {
    position: sticky;
    padding-left: 0.75rem;
  }

  .brand-inline {
    width: auto;
  }

  .brand-inline > div:last-child {
    display: block;
  }

  .topbar-session #session-name {
    display: none;
  }

  .nav-tabs {
    position: sticky;
    top: 48px;
    height: auto;
    flex-direction: row;
    padding: 0.5rem;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid #44505a;
  }

  .sidebar-search,
  .online-indicator,
  .sidebar-foot {
    display: none;
  }

  .nav-button {
    width: auto;
    min-width: max-content;
    grid-template-columns: auto auto;
  }

  .page-content {
    padding: 1rem 0.55rem 3rem;
  }

  .assistant-statuses {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .quick-actions,
  .stats-grid,
  .prompt-panel {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-messages {
    min-height: 360px;
  }

  .chat-message {
    max-width: 95%;
  }
}
