:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #eef3f5;
  --ink: #182025;
  --muted: #68747d;
  --line: #dce3e6;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --accent: #d97706;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(21, 32, 43, 0.08);
  font-family: Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.title-group {
  min-width: 170px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
}

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

.search-box,
.select-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-box input,
.select-box select {
  height: 42px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

.search-box input {
  width: min(420px, 64vw);
}

.select-box select {
  width: 150px;
}

.search-box input:focus,
.select-box select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--brand-strong);
}

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

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

.stats-grid article {
  min-height: 86px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

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

.table-panel,
.details-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-status {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 12px;
}

td {
  font-size: 13px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f4faf9;
}

tbody tr.is-selected {
  background: #e8f4f2;
}

.user-cell {
  display: grid;
  gap: 3px;
}

.user-cell strong {
  font-size: 14px;
}

.subtext {
  color: var(--muted);
  font-size: 12px;
  direction: ltr;
  text-align: right;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.green {
  background: #dff3ed;
  color: #0f5f52;
}

.badge.orange {
  background: #fff0d9;
  color: #8a4b05;
}

.badge.red {
  background: #fde6e3;
  color: var(--danger);
}

.row-button {
  min-width: 72px;
  height: 32px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  cursor: pointer;
  font-weight: 700;
}

.row-button:hover {
  background: var(--brand);
  color: #fff;
}

.details-panel {
  position: sticky;
  top: 16px;
  min-height: 360px;
  overflow: hidden;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

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

.details-body {
  padding: 18px;
}

.details-header {
  display: grid;
  gap: 6px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.details-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

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

.details-section:last-child {
  border-bottom: 0;
}

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

.kv-list {
  display: grid;
  gap: 9px;
}

.kv-list div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.kv-list strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

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

.error-box {
  margin: 16px;
  padding: 14px;
  border: 1px solid #f0b7ae;
  border-radius: 8px;
  background: #fff4f2;
  color: var(--danger);
  line-height: 1.7;
}

@media (max-width: 980px) {
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .search-box {
    flex: 1 1 240px;
  }

  .search-box input,
  .select-box select {
    width: 100%;
  }

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

  .details-panel {
    position: static;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 14px;
  }

  h1 {
    font-size: 28px;
  }

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

  .stats-grid article {
    min-height: 74px;
    padding: 12px;
  }

  .stats-grid strong {
    font-size: 23px;
  }
}
