:root {
  --bg: #0f1210;
  --bg-panel: #171b18;
  --bg-panel-2: #1e231f;
  --border: #2a322b;
  --text: #e7e9e4;
  --text-dim: #9aa39b;
  --accent: #c9a227;
  --accent-dim: #8a7020;
  --danger: #c0453a;
  --ok: #4a8f5c;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--accent);
}

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.auth-wrap {
  max-width: 380px;
  margin: 10vh auto 0;
  padding: 0 20px;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-decoration: none;
  font-size: 1.1rem;
}

.brand small {
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 8px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}

h1, h2, h3 {
  font-weight: 600;
  margin-top: 0;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input, button, textarea {
  font-family: inherit;
  font-size: 0.95rem;
}

input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

input:focus {
  outline: none;
  border-color: var(--accent-dim);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 600;
}

button.primary {
  background: var(--accent);
  color: #16190f;
}

button.primary:hover {
  background: #ddb52f;
}

button.secondary {
  background: var(--bg-panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover {
  border-color: var(--accent-dim);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 4px 10px;
  font-size: 0.8rem;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 10px;
  min-height: 1em;
}

.hint {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 6px;
}

.stat-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.stat {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  flex: 1;
  min-width: 180px;
}

.stat .label {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.autocomplete {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.autocomplete-list.open {
  display: block;
}

.autocomplete-item {
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.autocomplete-item .info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.autocomplete-item:hover, .autocomplete-item.active {
  background: var(--bg-panel);
}

.add-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.add-row .autocomplete {
  flex: 3;
}

.add-row .qty {
  flex: 1;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.tag.exact {
  background: rgba(74, 143, 92, 0.18);
  color: var(--ok);
}

.tag.fuzzy {
  background: rgba(201, 162, 39, 0.18);
  color: var(--accent);
}

.tag.unmatched {
  background: rgba(192, 69, 58, 0.18);
  color: var(--danger);
}

.upload-drop {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  color: var(--text-dim);
}

.item-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  image-rendering: pixelated;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  object-fit: contain;
}

.item-icon.sm {
  width: 28px;
  height: 28px;
}

#review-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

.review-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel-2);
  min-width: 0;
}

.review-item .review-body {
  flex: 1;
  min-width: 0;
}

.review-item .review-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.review-item .extracted-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-item .review-footer {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.review-item .review-footer .qty {
  width: 90px;
  flex-shrink: 0;
}

.review-item .review-footer button {
  flex-shrink: 0;
}

.muted {
  color: var(--text-dim);
}

.hidden {
  display: none;
}

.icon-hidden {
  visibility: hidden;
}

.mt-14 {
  margin-top: 14px;
}

.mt-6 {
  margin-top: 6px;
}

.mt-20 {
  margin-top: 20px;
}

.stat .value.compact {
  font-size: 1rem;
}

.footer-note {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 30px;
  text-align: center;
}
