:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;

  --badge-bg: #eff6ff;
  --badge-text: #1d4ed8;
  --badge-border: #bfdbfe;

  --price-text: #166534;

  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --warn-bg: #fef9c3;
  --warn-text: #854d0e;
  --err-bg: #fee2e2;
  --err-text: #991b1b;
  --neu-bg: #f1f5f9;
  --neu-text: #475569;

  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 6px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */

.layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

/* ── Top bar ── */

.top-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 52px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.logo-label {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 13px;
}

.meta-stat b {
  color: var(--text);
  font-weight: 600;
}

.meta-sep {
  color: var(--border);
}

/* ── Status badge ── */

.status-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--neu-bg);
  color: var(--neu-text);
}

.status-badge[data-status="ready"] {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.status-badge[data-status="auth_required"],
.status-badge[data-status="unconfigured"] {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.status-badge[data-status="error"] {
  background: var(--err-bg);
  color: var(--err-text);
}

/* ── Toolbar ── */

.toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.icon-search {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}

input[type="search"] {
  width: 100%;
  height: 36px;
  padding: 0 11px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

input[type="search"]:focus {
  border-color: var(--primary);
  background: #fff;
}

select {
  height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s;
  white-space: nowrap;
}

select:focus {
  border-color: var(--primary);
  background-color: #fff;
}

/* ── Alert ── */

.alert {
  margin: 12px 20px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid #fde68a;
  background: #fefce8;
  color: #854d0e;
  font-size: 13px;
  flex-shrink: 0;
}

/* ── Table ── */

.table-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  padding: 9px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #f8fafc;
}

/* Column sizing */

.col-model {
  width: 30%;
}

.col-provider {
  width: 12%;
}

.col-groups {
  width: 38%;
}

.col-price {
  width: 10%;
  text-align: right;
}

/* Model ID */

.model-id {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

/* Provider */

.provider-text {
  color: var(--muted);
  font-size: 12.5px;
}

/* Group badges */

.groups-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.group-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  border: 1px solid var(--badge-border);
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1;
}

.group-ratio {
  margin-left: 3px;
  opacity: 0.7;
  font-weight: 400;
  font-family: var(--mono);
  font-size: 10.5px;
}

/* Price */

.price-value {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--price-text);
  text-align: right;
  white-space: nowrap;
}

.price-dash {
  display: block;
  color: var(--border);
  text-align: right;
}

/* Empty state */

.empty {
  padding: 64px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.empty-body {
  margin: 0;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

/* ── Responsive ── */

@media (max-width: 640px) {
  .top-bar-right {
    display: none;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .search-field {
    flex: 1 0 100%;
  }

  .col-price {
    display: none;
  }

  .col-groups {
    width: 44%;
  }
}
