:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --panel: #ffffff;
  --canvas: #f3f6f8;
  --nav: #15313f;
  --nav-soft: #204b5f;
  --accent: #0b7285;
  --accent-dark: #075766;
  --green: #2f855a;
  --orange: #b45309;
  --red: #b42318;
  --shadow: 0 12px 30px rgba(20, 38, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: var(--nav);
  color: #fff;
  padding: 28px 20px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 36px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: var(--nav-soft);
  font-weight: 800;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.brand p,
.eyebrow {
  margin: 4px 0 0;
  color: #b9ccd6;
  font-size: 13px;
}

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

.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  color: #dce8ed;
  background: transparent;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  color: #fff;
  background: var(--nav-soft);
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
}

.content {
  min-width: 0;
  padding: 28px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 30px;
}

.topbar .eyebrow {
  color: var(--accent-dark);
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-actions,
.filters,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.session-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.session-box span {
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(380px, 46vw);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search input {
  width: 100%;
  min-height: 42px;
  border: 0;
  outline: 0;
}

.login-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin: -8px 0 22px;
  padding: 16px;
  border: 1px solid #b8e6ed;
  border-radius: 8px;
  background: #eef8f9;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat,
.form-panel,
.ticket-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat {
  padding: 18px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

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

.section-head.compact {
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
  font-size: 20px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select,
input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

.primary-button,
.ghost-button,
.danger-button,
.file-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.primary-button:hover {
  background: var(--accent-dark);
}

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

.ghost-button.active-light {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.danger-button {
  color: var(--red);
  background: #fff;
  border-color: #f3b8b3;
}

.danger-button:hover {
  background: #fff5f4;
}

.file-button {
  color: var(--accent-dark);
  background: #fff;
  border-color: var(--line);
  cursor: pointer;
}

.file-button input {
  display: none;
}

.ticket-list,
.history-list {
  display: grid;
  gap: 12px;
}

.ticket-list.slim {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 4px;
}

.ticket-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.ticket-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.ticket-selector input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.ticket-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 114, 133, 0.12), var(--shadow);
}

.ticket-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.ticket-id {
  color: var(--accent-dark);
  font-weight: 800;
}

.ticket-title {
  margin: 4px 0 0;
  font-size: 18px;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.ticket-desc {
  margin: 0;
  color: #344054;
  line-height: 1.45;
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.open {
  color: var(--red);
  background: #fee4e2;
}

.badge.progress {
  color: var(--orange);
  background: #fef0c7;
}

.badge.resolved {
  color: var(--green);
  background: #dcfae6;
}

.badge.pending {
  color: var(--accent-dark);
  background: #d7f3f7;
}

.badge.closed {
  color: var(--green);
  background: #dcfae6;
}

.priority.alta {
  color: var(--red);
}

.priority.media {
  color: var(--orange);
}

.priority.baja {
  color: var(--green);
}

.form-panel {
  display: grid;
  gap: 18px;
  max-width: 980px;
  padding: 22px;
}

.form-panel h3 {
  margin: 0;
  font-size: 20px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
}

.technician-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
}

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

.logo-preview {
  display: grid;
  place-items: center;
  min-height: 110px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f7fafc;
}

.logo-preview img {
  max-width: 220px;
  max-height: 90px;
  object-fit: contain;
}

.access-code {
  display: inline-flex;
  width: fit-content;
  padding: 3px 7px;
  border-radius: 5px;
  color: var(--accent-dark) !important;
  background: #d7f3f7;
  font-family: Consolas, monospace;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.resolution-panel {
  position: sticky;
  top: 28px;
  max-width: none;
  align-self: start;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}

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

.hidden {
  display: none !important;
}

.selected-ticket {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 8px;
  background: #eef8f9;
}

.selected-ticket span {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.ticket-note,
.confirmation-box,
.notification-box,
.catalog-item {
  border-radius: 8px;
  background: #f7fafc;
  color: #344054;
}

.company-line,
.company-identity,
.history-company {
  display: flex;
  align-items: center;
  gap: 10px;
}

.company-line {
  color: #344054;
}

.company-logo {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.company-logo.small {
  width: 34px;
  height: 34px;
}

.company-logo.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.ticket-note {
  padding: 10px 12px;
  line-height: 1.45;
}

.confirmation-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #b8e6ed;
}

.notification-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
}

.confirmation-box span,
.muted-note {
  color: var(--muted);
  line-height: 1.4;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.delivery-options {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.check-option input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

a.ghost-button {
  text-decoration: none;
}

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

.catalog-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
}

.catalog-item span {
  color: var(--muted);
}

.catalog-main {
  display: grid;
  gap: 4px;
}

.catalog-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.permission {
  font-weight: 800;
}

.permission.autorizada {
  color: var(--green);
}

.permission.requiere_aprobacion {
  color: var(--orange);
}

.permission.suspendida {
  color: var(--red);
}

.history-card {
  padding: 18px;
}

.history-card h4 {
  margin: 0 0 10px;
}

.history-card dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.history-card dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.history-card dd {
  margin: 3px 0 0;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    padding: 18px;
  }

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

  .nav-button {
    justify-content: center;
  }

  .brand {
    margin-bottom: 18px;
  }

  .content {
    padding: 20px;
  }

  .topbar,
  .section-head,
  .technician-layout,
  .catalog-layout,
  .login-panel {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .session-box {
    justify-content: space-between;
  }

  .search {
    min-width: 0;
  }

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

  .resolution-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar-actions,
  .filters,
  .form-actions,
  .session-box,
  .action-row,
  .ticket-top,
  .catalog-item,
  .catalog-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .topbar h2 {
    font-size: 24px;
  }
}
