:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #162033;
  --muted: #647084;
  --line: #d9e0eb;
  --primary: #1456d9;
  --primary-dark: #0d3f9f;
  --danger: #c62828;
  --success: #147a3f;
  --shadow: 0 18px 45px rgba(25, 41, 70, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.app-logo {
  width: 86px;
  height: 64px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 4px;
}

h1, h2, p { margin: 0; }

h1 {
  color: var(--primary);
  font-size: clamp(34px, 6vw, 64px);
  letter-spacing: .08em;
  line-height: .95;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
  font-size: 15px;
}

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

.search-panel { margin-bottom: 18px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
  gap: 18px;
  align-items: start;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

h2 {
  font-size: 20px;
  color: var(--text);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  background: #fff;
  min-height: 110px;
}

input:focus, textarea:focus {
  outline: 2px solid rgba(20, 86, 217, .18);
  border-color: var(--primary);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  margin-top: 4px;
}

.check-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover { background: var(--primary-dark); }

button.secondary {
  background: #e8eef9;
  color: var(--primary-dark);
}

button.secondary:hover { background: #d9e5f7; }

button.danger {
  background: #ffe6e6;
  color: var(--danger);
}

button.danger:hover { background: #ffd3d3; }

.search-row, .open-row, .actions, .sync-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.sync-row {
  margin: 0 0 12px;
  flex-wrap: wrap;
}

.compact-actions {
  justify-content: flex-start;
  margin: 10px 0 4px;
}

.search-row input, .open-row input { flex: 1; }

.link-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.link-card, .saved-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.link-card {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 10px;
  align-items: center;
}

.link-card strong, .saved-card strong { display: block; font-size: 15px; }

.link-card a, .saved-card a {
  display: block;
  color: var(--primary);
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.plus-button {
  width: 42px;
  min-height: 42px;
  border-radius: 50%;
  font-size: 24px;
  padding: 0;
}

.item-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.item-list.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

.active-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.price-cell {
  gap: 4px;
}

.price-cell input {
  height: 38px;
}

.total-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
}

.total-box span {
  color: var(--muted);
  font-weight: 800;
}

.total-box strong {
  color: var(--primary-dark);
  font-size: 18px;
}

.active-item small, .saved-card small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.note-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef8f1;
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.saved-card .card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf3ff;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.status {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.barcode-preview {
  width: 100%;
  max-height: 240px;
  margin-top: 12px;
  border-radius: 8px;
  background: #111;
}

.hidden { display: none; }

@media (max-width: 920px) {
  .layout, .link-grid { grid-template-columns: 1fr; }
  .topbar, .search-row, .open-row, .actions { align-items: stretch; flex-direction: column; }
  .brand-wrap { align-items: flex-start; }
  .active-item { grid-template-columns: 1fr; }
  button { width: 100%; }
}
