/* PoultryWinner Developer Console — v25 design.
   Field-green rail, pale ledger surface, one gold accent reserved for money. */

:root, [data-theme="light"] {
  --bg: #edf1ec;
  --bg-elevated: #ffffff;
  --bg-panel: #ffffff;
  --field: #f5f8f4;
  --border: #dbe3da;
  --border-strong: #c3cfc3;
  --text: #15211a;
  --muted: #5a6b60;
  --accent: #0b6b4d;
  --accent-dim: #0b6b4d;
  --accent-ink: #ffffff;
  --gold: #8f6100;
  --gold-fill: #f2b13a;
  --success: #1b7f4f;
  --warning: #a35f00;
  --danger: #b3382c;
  --rail: #073b2d;
  --rail-text: #bcd5c8;
  --rail-strong: #ffffff;
  --rail-hover: rgba(255,255,255,0.07);
  --rail-active: rgba(242,177,58,0.16);
  --radius: 12px;
  --nav-width: 232px;
  --bar-h: 64px;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1310;
  --bg-elevated: #121c17;
  --bg-panel: #121c17;
  --field: #0d1612;
  --border: #223128;
  --border-strong: #31453a;
  --text: #e5ede7;
  --muted: #8ea396;
  --accent: #4cc790;
  --accent-dim: #4cc790;
  --accent-ink: #072016;
  --gold: #f2b541;
  --gold-fill: #f2b541;
  --success: #4cc790;
  --warning: #e5a23a;
  --danger: #f0786b;
  --rail: #07120d;
  --rail-text: #9bb5a8;
  --rail-strong: #f1f6f3;
  --rail-hover: rgba(255,255,255,0.06);
  --rail-active: rgba(242,181,65,0.15);
  color-scheme: dark;
}

[data-accent="emerald"] { --accent: #0f766e; --accent-dim: #0f766e; }
[data-accent="violet"] { --accent: #6d4fd6; --accent-dim: #6d4fd6; }
[data-accent="amber"] { --accent: #a86a00; --accent-dim: #a86a00; }
[data-theme="dark"][data-accent="emerald"] { --accent: #4fd1c5; --accent-dim: #4fd1c5; }
[data-theme="dark"][data-accent="violet"] { --accent: #a99bf5; --accent-dim: #a99bf5; }
[data-theme="dark"][data-accent="amber"] { --accent: #f2b541; --accent-dim: #f2b541; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
code { font-size: 0.9em; background: var(--field); padding: 0.1em 0.35em; border-radius: 5px; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--gold-fill); outline-offset: 2px; }

/* ---------- buttons ---------- */
button {
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 10px;
  padding: 0.5rem 0.95rem;
  min-height: 40px;
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.12s, border-color 0.12s;
}
button:hover { background: var(--field); border-color: var(--accent); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost { background: transparent; }
button.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
button.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
button.secondary { width: 100%; background: transparent; }

/* ---------- forms ---------- */
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="date"], select, textarea {
  width: 100%;
  max-width: 100%;
  background: var(--field);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
label { display: block; color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 0.3rem; }

/* ---------- login ---------- */
#login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(300px, 1.05fr) minmax(340px, 1fr);
  background: var(--bg);
}
.login-brand {
  background: var(--rail);
  color: var(--rail-strong);
  padding: 3rem clamp(1.5rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand .mark { width: 104px; height: 104px; border-radius: 24px; }
.login-brand h2 { font-family: var(--font-display); font-size: clamp(1.9rem, 3.6vw, 2.9rem); line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 1rem; max-width: 14ch; font-weight: 700; }
.login-brand p { margin: 0; color: var(--rail-text); max-width: 38ch; }
.login-wrap { display: grid; place-items: center; padding: 2rem 1.25rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 0.35rem; font-family: var(--font-display); font-size: 1.7rem; letter-spacing: -0.02em; }
.login-card > p { margin: 0 0 1.4rem; color: var(--muted); }
.login-card form > * { margin-bottom: 0.9rem; }
.login-card .view-lead { font-size: 13px; }
#login-status { color: var(--danger); min-height: 1.2em; font-size: 13px; }
.login-card button.primary { width: 100%; min-height: 46px; }

/* ---------- shell ---------- */
#console-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
}
.app-body { display: contents; }

.sidebar {
  grid-column: 1;
  grid-row: 1 / 3;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  background: var(--rail);
  color: var(--rail-text);
  padding: 1.1rem 0.75rem 1.5rem;
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.2rem 0.5rem 1.2rem;
  color: var(--rail-strong);
}
.rail-brand .mark { width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; }
.rail-brand strong { display: block; font-family: var(--font-display); font-size: 1.05rem; letter-spacing: -0.01em; line-height: 1.15; }
.rail-brand span { display: block; font-size: 12px; color: var(--rail-text); }
.nav-group { margin-bottom: 1rem; }
.nav-group-title { font-size: 12px; color: var(--rail-text); opacity: 0.7; padding: 0.35rem 0.65rem; font-weight: 600; }
.sidebar .nav-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 40px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--rail-text);
  padding: 0.45rem 0.65rem;
  margin-bottom: 2px;
  font-weight: 500;
}
.sidebar .ico { width: 24px; text-align: center; font-size: 1.15rem; line-height: 1; flex-shrink: 0; }
.install-btn { display: flex; align-items: center; gap: 0.7rem; width: 100%; min-height: 40px; background: var(--rail-active); border: 0; border-radius: 9px; color: var(--rail-strong); padding: 0.45rem 0.65rem; font-weight: 600; }
.install-btn:hover { background: var(--rail-hover); border-color: transparent; }
.sidebar .nav-btn:hover { background: var(--rail-hover); color: var(--rail-strong); }
.sidebar .nav-btn.active { background: var(--rail-active); color: var(--rail-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--gold-fill); }

.app-header {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-left { display: flex; align-items: center; gap: 0.6rem; }
.app-header h1 { margin: 0; font-family: var(--font-display); font-size: 1.05rem; display: none; }
.header-mark { display: none; width: 30px; height: 30px; border-radius: 8px; }
.env-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.env-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold-fill); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold-fill) 28%, transparent); }
.session-meta { display: flex; align-items: center; gap: 0.6rem; }
#developer-role { font-size: 13px; color: var(--muted); text-transform: capitalize; }
.session-meta button { min-height: 36px; padding: 0.3rem 0.8rem; white-space: nowrap; }
.menu-toggle { display: none; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 0; }
.menu-toggle svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.main {
  grid-column: 2;
  grid-row: 2;
  padding: 1.6rem clamp(1rem, 3vw, 2.25rem) 3rem;
  max-width: 1180px;
  width: 100%;
}
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.14s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.view h2 { margin: 0 0 0.35rem; font-family: var(--font-display); font-size: clamp(1.6rem, 3vw, 2.1rem); letter-spacing: -0.025em; line-height: 1.12; font-weight: 700; }
.view-lead { margin: 0 0 1.1rem; color: var(--muted); font-size: 14px; max-width: 64ch; }
.view > .toolbar:first-of-type { margin-top: 0.4rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: flex-end; margin-bottom: 1rem; }
.toolbar .field { flex: 1 1 160px; min-width: 130px; max-width: 300px; }

/* ---------- figures strip ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.kpi { background: var(--bg-panel); box-shadow: 1px 1px 0 0 var(--border); padding: 1rem 1.15rem 1.05rem; display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 0.2rem; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .value.kpi-small { font-size: 1.25rem; line-height: 1.3; word-break: break-word; white-space: pre-line; }
.kpi.kpi-money .value { color: var(--gold); }

/* ---------- panels ---------- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}
.panel h3 { margin: 0 0 0.6rem; font-family: var(--font-display); font-size: 1.1rem; letter-spacing: -0.01em; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.9rem; }
.quick-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

/* ---------- status marks ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: transparent;
  color: var(--text);
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.badge-healthy::before, .badge-ok::before { background: var(--success); }
.badge-warning::before { background: var(--gold-fill); }
.badge-critical::before, .badge-fail::before { background: var(--danger); }
.badge-info::before { background: var(--accent); }
.badge-na::before { background: var(--border-strong); }
.badge-critical, .badge-fail { color: var(--danger); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
tbody tr:hover td { background: var(--field); }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap, .view > div[id$="-results"], #dashboard-recent, #analytics-by-country, #analytics-finance, #analytics-other { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table, .view > div[id$="-results"] table, #dashboard-recent table, #analytics-by-country table { min-width: 520px; }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.row-actions button { min-height: 32px; padding: 0.2rem 0.65rem; font-size: 13px; }

.status-line { color: var(--muted); margin: 0.4rem 0; min-height: 1.3em; font-size: 13.5px; }
.error-text { color: var(--danger); }
.success-text { color: var(--success); }
dl { margin: 0; display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: 0.4rem 0.9rem; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }
.details-panel { margin-top: 1rem; background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem 1.25rem; }
.details-panel h3 { margin: 1rem 0 0.5rem; font-family: var(--font-display); }
.details-panel h3:first-child { margin-top: 0; }
.check-row { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; align-items: baseline; padding: 0.65rem 0; border-bottom: 1px solid var(--border); }
.check-row .name { font-weight: 600; min-width: 150px; }
.check-meta { color: var(--muted); font-size: 13px; }
pre.details-json { white-space: pre-wrap; word-break: break-word; background: var(--field); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; font-size: 12px; margin: 0.4rem 0 0; }
.feature-matrix { width: 100%; font-size: 13px; }
.feature-on { color: var(--success); font-weight: 600; }
.feature-off { color: var(--muted); }

/* ---------- billing ---------- */
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; margin: 0 0 1.1rem; border-bottom: 1px solid var(--border-strong); }
.tab-btn { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; padding: 0.6rem 1rem; color: var(--muted); font-weight: 600; margin-bottom: -1px; }
.tab-btn:hover { background: transparent; color: var(--text); border-bottom-color: var(--border-strong); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--gold-fill); }
.check-field { display: flex; align-items: flex-end; padding-bottom: 0.6rem; }
.check-field label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--text); margin: 0; }
.price-input { width: 9.5rem; }
.cur-input { text-transform: uppercase; width: 5.5rem; }
.manage-plan-btn { margin: 1rem 0.5rem 0 0; }

.nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(4, 14, 10, 0.55); z-index: 40; }
.nav-backdrop.open { display: block; }

@media (max-width: 820px) {
  #login-screen { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { padding: 1.6rem 1.4rem 1.5rem; flex-direction: row; align-items: center; gap: 1rem; }
  .login-brand .mark { width: 54px; height: 54px; flex-shrink: 0; border-radius: 14px; }
  .login-brand h2 { font-size: 1.35rem; margin: 0; max-width: none; }
  .login-brand p, .login-brand .brand-copy p { display: none; }
  .login-wrap { align-items: start; padding-top: 1.75rem; }

  #console-screen { grid-template-columns: minmax(0, 1fr); }
  .menu-toggle { display: inline-flex; }
  .app-header { grid-column: 1; padding: 0.55rem 1rem; }
  .app-header h1 { display: block; font-size: 1rem; }
  .header-left { min-width: 0; gap: 0.5rem; }
  .env-badge { font-size: 0; gap: 0; }
  .session-meta button { padding: 0.3rem 0.65rem; }
  #developer-role { display: none; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    grid-column: auto;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    width: min(290px, 86vw);
    height: 100dvh;
  }
  .sidebar.open { transform: translateX(0); }
  .main { grid-column: 1; padding: 1.1rem 1rem calc(2rem + env(safe-area-inset-bottom)); }
  dl { grid-template-columns: 1fr; gap: 0.1rem; }
  dt { margin-top: 0.5rem; font-size: 13px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 1.65rem; }
  .toolbar .field { max-width: none; flex-basis: 100%; }
  .toolbar button { flex: 1 1 auto; }
  .panel { padding: 1rem; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tab-btn { white-space: nowrap; }

}

@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none; }
  .sidebar { transition: none; }
}

td button { min-height: 32px; padding: 0.2rem 0.7rem; font-size: 13px; }
.view > .toolbar + .status-line { margin-top: -0.4rem; }

.glance { margin-bottom: 1.1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.attention-list { display: grid; gap: 0.5rem; }
.attention-item { display: flex; align-items: center; gap: 0.7rem; justify-content: flex-start; text-align: left; width: 100%; min-height: 46px; }
.attention-item .ico { font-size: 1.2rem; }
a { text-underline-offset: 2px; }

/* app problems */
.code-block { background: var(--surface-2, #f1f4f1); border: 1px solid var(--line, #d7ddd7); border-radius: 8px; padding: 10px; font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
details.panel > summary { cursor: pointer; font-weight: 600; }
