:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #e5e7eb;
  --line-dark: #cbd5e1;
  --primary: #dc2626;
  --primary-dark: #b91c1c;
  --primary-soft: #fef2f2;
  --green: #15803d;
  --green-soft: #ecfdf5;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.06);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  background:
    radial-gradient(circle at top left, rgba(220, 38, 38, 0.08), transparent 34rem),
    linear-gradient(180deg, #fff 0%, var(--bg) 34rem);
  color: var(--text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.container {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.topbar-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

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

.logo-box {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #111827 0%, var(--primary) 100%);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.04em;
  box-shadow: 0 14px 28px rgba(220, 38, 38, 0.18);
}

.brand strong,
.login-brand h1 {
  display: block;
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.brand small,
.login-brand p {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.data-pill, .user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.data-pill b { color: var(--text); }

.btn {
  border: 0;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.72; cursor: progress; }
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 13px 26px rgba(220, 38, 38, 0.18);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-soft {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}
.btn-soft:hover { border-color: var(--line-dark); background: var(--surface-2); }
.btn-ghost {
  color: var(--text);
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}
.btn-ghost:hover { background: #e2e8f0; }
.btn-danger {
  color: #fff;
  background: var(--red);
}
.full { width: 100%; }
.hidden { display: none !important; }

.app { padding: 28px 0 64px; }

.search-panel {
  display: grid;
  grid-template-columns: 0.78fr 1.22fr;
  align-items: center;
  gap: 24px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(226, 232, 240, 0.96);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-copy h1 {
  margin: 0;
  max-width: 520px;
  font-size: clamp(24px, 2.7vw, 34px);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.panel-copy p {
  margin: 14px 0 0;
  max-width: 540px;
  color: var(--muted);
  font-size: 14.5px;
}

.search-area { min-width: 0; }
.search-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px;
  background: #fff;
  border: 1px solid #dbe3ee;
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

.search-input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.search-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

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

.chips button {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 12.5px;
  font-weight: 500;
}
.chips button:hover { border-color: var(--primary); color: var(--primary); }

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  font-size: 14px;
}
select { min-height: 42px; padding: 0 12px; }
input { min-height: 42px; padding: 0 12px; }
textarea { padding: 11px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(220, 38, 38, 0.55);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.09);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.status-strip > div {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.status-strip b {
  display: block;
  font-size: 20px;
  line-height: 1;
  letter-spacing: -0.035em;
}
.status-strip span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.result-toolbar {
  margin: 28px 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}
.result-toolbar h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.035em;
}
.result-toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14.5px;
}
#resultCount {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.result-grid {
  display: grid;
  gap: 12px;
}

.result-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.result-card.top-match {
  border-color: rgba(220, 38, 38, 0.28);
  box-shadow: 0 18px 40px rgba(220, 38, 38, 0.08);
}

.result-kicker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 7px;
}
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 400;
}
.tag-match { background: var(--primary-soft); color: var(--primary-dark); }
.stock-available { background: var(--green-soft); color: var(--green); }
.stock-out_of_stock { background: var(--red-soft); color: var(--red); }
.stock-pre_order { background: var(--amber-soft); color: var(--amber); }

.result-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.035em;
}
.battery-line {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.battery-line strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.meta-grid span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid #edf2f7;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 12.5px;
  font-weight: 500;
}
.meta-grid b { color: #111827; font-weight: 600; }
.row-note {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.card-actions {
  min-width: 156px;
  display: grid;
  align-content: center;
  gap: 8px;
}
.card-actions .btn { width: 100%; }

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 220px;
  padding: 34px;
  border: 1px dashed #cbd5e1;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
}
.empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #f1f5f9;
  color: #334155;
  font-size: 26px;
  font-weight: 600;
}
.empty-state h3 {
  margin: 14px 0 6px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.empty-state p {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
}

.admin-panel {
  margin-top: 26px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-sm);
}
.admin-panel summary {
  padding: 18px 20px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 16px;
  padding: 0 18px 18px;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head.compact { margin-bottom: 12px; }
.section-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.section-head p, .help-text {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.battery-form label, .login-form label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 12.5px;
  font-weight: 600;
}
.form-row {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}
.form-row.two { grid-template-columns: 1fr 1fr; }
.form-row.three { grid-template-columns: repeat(3, 1fr); }
.battery-form > label { margin-bottom: 10px; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.import-card form { display: grid; gap: 10px; }
.import-card .btn { margin-top: 10px; }
.checkline {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
  color: var(--muted) !important;
  font-size: 13px !important;
  line-height: 1.35;
}
.checkline input { width: auto; min-height: auto; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: min(420px, calc(100% - 40px));
  padding: 12px 16px;
  border-radius: 14px;
  background: #111827;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
}

.alert {
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
}
.alert-danger { background: var(--red-soft); color: var(--red); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top right, rgba(220, 38, 38, 0.12), transparent 26rem),
    linear-gradient(135deg, #f8fafc 0%, #fff 48%, #f1f5f9 100%);
}
.login-shell { width: min(440px, calc(100% - 32px)); }
.login-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-copy { margin: 24px 0 18px; }
.login-copy h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1.16;
  font-weight: 600;
  letter-spacing: -0.04em;
}
.login-copy p {
  margin: 9px 0 0;
  color: var(--muted);
}
.login-form { display: grid; gap: 12px; margin-top: 14px; }

@media (max-width: 920px) {
  .search-panel { grid-template-columns: 1fr; padding: 22px; gap: 20px; }
  .status-strip { grid-template-columns: repeat(2, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  body { font-size: 15px; }
  .container { width: min(100% - 24px, 1160px); }
  .topbar-inner { min-height: 64px; }
  .brand small, .data-pill { display: none; }
  .user-chip { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .top-actions { gap: 7px; }
  .btn { min-height: 40px; padding: 9px 12px; font-size: 13.5px; }
  .app { padding: 18px 0 44px; }
  .search-panel { border-radius: 22px; padding: 18px; }
  .panel-copy h1 { font-size: 26px; }
  .panel-copy p { font-size: 14.5px; }
  .search-box { grid-template-columns: 1fr; }
  .search-input { min-height: 50px; font-size: 17px; }
  .filters { grid-template-columns: 1fr; }
  .status-strip { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .status-strip > div { padding: 14px; }
  .status-strip b { font-size: 21px; }
  .result-toolbar { align-items: flex-start; margin-top: 22px; }
  .result-toolbar h2 { font-size: 21px; }
  .result-card { grid-template-columns: 1fr; padding: 16px; }
  .card-actions { min-width: 0; grid-template-columns: 1fr 1fr; }
  .card-actions .btn[data-edit] { grid-column: span 2; }
  .form-row.two, .form-row.three { grid-template-columns: 1fr; }
  .login-card { padding: 22px; border-radius: 22px; }
  .login-copy h2 { font-size: 25px; }
}

@media (max-width: 420px) {
  .status-strip { grid-template-columns: 1fr; }
  .top-actions .btn-ghost { padding-inline: 10px; }
  .logo-box { width: 38px; height: 38px; flex-basis: 38px; border-radius: 12px; }
  .brand strong { font-size: 17px; }
  .card-actions { grid-template-columns: 1fr; }
  .card-actions .btn[data-edit] { grid-column: auto; }
}


/* V4.1 typography refinement: smaller text and standard supported weights only */
body { font-size: 14.5px; }
.brand strong, .login-brand h1 { font-weight: 600; }
.brand small, .login-brand p { font-weight: 400; }
.panel-copy h1 { font-weight: 600; letter-spacing: -0.032em; }
.result-toolbar h2,
.result-card h3,
.section-head h2,
.empty-state h3,
.login-copy h2 { font-weight: 600; }
.btn,
.data-pill,
.user-chip,
.tag,
.meta-grid span,
.alert,
.toast { font-weight: 600; }
.search-input { font-size: 16px; font-weight: 500; }
.search-input::placeholder { font-weight: 400; }
.chips button { font-size: 12.5px; font-weight: 500; }
.battery-line { font-size: 13px; font-weight: 500; }
.battery-line strong { font-size: 17px; font-weight: 600; }
input, select, textarea { font-size: 14px; }
.status-strip b { font-size: 20px; font-weight: 600; }
.status-strip span { font-size: 12.5px; font-weight: 500; }
.result-card { padding: 16px; }
@media (max-width: 680px) {
  body { font-size: 14px; }
  .panel-copy h1 { font-size: 23px; }
  .panel-copy p { font-size: 13.5px; }
  .search-input { min-height: 48px; font-size: 15.5px; }
  .result-toolbar h2 { font-size: 19px; }
  .result-card h3 { font-size: 17px; }
  .battery-line strong { font-size: 16px; }
}
