:root {
  --kvd-red: #fe0000;
  --kvd-btn: #dc3545;
  --kvd-btn-hover: #c82333;
  --ink: #212529;
  --muted: #6c757d;
  --line: #dee2e6;
  --surface: #f8f9fa;
  --link: #007bff;
  --good: #28a745;
  --good-bg: #e8f6ec;
  --font: Quicksand, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: #fff;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--kvd-red);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: min(1140px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.85rem 0;
}

.logo img {
  display: block;
  height: 52px;
  width: auto;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-meta a {
  color: var(--link);
}

header {
  border-bottom: 2px solid var(--kvd-red);
}

.page {
  width: min(1140px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 2.5rem;
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1.5rem;
  align-items: start;
}

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

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-meta {
    justify-content: flex-start;
  }
}

.panel {
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  padding: 1.25rem;
  background: #fff;
}

.panel-title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field.span-2 {
  grid-column: span 2;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
}

input:focus,
select:focus {
  outline: 0;
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.time-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.time-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.time-toggle label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  padding: 0.5rem;
  text-align: center;
  cursor: pointer;
  background: #fff;
}

.time-toggle input:checked + label {
  border-color: var(--kvd-red);
  color: var(--kvd-red);
  background: #fff5f5;
}

.actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

button {
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 0.25rem;
  padding: 0.5rem 1rem;
  background: #fff;
  color: var(--ink);
}

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

.btn-primary:hover {
  background: var(--kvd-btn-hover);
  border-color: var(--kvd-btn-hover);
}

.btn-ghost {
  border-color: var(--line);
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface);
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.results-head .panel-title {
  margin: 0;
}

.results-meta {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 0.25rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--surface);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
}

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

th,
td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

th {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td {
  border-bottom: 0;
}

.price {
  font-weight: 700;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.45rem;
  border-radius: 0.25rem;
  background: var(--good-bg);
  color: var(--good);
}

.row-best td.col-toggle {
  box-shadow: inset 3px 0 0 var(--kvd-red);
}

.footnote {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.col-toggle {
  width: 2.25rem;
  padding-left: 0.5rem !important;
  padding-right: 0.25rem !important;
}

.expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  flex: none;
}

.expand-btn:hover {
  border-color: var(--kvd-btn);
  color: var(--kvd-btn);
}

.expand-icon {
  display: inline-block;
  font-size: 0.85rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

.result-row.is-expanded .expand-icon,
.expand-btn[aria-expanded="true"] .expand-icon {
  transform: rotate(90deg);
}

.detail-row td {
  background: var(--surface);
  padding: 0 !important;
  border-bottom: 1px solid var(--line);
}

.detail-panel {
  padding: 0.85rem 1rem 0.95rem 2.75rem;
  font-size: 0.88rem;
  border-left: 3px solid var(--kvd-red);
  margin: 0.35rem 0.75rem 0.55rem;
  background: #fff;
  border-radius: 0.25rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--kvd-red);
}

.detail-panel strong {
  display: block;
  margin-bottom: 0.3rem;
}

.detail-panel ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink);
}

.detail-panel li + li {
  margin-top: 0.2rem;
}

.footer {
  border-top: 1px solid var(--line);
  background: #fff;
  margin-top: 1rem;
}

.footer-inner {
  width: min(1140px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-inner a {
  color: var(--muted);
  margin-left: 1rem;
}

.footer-inner a:hover {
  color: var(--kvd-red);
}

.admin-layout {
  max-width: 640px;
}

.status-msg {
  margin-top: 0.85rem;
  font-size: 0.9rem;
  color: var(--good);
  min-height: 1.2em;
}

.status-msg.error {
  color: var(--kvd-btn);
}

.supplier-row {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 0.85rem;
  align-items: end;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.supplier-row:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.supplier-row .name {
  font-weight: 700;
  font-size: 1rem;
}

.supplier-row .unit {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.input-with-suffix {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.input-with-suffix input {
  flex: 1;
}

.input-with-suffix span {
  color: var(--muted);
  font-weight: 600;
}
