:root {
  --bg: #0f1512;
  --panel: #16201b;
  --border: #26332c;
  --text: #e8efe9;
  --muted: #93a69a;
  --accent: #34c07a;
  --accent-hover: #2ca86a;
  --danger: #e0655f;
  --radius: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.card h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.card h2 { margin: 0 0 4px; font-size: 18px; }

.sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}

input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

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

button {
  width: 100%;
  margin-top: 22px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #08130d;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.6; cursor: default; }

.error {
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand { font-weight: 700; letter-spacing: -0.02em; }

/* Logo has dark-green fills — a soft light chip keeps it legible on the dark theme. */
.logo-login, .logo-topbar {
  background: #f3f8f4;
  border-radius: 10px;
}

.logo-login {
  display: block;
  height: 64px;
  margin: 0 auto 14px;
  padding: 10px 16px;
}

.logo-topbar { height: 34px; padding: 4px 10px; }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; }

button.ghost {
  width: auto;
  margin: 0;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
}

button.ghost:hover { border-color: var(--accent); background: transparent; }

.content {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 20px;
}

.content-wide {
  max-width: none;
  margin: 20px 0;
  padding: 0 20px;
}

/* ---- Products sheet ---- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar h2 { margin: 0; font-size: 18px; }

.count { color: var(--muted); font-size: 12px; white-space: nowrap; }

.toolbar input[type='search'] {
  width: 240px;
  padding: 8px 10px;
  font-size: 13px;
}

.toolbar select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

button.primary {
  width: auto;
  margin: 0;
  padding: 8px 14px;
  font-size: 13px;
}

.sheet-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sheet-status.ok { color: var(--accent); }
.sheet-status.bad { color: var(--danger); }
.sheet-status.busy { color: var(--muted); }

.sheet-wrap {
  overflow: auto;
  max-height: calc(100vh - 150px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.sheet {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  width: max-content;
}

.sheet th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.sheet td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-width: 130px;
  max-width: 240px;
  max-height: 66px;
  overflow: hidden;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.sheet td.wide, .sheet th.wide { min-width: 320px; max-width: 420px; }

.sheet td[data-col]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--bg);
  max-height: none;
  max-width: 480px;
}

.sheet td.row-actions {
  min-width: 0;
  width: 34px;
  text-align: center;
  padding: 4px;
}

button.del {
  width: 24px;
  margin: 0;
  padding: 0 0 2px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.3;
}

button.del:hover {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

/* ---- Tabs ---- */

.tabs { display: flex; gap: 4px; margin-left: 16px; }

.tabs .tab {
  width: auto;
  margin: 0;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.tabs .tab:hover { background: transparent; color: var(--text); }
.tabs .tab.active { border-color: var(--border); background: var(--bg); color: var(--text); }

/* ---- Price tracker ---- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.tile .num { font-size: 24px; font-weight: 700; }
.tile .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tile.red .num { color: var(--danger); }
.tile.amber .num { color: #d9a441; }
.tile.green .num { color: var(--accent); }
.tile.grey .num { color: var(--muted); }

.trk-filters {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.fgroup { display: flex; flex-direction: column; gap: 4px; }

.fgroup label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.trk-filters select, .trk-filters input[type='number'] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
}

.trk-filters select[multiple] { min-width: 170px; }
.trk-filters input[type='number'] { width: 80px; }

.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); }
.chk input { accent-color: var(--accent); }

.trk-filters button.ghost { align-self: flex-end; }

.sheet.trk td { max-height: none; white-space: nowrap; }
.sheet.trk td.wide { white-space: normal; min-width: 260px; }
.sheet.trk td.r, .sheet.trk th.r { text-align: right; }
.sheet.trk td { min-width: 0; }
.sheet.trk a { color: var(--accent); text-decoration: none; }
.sheet.trk a:hover { text-decoration: underline; }
.sheet.trk th { cursor: pointer; user-select: none; }

td.pos { color: var(--accent); }
td.neg { color: var(--danger); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.b-red { background: rgba(224, 101, 95, 0.16); color: var(--danger); }
.b-amber { background: rgba(217, 164, 65, 0.16); color: #d9a441; }
.b-green { background: rgba(52, 192, 122, 0.16); color: var(--accent); }
.b-grey { background: rgba(147, 166, 154, 0.14); color: var(--muted); }
