:root {
  --green: #0b3d2e;
  --green-2: #12664a;
  --accent: #1f9d6b;
  --ok: #1e7d43;
  --ok-bg: #e4f5ea;
  --warn: #9a6b00;
  --warn-bg: #fdf3d6;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --ink: #14201b;
  --muted: #5d6b64;
  --line: #dde5e0;
  --bg: #f4f7f5;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 18px rgba(11,61,46,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(120deg, var(--green), var(--green-2));
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { border-radius: 8px; background: #fff; padding: 2px; }
.topbar h1 { font-size: 1.05rem; margin: 0; line-height: 1.1; }
.topbar .sub { margin: 0; font-size: .72rem; opacity: .85; }
.topbar-actions { display: flex; gap: 8px; }

.btn {
  font: inherit; font-size: .85rem; cursor: pointer;
  border-radius: 10px; padding: 8px 12px; border: 1px solid transparent;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.28); }
.btn-ghost:hover { background: rgba(255,255,255,.24); }

main { max-width: 960px; margin: 0 auto; padding: 16px; }

/* Status bar */
.status-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius); margin-bottom: 16px;
  background: #eef2f0; border: 1px solid var(--line);
  position: sticky; top: 58px; z-index: 10;
}
.status-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.status-text { font-size: 1.15rem; font-weight: 800; }
.status-bar.ok   { background: var(--ok-bg);   border-color: #bfe6cd; }
.status-bar.bad  { background: var(--bad-bg);  border-color: #f2c4c0; }
.status-bar.info { background: var(--warn-bg); border-color: #efe0aa; }
.status-bar.ok   .status-text { color: var(--ok); }
.status-bar.bad  .status-text { color: var(--bad); }
.status-bar.info .status-text { color: var(--warn); }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card h2 {
  font-size: 1rem; margin: 0 0 4px; display: flex; align-items: center; gap: 10px;
}
.card h2 .num {
  display: inline-grid; place-items: center; width: 24px; height: 24px;
  background: var(--green); color: #fff; border-radius: 7px; font-size: .8rem; font-weight: 700;
}
.hint { color: var(--muted); font-size: .82rem; margin: 2px 0 12px; }
.hint.small { font-size: .76rem; margin-top: 10px; }
.small { font-size: .78rem; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 560px; }
.grid th, .grid td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--line); }
.grid thead th { background: #f0f4f2; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; }
.grid tfoot th { background: #f0f4f2; font-weight: 800; }
.num-col, td.num-col, th.num-col { text-align: right; white-space: nowrap; }
.grid tbody tr:hover { background: #f8faf9; }
.cat-tag { font-size: .7rem; color: var(--muted); }

input[type="number"], select {
  font: inherit; font-size: .85rem; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
  width: 100%; max-width: 100%;
}
input[type="number"] { width: 78px; text-align: right; }
td.qty-cell { width: 90px; }
select { min-width: 130px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* Row status coloring */
tr.row-incompat td { background: var(--bad-bg); }
tr.row-repeat td { background: var(--warn-bg); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.falta-bad { color: var(--bad); font-weight: 700; }

/* Metrics grid */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.metric {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fbfdfc;
}
.metric .k { font-size: .74rem; color: var(--muted); }
.metric .v { font-size: 1.15rem; font-weight: 800; margin-top: 2px; }
.metric.good .v { color: var(--ok); }
.metric.warn .v { color: var(--warn); }
.metric.bad .v  { color: var(--bad); }
.metric.wide { grid-column: 1 / -1; }

/* Alerts */
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alerts li {
  background: var(--warn-bg); border: 1px solid #efe0aa; color: #6b4e00;
  padding: 9px 12px; border-radius: 10px; font-size: .84rem;
  display: flex; gap: 8px;
}
.alerts li::before { content: "⚠"; }
.alerts li.danger { background: var(--bad-bg); border-color: #f2c4c0; color: #7d1a15; }
.alerts li.danger::before { content: "⛔"; }

/* Help */
.help summary { cursor: pointer; font-weight: 700; font-size: .95rem; }
.help-body { margin-top: 10px; font-size: .86rem; color: #2a352f; }
.help-body ul { margin: 8px 0; padding-left: 18px; }

.foot { text-align: center; color: var(--muted); font-size: .76rem; padding: 8px 16px 28px; }

@media (max-width: 560px) {
  .topbar h1 { font-size: .95rem; }
  .status-bar { top: 54px; }
}
