:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --text: #0f172a;
  --muted: #667085;
  --border: #dfe7f0;
  --accent: #2563eb;
  --accent-2: #0f766e;
  --danger: #b42318;
  --warning: #b54708;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.06), 0 10px 28px rgba(15, 23, 42, 0.05);
  --app-height: 100dvh;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-tap-highlight-color: rgba(23, 109, 93, 0.14);
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
}

button,
input,
select,
textarea {
  font: inherit;
  touch-action: manipulation;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 10;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(23, 109, 93, 0.6);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: var(--app-height);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, #0f172a, #1e293b);
  color: #fff;
  font-weight: 750;
}

.brand-title {
  font-size: 16px;
  font-weight: 750;
}

.brand-subtitle,
.muted {
  color: var(--muted);
  font-size: 12px;
}

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

.nav-item {
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.footer-value {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 760;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 14px;
  margin-bottom: 14px;
  align-items: start;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: 0;
  text-wrap: balance;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
}

.insights {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 8px;
  min-width: 280px;
}

.insight {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.insight span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.insight strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.search,
.select,
.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.search,
.select {
  height: 42px;
  padding: 0 13px;
  font-size: 14px;
}

.search:focus-visible,
.select:focus-visible,
.field input:focus-visible,
.field textarea:focus-visible {
  border-color: rgba(23, 109, 93, 0.55);
  box-shadow: 0 0 0 3px rgba(23, 109, 93, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(500px, 1fr) 410px;
  gap: 14px;
  align-items: start;
}

.table-panel,
.detail {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-head,
.tender-row {
  display: block;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.list-toolbar strong {
  font-size: 14px;
}

.list-toolbar span {
  margin-left: 6px;
  color: var(--muted);
  font-size: 13px;
}

.table-head {
  display: none;
}

.tender-rows {
  max-height: calc(100vh - 172px);
  overflow: auto;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.tender-row {
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: 104px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.tender-row:hover,
.tender-row.active {
  border-color: rgba(37, 99, 235, 0.2);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.row-metrics {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 7px;
  margin-top: 10px;
}

.metric-pill {
  min-width: 0;
  padding: 8px 9px;
  border-radius: 10px;
  background: #f8fafc;
}

.metric-pill span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.metric-pill strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.drug {
  display: block;
  max-width: 100%;
  font-weight: 760;
  font-size: 13px;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.reg {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.badge.go {
  border-color: rgba(15, 118, 110, 0.25);
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent-2);
}

.badge.maybe {
  border-color: rgba(148, 98, 0, 0.3);
  background: rgba(148, 98, 0, 0.1);
  color: var(--warning);
}

.badge.no-go,
.badge.reject {
  border-color: rgba(180, 35, 24, 0.28);
  background: rgba(180, 35, 24, 0.09);
  color: var(--danger);
}

.badge-cell {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.status-chip {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.detail {
  position: sticky;
  top: 22px;
  max-height: calc(100vh - 44px);
  overflow: auto;
}

.detail-header {
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.detail-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.16;
  text-transform: uppercase;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.metric {
  padding: 12px;
  border-radius: 10px;
  background: #f8fafc;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.section h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.summary {
  margin: 0;
  color: #2d3932;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

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

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

.mobile-detail-bar {
  display: none;
}

.icon-btn {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 740;
}

.field input,
.field textarea {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
}

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

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
  cursor: pointer;
}

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

.btn.compact {
  width: auto;
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.btn.reject {
  color: var(--danger);
}

.empty-state,
.loading,
.error {
  padding: 28px;
  color: var(--muted);
}

.empty-title {
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 760;
}

.link {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 650;
}

.link:hover {
  text-decoration: underline;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    padding: 12px;
  }

  .nav {
    display: flex;
  }

  .sidebar-footer {
    display: none;
  }

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

  .detail {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  body {
    background:
      radial-gradient(circle at 10% -5%, rgba(37, 99, 235, 0.12), transparent 32%),
      var(--bg);
  }

  .app {
    display: block;
    min-height: var(--app-height);
    padding-bottom: var(--safe-bottom);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    gap: 10px;
    padding: calc(8px + var(--safe-top)) 14px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(14px);
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 13px;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-subtitle {
    display: none;
  }

  .nav,
  .sidebar-footer {
    display: none;
  }

  .main {
    padding: 12px 12px 18px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: 22px;
  }

  .topbar p {
    margin-top: 4px;
    font-size: 13px;
  }

  .top-actions {
    display: grid;
    min-width: 0;
    gap: 7px;
    padding: 7px;
    border-radius: 14px;
  }

  .search,
  .select {
    height: 38px;
    font-size: 13px;
  }

  .insights {
    min-width: 0;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
  }

  .insight {
    padding: 8px 9px;
    border-radius: 12px;
  }

  .insight span {
    font-size: 10px;
  }

  .insight strong {
    font-size: 16px;
  }

  .table-head {
    display: none;
  }

  .workspace {
    display: block;
  }

  .table-panel,
  .detail {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    overflow: visible;
  }

  .detail {
    display: none;
    max-height: none;
  }

  body.detail-open .table-panel,
  body.detail-open .topbar {
    display: none;
  }

  body.detail-open .detail {
    display: block;
  }

  .mobile-detail-bar {
    position: sticky;
    top: calc(47px + var(--safe-top));
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0 10px;
    background: rgba(245, 247, 251, 0.95);
    color: var(--muted);
    font-size: 13px;
    font-weight: 720;
  }

  .list-toolbar {
    padding: 8px 2px;
    border-bottom: 0;
  }

  .list-toolbar span {
    display: block;
    margin: 2px 0 0;
  }

  .tender-rows {
    max-height: none;
    display: grid;
    gap: 8px;
    overflow: visible;
    padding: 0;
  }

  .tender-row {
    display: block;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    content-visibility: visible;
    contain-intrinsic-size: auto;
    box-shadow: var(--shadow-soft);
  }

  .tender-row.active {
    background: var(--surface);
  }

  .drug {
    font-size: 13px;
    line-height: 1.22;
  }

  .reg {
    font-size: 11px;
  }

  .badge-cell {
    align-self: start;
    display: grid;
    justify-items: end;
    gap: 5px;
  }

  .row-metrics {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 9px;
  }

  .metric-pill {
    padding: 7px;
  }

  .metric-pill strong {
    font-size: 11px;
  }

  .badge {
    min-width: 54px;
    height: 24px;
    padding: 0 7px;
    font-size: 10px;
  }

  .status-chip {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
  }

  .detail-header,
  .section,
  .metric-grid {
    padding-left: 0;
    padding-right: 0;
  }

  .detail-header {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .section {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .detail-title {
    font-size: 19px;
    line-height: 1.22;
  }

  .detail-meta {
    gap: 6px;
  }

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

  .metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .metric {
    padding: 9px;
  }

  .metric-value {
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  .button-row {
    padding-top: 10px;
    background: var(--surface);
  }

  .btn {
    height: 40px;
  }
}
