:root {
  color-scheme: light;
  --bg: #f1f3f7;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --ink: #1f2124;
  --muted: #6d758f;
  --line: #e1e4ed;
  --teal: #1e1555;
  --teal-soft: #ece9ff;
  --rose: #d9534f;
  --rose-soft: #fde9e8;
  --amber: #f0ad4e;
  --amber-soft: #fff3df;
  --indigo: #4105de;
  --indigo-soft: #ebe6ff;
  --blue: #168aff;
  --blue-soft: #e8f3ff;
  --shadow: 0 20px 60px rgba(28, 36, 72, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(30, 21, 85, 0.09), transparent 34%),
    linear-gradient(315deg, rgba(22, 138, 255, 0.08), transparent 28%),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(280px, 520px);
  gap: 28px;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(30, 21, 85, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(22, 138, 255, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(236, 233, 255, 0.7), rgba(241, 243, 247, 0.95));
}

.login-panel,
.panel,
.metric {
  border: 1px solid rgba(28, 36, 72, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 4vw, 40px);
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--teal), var(--indigo), var(--blue));
}

.login-panel > * {
  position: relative;
}

.eyebrow,
.mini-label {
  display: block;
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.login-panel h1 {
  margin: 0;
  max-width: 24rem;
  font-size: clamp(1.65rem, 4vw, 2.45rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.login-copy {
  max-width: 38rem;
  margin: 16px 0 24px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px;
  margin: 0 0 18px;
  background: #fff;
}

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

.auth-tabs button.active,
.auth-tabs button:hover {
  color: #fff;
  background: var(--teal);
}

.auth-feedback {
  margin: 0 0 16px;
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.4;
}

.auth-feedback.success {
  border: 1px solid rgba(21, 87, 36, 0.18);
  color: #155724;
  background: #dff3e6;
}

.auth-feedback.error {
  border: 1px solid rgba(217, 83, 79, 0.28);
  color: #7c2926;
  background: #f8d7da;
}

.login-form {
  display: grid;
  gap: 16px;
}

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

.login-form label {
  display: grid;
  gap: 8px;
  color: #3d3e3f;
  font-size: 0.86rem;
  font-weight: 700;
}

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

.login-form input:focus,
.filters input:focus,
.filters select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(65, 5, 222, 0.12);
}

.login-form button,
.ghost {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.login-form button {
  color: #fff;
  background: var(--teal);
}

.login-form button:disabled {
  cursor: wait;
  opacity: 0.7;
}

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

.panel-heading span,
.table-toolbar span,
.metric small {
  color: var(--muted);
  font-size: 0.82rem;
}

.workspace {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 24px;
}

.technical-summary-workspace {
  gap: 14px;
}

.technical-summary-workspace .topbar h1 {
  font-size: clamp(1.6rem, 3vw, 2.8rem);
}

.timeline-workspace {
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.topbar,
.panel-heading,
.table-toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
}

.dashboard-heading h1 {
  font-size: 1.35rem;
  line-height: 1.15;
}

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

.segmented-control {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #fff;
}

.segmented-control button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: #3d3e3f;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 850;
}

.segmented-control button.active,
.segmented-control button:hover {
  color: #fff;
  background: var(--teal);
}

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

.logout-button {
  color: #7c2926;
  border-color: rgba(217, 83, 79, 0.28);
}

.logout-button:hover {
  color: #fff;
  background: var(--rose);
}

.history-link-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.history-link-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

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

.metric {
  min-height: 92px;
  padding: 12px 14px;
  box-shadow: none;
}

.metric span,
.metric strong,
.metric small {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  margin: 8px 0 5px;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1;
}

.metric.teal {
  background: var(--teal-soft);
}

.metric.rose {
  background: var(--rose-soft);
}

.metric.amber {
  background: var(--amber-soft);
}

.metric.indigo {
  background: var(--indigo-soft);
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.span-12 {
  grid-column: 1 / -1;
}

.panel {
  padding: 18px;
  box-shadow: none;
}

.panel h2,
.table-toolbar h2 {
  margin: 0 0 3px;
  font-size: 1rem;
}

.rank-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.rank-row {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) minmax(112px, auto) 80px;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.rank-row:hover {
  border-color: rgba(65, 5, 222, 0.28);
}

.rank-number {
  color: var(--muted);
  font-weight: 800;
}

.rank-company,
.table-company {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.rank-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-document {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-company strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-license-stack {
  display: grid;
  gap: 3px;
  justify-items: end;
}

.rank-license-stack strong {
  line-height: 1;
}

.rank-contract {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(65, 5, 222, 0.18);
  border-radius: 8px;
  color: var(--teal);
  background: var(--teal-soft);
}

.icon-button:hover {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.table-action {
  margin: 0;
}

.action-group {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.table-panel .action-group {
  flex-wrap: nowrap;
  justify-content: center;
}

.status {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.74rem;
  font-weight: 900;
}

.status.ok {
  color: #1e1555;
  background: var(--teal-soft);
}

.status.hot {
  color: #a8322f;
  background: var(--rose-soft);
}

.status.watch {
  color: #8a5a10;
  background: var(--amber-soft);
}

.muted-cell {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.usage-pill {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  color: #1e1555;
  background: var(--teal-soft);
  font-size: 0.78rem;
  font-weight: 900;
}

.usage-pill.warning {
  color: #8a5a10;
  background: var(--amber-soft);
}

.usage-pill.over {
  color: #a8322f;
  background: var(--rose-soft);
}

.table-panel {
  overflow: hidden;
  min-width: 0;
}

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

.summary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.summary-layout .panel {
  min-width: 0;
  padding: 14px;
}

.summary-layout .panel-heading {
  margin-bottom: 2px;
}

.summary-panel {
  display: grid;
  gap: 12px;
}

.license-comparison-panel {
  display: grid;
  gap: 12px;
}

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

.license-comparison-card {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.license-comparison-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.license-comparison-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  line-height: 1;
}

.license-comparison-card.ok strong {
  color: var(--teal);
}

.license-comparison-card.warning strong {
  color: var(--amber);
}

.license-comparison-card.over strong {
  color: var(--rose);
}

.license-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e4ed;
}

.license-progress span {
  display: block;
  width: var(--usage);
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.consistency-note {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
}

.consistency-note strong {
  font-size: 0.9rem;
}

.consistency-note span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.consistency-note.warning {
  border-color: rgba(240, 173, 78, 0.34);
  background: var(--amber-soft);
}

.timeline-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-height: 0;
  align-items: stretch;
}

.timeline-layout .panel {
  min-width: 0;
  min-height: 0;
}

.timeline-summary-panel {
  align-content: start;
  overflow: auto;
}

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

.kits-panel,
.equipment-types-panel,
.contract-products-panel {
  display: grid;
  gap: 12px;
}

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

.summary-card,
.summary-kv div,
.summary-empty,
.summary-raw {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-card {
  min-height: 78px;
  padding: 12px;
}

.summary-card span,
.summary-kv span,
.summary-empty span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 1.15rem;
}

.summary-section {
  display: grid;
  gap: 12px;
}

.summary-section h3 {
  margin: 4px 0 0;
  font-size: 0.95rem;
}

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

.summary-kv div {
  padding: 12px;
}

.summary-kv strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.summary-empty {
  display: grid;
  gap: 8px;
  min-height: 112px;
  align-content: center;
  padding: 18px;
}

.summary-empty.error {
  border-color: rgba(217, 83, 79, 0.26);
  background: var(--rose-soft);
}

.summary-raw {
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.86rem;
}

.summary-table {
  margin-top: 0;
}

.service-quantity-cell {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.service-quantity-cell span {
  overflow-wrap: anywhere;
}

.service-quantity-cell strong {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  color: #1e1555;
  background: var(--teal-soft);
  font-size: 0.82rem;
}

.timeline-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  overflow: hidden;
}

.kits-table-wrap {
  width: 100%;
  overflow: auto;
}

.contract-products-wrap {
  width: 100%;
  max-height: min(34vh, 360px);
  overflow: auto;
}

.contract-products-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.omie-services-panel {
  display: grid;
  gap: 12px;
}

.omie-history-panel {
  display: grid;
  gap: 12px;
}

.omie-service-search label {
  display: grid;
  gap: 6px;
}

.omie-service-search span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.omie-service-search input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font-size: 0.9rem;
  font-weight: 750;
  outline: none;
}

.omie-service-search input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(65, 5, 222, 0.12);
}

.omie-service-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 180px));
  gap: 10px;
}

.omie-service-filters label {
  display: grid;
  gap: 5px;
}

.omie-service-filters span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.omie-service-filters select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  font-size: 0.86rem;
  font-weight: 750;
}

.omie-service-tabs {
  display: flex;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding: 2px 0 6px;
}

.omie-service-tabs button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.omie-service-tabs button.active,
.omie-service-tabs button:hover {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.omie-service-tabs span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.omie-service-tabs small {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  border-radius: 999px;
  padding: 0 7px;
  color: currentColor;
  background: rgba(255, 255, 255, 0.24);
  font-size: 0.75rem;
}

.omie-service-tabs button:not(.active) small {
  color: var(--teal);
  background: var(--teal-soft);
}

.omie-services-wrap {
  width: 100%;
  max-height: min(68vh, 720px);
  overflow: auto;
}

.omie-history-wrap {
  width: 100%;
  max-height: min(72vh, 760px);
  overflow: auto;
}

.omie-services-wrap thead th,
.omie-history-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.kits-table {
  min-width: 420px;
}

.contract-products-table {
  min-width: 620px;
}

.omie-services-table {
  min-width: 1040px;
}

.omie-history-table {
  min-width: 1080px;
}

.kits-table th:last-child,
.kits-table td:last-child {
  width: 118px;
  text-align: right;
}

.kits-table td {
  vertical-align: middle;
}

.kits-total-row td {
  background: var(--surface);
  font-weight: 900;
}

.contract-products-table th:nth-child(3),
.contract-products-table td:nth-child(3) {
  text-align: center;
}

.contract-products-table th:nth-child(4),
.contract-products-table td:nth-child(4),
.contract-products-table th:nth-child(5),
.contract-products-table td:nth-child(5) {
  text-align: right;
}

.omie-services-table th:first-child,
.omie-services-table td:first-child {
  width: 150px;
}

.omie-services-table th:nth-child(2),
.omie-services-table td:nth-child(2) {
  width: 260px;
  text-align: left;
}

.omie-services-table th:nth-child(4),
.omie-services-table td:nth-child(4),
.omie-services-table th:nth-child(5),
.omie-services-table td:nth-child(5),
.omie-services-table th:nth-child(6),
.omie-services-table td:nth-child(6) {
  width: 140px;
  text-align: center;
}

.omie-services-table th:nth-child(7),
.omie-services-table td:nth-child(7) {
  width: 86px;
  text-align: right;
}

.omie-history-table th:first-child,
.omie-history-table td:first-child {
  width: 170px;
  white-space: nowrap;
}

.omie-history-table th:nth-child(2),
.omie-history-table td:nth-child(2) {
  width: 220px;
}

.omie-history-table th:nth-child(4),
.omie-history-table td:nth-child(4),
.omie-history-table th:nth-child(5),
.omie-history-table td:nth-child(5),
.omie-history-table th:nth-child(6),
.omie-history-table td:nth-child(6) {
  width: 130px;
  text-align: center;
}

.omie-history-table th:nth-child(7),
.omie-history-table td:nth-child(7) {
  width: 150px;
}

.service-description {
  overflow-wrap: anywhere;
}

.boolean-badge {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 900;
}

.boolean-badge.yes {
  color: #155724;
  background: #dff3e6;
}

.boolean-badge.no {
  color: #7c2926;
  background: #f8d7da;
}

.boolean-badge.unknown {
  color: var(--muted);
  background: var(--line);
}

.edit-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 33, 36, 0.42);
}

.edit-dialog {
  display: grid;
  gap: 16px;
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(31, 33, 36, 0.18);
}

.edit-dialog-heading {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.edit-dialog-heading h2 {
  margin: 2px 0 0;
  font-size: 1.15rem;
}

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

.service-edit-context div {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.service-edit-context .span-full {
  grid-column: 1 / -1;
}

.service-edit-context span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.service-edit-context strong {
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.service-edit-form {
  display: grid;
  gap: 10px;
}

.switch-field {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  font-weight: 850;
}

.switch-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.form-error {
  margin: 0;
  border: 1px solid rgba(217, 83, 79, 0.28);
  border-radius: 8px;
  padding: 10px 12px;
  color: #7c2926;
  background: #f8d7da;
  font-size: 0.86rem;
  font-weight: 800;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.primary-action {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #fff;
  background: var(--teal);
  font-weight: 900;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.68;
}

.contract-product-name {
  display: grid;
  gap: 3px;
}

.contract-product-name strong {
  overflow-wrap: anywhere;
}

.contract-product-name small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.kit-equipment {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.kit-equipment span {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  color: #1e1555;
  background: var(--teal-soft);
  font-size: 0.78rem;
  font-weight: 850;
}

.equipment-type-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.equipment-type-card {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.equipment-type-card span {
  overflow-wrap: anywhere;
  font-weight: 850;
}

.equipment-type-card strong {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  color: #1e1555;
  background: var(--teal-soft);
  font-size: 0.9rem;
}

.timeline-list {
  display: grid;
  gap: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.timeline-note {
  margin-bottom: 14px;
  border: 1px solid rgba(240, 173, 78, 0.34);
  border-radius: 8px;
  padding: 12px 14px;
  color: #8a5a10;
  background: var(--amber-soft);
  font-size: 0.86rem;
  font-weight: 750;
}

.timeline-day {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 14px;
  padding: 0 0 18px;
}

.timeline-day:not(:last-child)::before {
  position: absolute;
  top: 22px;
  bottom: -2px;
  left: 9px;
  width: 2px;
  content: "";
  background: var(--line);
}

.timeline-marker {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  margin-top: 14px;
  border: 4px solid var(--teal-soft);
  border-radius: 50%;
  background: var(--teal);
}

.timeline-content {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.timeline-content header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.timeline-content span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.timeline-content h3 {
  margin: 4px 0 0;
  font-size: 1.1rem;
}

.timeline-content header strong {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  color: #1e1555;
  background: var(--teal-soft);
  font-size: 0.82rem;
}

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

.timeline-service {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
}

.timeline-service span {
  overflow-wrap: anywhere;
  color: var(--ink);
}

.timeline-service strong {
  flex: 0 0 auto;
  font-size: 1rem;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 170px auto;
  gap: 10px;
  align-items: center;
  width: min(100%, 680px);
}

.toggle-filter {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: #3d3e3f;
  background: #fff;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.toggle-filter input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.table-wrap {
  width: 100%;
  margin-top: 16px;
  overflow: auto;
}

.table-panel .table-wrap {
  max-height: min(58vh, 640px);
  overflow-y: auto;
}

.dashboard-table-panel .table-wrap {
  max-height: calc(100vh - 178px);
}

.table-panel thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

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

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

th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
  font-weight: 650;
}

tbody tr {
  cursor: default;
}

tbody tr:hover {
  background: rgba(65, 5, 222, 0.05);
}

@media (max-width: 1120px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .kpi-grid,
  .summary-head,
  .summary-layout,
  .timeline-layout,
  .license-comparison-grid,
  .summary-grid,
  .equipment-type-list,
  .timeline-services {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-12 {
    grid-column: 1 / -1;
  }

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

@media (max-width: 760px) {
  .login-layout {
    grid-template-columns: 1fr;
    padding: 18px 16px;
  }

  .login-panel {
    padding: 24px 20px;
  }

  .login-panel h1 {
    font-size: clamp(1.45rem, 9vw, 2rem);
  }

  .auth-name-grid {
    grid-template-columns: 1fr;
  }

  .workspace {
    gap: 14px;
    padding: 14px;
  }

  .timeline-workspace {
    height: auto;
    overflow: visible;
  }

  .panel {
    padding: 14px;
  }

  .topbar,
  .panel-heading,
  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .filters {
    width: 100%;
  }

  .dashboard-heading {
    flex-direction: row;
    align-items: center;
  }

  .dashboard-heading .topbar-actions {
    width: auto;
    margin-left: auto;
  }

  .topbar h1 {
    font-size: clamp(1.55rem, 9vw, 2.2rem);
    line-height: 1.05;
  }

  .dashboard-heading h1 {
    font-size: 1.18rem;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .ghost,
  .filters {
    grid-template-columns: 1fr;
  }

  .topbar-actions .ghost {
    flex: 1 1 140px;
  }

  .kpi-grid,
  .summary-head,
  .summary-layout,
  .timeline-layout,
  .summary-grid,
  .omie-service-filters,
  .service-edit-context,
  .summary-kv,
  .equipment-type-list,
  .timeline-services {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .timeline-summary-panel,
  .timeline-panel {
    overflow: visible;
  }

  .timeline-list {
    max-height: 62svh;
    overflow-y: auto;
    padding-right: 2px;
  }

  .rank-row {
    grid-template-columns: 32px minmax(0, 1fr) minmax(72px, auto);
  }

  .rank-company {
    grid-column: 2;
    grid-row: 1;
  }

  .rank-license-stack {
    grid-column: 3;
    grid-row: 1;
  }

  .rank-contract {
    white-space: normal;
  }

  .rank-row .action-group {
    grid-column: 2 / -1;
    grid-row: 3;
    justify-content: flex-start;
  }

  .timeline-content header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .license-comparison-card {
    min-height: 66px;
    padding: 10px;
  }

  .license-comparison-card span {
    font-size: 0.7rem;
  }

  .license-comparison-card strong {
    font-size: 1.25rem;
  }

  .segmented-control {
    display: flex;
    width: 100%;
    overflow-x: auto;
  }

  .segmented-control button {
    flex: 1 0 auto;
  }

  .omie-service-tabs {
    padding-bottom: 8px;
  }

  .omie-service-tabs button {
    flex: 0 0 auto;
    max-width: 220px;
  }

  .dashboard-table-panel .table-wrap {
    max-height: max(320px, calc(100svh - 292px));
  }

  .summary-table,
  .kits-table-wrap,
  .contract-products-wrap,
  .omie-services-wrap,
  .omie-history-wrap {
    overflow-x: hidden;
  }

  .summary-table,
  .kits-table-wrap,
  .contract-products-wrap {
    max-height: none;
  }

  .omie-services-wrap {
    max-height: max(300px, calc(100svh - 430px));
  }

  .omie-history-wrap {
    max-height: max(340px, calc(100svh - 230px));
  }

  .dashboard-table-panel table,
  .summary-table table,
  .kits-table,
  .contract-products-table,
  .omie-services-table,
  .omie-history-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  .dashboard-table-panel thead,
  .summary-table thead,
  .kits-table thead,
  .contract-products-table thead,
  .omie-services-table thead,
  .omie-history-table thead {
    display: none;
  }

  .dashboard-table-panel tbody,
  .summary-table tbody,
  .kits-table tbody,
  .contract-products-table tbody,
  .omie-services-table tbody,
  .omie-history-table tbody {
    display: grid;
    gap: 10px;
  }

  .dashboard-table-panel tr,
  .summary-table tr,
  .kits-table tr,
  .contract-products-table tr,
  .omie-services-table tr,
  .omie-history-table tr {
    display: grid;
    gap: 9px;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
  }

  .dashboard-table-panel td,
  .summary-table td,
  .kits-table td,
  .contract-products-table td,
  .omie-services-table td,
  .omie-history-table td {
    display: grid;
    grid-template-columns: minmax(92px, 35%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: auto;
    height: auto;
    min-height: 0;
    border-bottom: 0;
    padding: 0;
    text-align: right;
  }

  .dashboard-table-panel td::before,
  .summary-table td::before,
  .kits-table td::before,
  .contract-products-table td::before,
  .omie-services-table td::before,
  .omie-history-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
  }

  .dashboard-table-panel td[data-label="Porte"],
  .dashboard-table-panel td[data-label="Status"] {
    display: none;
  }

  .dashboard-table-panel td[data-label="Empresa"],
  .summary-table td:first-child,
  .kits-table td[data-label="Equipamentos"],
  .contract-products-table td[data-label="Produto"],
  .omie-services-table td[data-label="Empresa"],
  .omie-services-table td[data-label="Descrição"],
  .omie-history-table td[data-label="Empresa"],
  .omie-history-table td[data-label="Serviço"] {
    align-items: start;
    text-align: left;
  }

  .dashboard-table-panel td[data-label="Ações"],
  .omie-services-table td[data-label="Ações"] {
    grid-template-columns: 1fr;
    justify-items: end;
  }

  .dashboard-table-panel td[data-label="Ações"]::before,
  .omie-services-table td[data-label="Ações"]::before {
    display: none;
  }

  .dashboard-table-panel .action-group {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .kits-table td:last-child,
  .contract-products-table td:nth-child(3),
  .contract-products-table td:nth-child(4),
  .contract-products-table td:nth-child(5),
  .omie-services-table td:nth-child(4),
  .omie-services-table td:nth-child(5),
  .omie-services-table td:nth-child(6),
  .omie-services-table td:nth-child(7),
  .omie-history-table td:nth-child(4),
  .omie-history-table td:nth-child(5),
  .omie-history-table td:nth-child(6) {
    width: auto;
    text-align: right;
  }

  .kits-total-row td {
    background: transparent;
  }
}

@media (max-width: 420px) {
  .license-comparison-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-table-panel .table-wrap {
    max-height: max(300px, calc(100svh - 316px));
  }
}
