:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --paper: #f8fafc;
  --card: #ffffff;
  --gap: #c2410c;
  --gap-bg: #fff7ed;
  --sale: #047857;
  --sale-bg: #ecfdf5;
  --hidden: #475569;
  --hidden-bg: #f1f5f9;
  --conflict: #c2410c;
  --conflict-bg: #fff7ed;
  --draft: #1d4ed8;
  --draft-bg: #eff6ff;
  --accent: #047857;
  --blue: #2563eb;
  --bar: linear-gradient(90deg, #059669, #2563eb);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.5 "Segoe UI", sans-serif;
}

main { width: min(1120px, calc(100% - 32px)); margin: 0 auto 12px; }

.foot {
  display: flex;
  gap: 14px;
  align-items: baseline;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 12px;
}

.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

.login .foot { width: auto; margin: 4px 0 0; }

.news { display: grid; gap: 18px; }
.news article h2 { margin: 0 0 4px; font-size: 15px; }
.news article h2 .muted { margin-left: 8px; font-weight: 400; }
.news article p { margin: 0; }

.top {
  background: var(--bar) top / 100% 2px no-repeat, var(--card);
  border-bottom: 1px solid var(--line);
  margin: 0 0 22px;
  padding: 16px 16px 12px;
}

.top-inner {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  width: min(1120px, 100%);
  margin: 0 auto;
}

.activity {
  width: min(1120px, 100%);
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 13px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-logo { display: block; height: 68px; width: auto; }

.mark { width: 18px; height: 18px; flex: none; display: block; }

nav { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }

nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #475569;
  font-weight: 500;
  text-decoration: none;
  padding: 7px 12px 9px;
  border-radius: 8px;
}

nav a .mark { width: 16px; height: 16px; }

nav a .mark,
nav a .mark * {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

nav a .mark circle {
  fill: currentColor;
  stroke: none;
}

nav a:hover { background: #f1f5f9; color: var(--ink); }

nav a.on {
  background: #ecfdf5;
  color: var(--accent);
}

nav a.on::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

nav form.logout { margin: 0 0 0 6px; }

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.logout-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logout-btn:hover { background: var(--paper); color: var(--ink); }

.login { width: min(420px, calc(100% - 32px)); margin: 48px auto; }

.login .brand { margin-bottom: 18px; }

.login form { display: grid; gap: 12px; }

h2 { margin: 0 0 12px; font-size: 18px; color: var(--ink); }

h2.with-mark { display: flex; align-items: center; gap: 8px; }
h2.with-mark .mark { width: 22px; height: 22px; }

.summary { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.summary strong { font-size: 32px; letter-spacing: -0.04em; color: var(--gap); }
.gap-count { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 650; }
.gap-count .mark { width: 28px; height: 28px; }

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 10px;
}

.metric {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
  color: #334155;
  font-size: 13px;
  white-space: nowrap;
}

.metric strong { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  flex: none;
}

.dot.sale { background: #059669; }
.dot.hidden { background: #64748b; }
.dot.archive { background: #94a3b8; }
.dot.slip { background: var(--blue); }

.muted { color: var(--muted); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px 18px;
  margin: 16px 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.banner { padding: 10px 12px; border-radius: 8px; border-left: 4px solid transparent; }
.banner.ok { background: var(--sale-bg); color: var(--sale); border-left-color: var(--sale); }
.banner.bad { background: var(--gap-bg); color: var(--gap); border-left-color: var(--gap); }
.banner a { color: inherit; font-weight: 650; }
.backup-alert { margin: 0 0 16px; }

details.backup-settings { margin: 4px 0 8px; }

details.backup-settings > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

details.backup-settings > summary::-webkit-details-marker { display: none; }

details.backup-settings > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 12px;
  margin-right: 6px;
}

details.backup-settings[open] > summary::before { content: "▾"; }
details.backup-settings[open] > summary { margin-bottom: 12px; }

label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

input, select, button {
  font: inherit;
  color: var(--ink);
}

input[type="hidden"] { display: none; }

input, select {
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 8px 10px;
}

input:focus, select:focus {
  outline: 2px solid #dbeafe;
  border-color: var(--blue);
}

#model-filter,
.finder input[name="q"] {
  border-radius: 999px;
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px 50%;
  background-size: 16px;
}

button {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 650;
}

button:hover { background: #065f46; }

button.plus {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 5px 12px 5px 10px;
}

button.plus::before {
  content: "+";
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

button.quiet,
a.quiet {
  background: var(--card);
  color: #334155;
  border: 1px solid var(--line);
  font-weight: 600;
}

a.quiet {
  display: inline-block;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

button.quiet:hover,
a.quiet:hover { background: var(--paper); }

.record, .split { display: grid; gap: 12px; }
.record { grid-template-columns: 1.4fr 0.8fr 0.8fr auto; align-items: end; }
.split { grid-template-columns: repeat(3, 1fr); }

.panel form { display: grid; gap: 10px; margin-bottom: 12px; }
.panel form.row { display: flex; gap: 8px; align-items: center; margin: 0; }
.panel form.row input { flex: 1; min-width: 0; }
.panel form.row input.short { width: 76px; flex: none; }
.panel form.row button { flex: none; }
.record { margin-bottom: 8px; }

code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: #475569;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px 6px;
}

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  vertical-align: top;
  padding: 12px 10px;
  border-bottom: 1px solid #eef2f6;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border-bottom: 1px solid var(--line);
}

tbody tr:hover td { background: #f8fafc; }

.model-title { display: block; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }

.model-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: #94a3b8;
  font-size: 12px;
}

.name-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.name-line .copy-name,
.name-line .gsmarena-search { flex: none; padding: 2px 8px; font-size: 12px; }
.name-line .copy-name.pressed,
.name-line .gsmarena-search.pressed,
.name-line .copy-name.pressed:hover,
.name-line .gsmarena-search.pressed:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.cell {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
}

.cell.gap { background: #ffedd5; color: #c2410c; box-shadow: inset 0 0 0 1px #fdba74; }
.cell.sale,
.cell.on_sale { background: var(--sale-bg); color: var(--sale); }
.cell.hidden { background: #f1f5f9; color: #475569; }
.cell.conflict { background: var(--conflict-bg); color: var(--conflict); box-shadow: inset 0 0 0 1px #fdba74; }
.cell.archived { background: #f1f5f9; color: #475569; }
.cell.off { background: #f8fafc; color: #94a3b8; font-weight: 500; }
.cell.draft { background: var(--draft-bg); color: var(--draft); }

.warn {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border: 1px solid #fdba74;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  font-size: 12px;
}

.annotation { white-space: pre-wrap; }
.price s { color: var(--muted); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: end;
  margin-bottom: 12px;
}

.filter { max-width: 320px; margin: 0; }

label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 15px;
}

label.check input {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  background: #fff center / 12px no-repeat;
  cursor: pointer;
}

label.check input:checked {
  border-color: var(--accent);
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.2 6.4 11 12.5 4.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

label.check input:focus-visible {
  outline: 2px solid #dbeafe;
  outline-offset: 2px;
}
.summary form { margin: 0; }

td form,
.panel td form { display: flex; gap: 8px; align-items: center; margin: 6px 0 0; }
td button, .rules button { padding: 4px 8px; font-size: 13px; }

.codes { list-style: none; padding: 0; margin: 0; }
.codes li { padding: 4px 0; }

.panel form.finder {
  grid-template-columns: 1fr auto;
  align-items: end;
  max-width: 520px;
}

.panel form.finder.with-status {
  grid-template-columns: 1fr auto auto;
  max-width: 760px;
}

.panel form.finder.with-status label.check { margin: 0 0 8px; }

.pager { display: flex; gap: 16px; margin-top: 12px; }

.panel form.finder.with-year {
  grid-template-columns: minmax(160px, 1fr) 110px auto auto;
  max-width: 760px;
}

.panel form.finder.picture-filters {
  grid-template-columns: 180px minmax(180px, 240px) auto;
  max-width: 680px;
}

details.faq {
  margin: 0 0 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

details.faq > summary {
  cursor: pointer;
  font-weight: 600;
}

.faq-body { max-width: 68ch; padding-top: 4px; }

.faq-body h3 { margin: 14px 0 4px; font-size: 15px; }

.faq-body p { margin: 0 0 8px; }

details.queue > summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
}

details.queue > summary::-webkit-details-marker { display: none; }

details.queue > summary::before { content: none; }

details.queue > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-right: 1.5px solid #94a3b8;
  border-bottom: 1.5px solid #94a3b8;
  transform: rotate(45deg) translateY(-2px);
  flex: none;
}

details.queue[open] > summary::after { transform: rotate(-135deg) translate(-1px, -1px); }

details.queue > summary h2 { margin: 0; flex: 1; }

details.queue[open] > summary { margin-bottom: 12px; }

.queue-count {
  font-weight: 650;
  color: #334155;
  background: #f1f5f9;
  border-radius: 999px;
  min-width: 1.6em;
  padding: 1px 8px;
  text-align: center;
}

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.actions form { display: inline-flex; margin: 0; }
.panel .actions form { display: inline-flex; margin: 0; }

.backup-actions { display: flex; gap: 14px; white-space: nowrap; }
.backup-actions a { color: var(--accent); font-weight: 600; }

.confirm {
  background: var(--gap-bg);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
}
.panel .confirm form { margin: 0; }
.confirm p { margin: 0 0 10px; }

.panel form.front-drop { display: grid; gap: 6px; margin: 0; justify-items: start; }
.front-cell { display: flex; gap: 6px; align-items: center; }
.rules input[readonly] { background: var(--paper); color: var(--muted); }
a.device-link { color: var(--accent); font-weight: 600; text-decoration: none; }
a.device-link:hover { text-decoration: underline; }
button.front-clear { padding: 0 7px; line-height: 1.2; font-size: 18px; }
.front-thumb { display: block; width: 72px; height: 72px; object-fit: contain; background: white; border: 1px solid var(--line); border-radius: 8px; }
.drop {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 108px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--paper);
}
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--accent); background: var(--sale-bg); }

@media (max-width: 800px) {
  .record, .split, .summary, .top-inner { display: block; }
  nav { margin-top: 12px; }
  .board-wrap { overflow-x: auto; }
  .panel form.finder.with-status,
  .panel form.finder.with-year,
  .panel form.finder.picture-filters { grid-template-columns: 1fr; }
}
