
:root {
  --forest: #134e2a;
  --forest-dark: #0d3a1f;
  --green: #1e8747;
  --green-soft: #e9f7ee;
  --green-border: #a7ddb9;
  --cream: #f7f8f5;
  --white: #ffffff;
  --ink: #1a241e;
  --muted: #5d6c63;
  --border: #dfe6e1;
  --red: #dc2626;
  --red-soft: #fdecea;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--cream);
  color: var(--ink);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.86rem; }
.small-mb { margin: 0 0 10px; }
.mb { margin-bottom: 8px; }
.flex-1 { flex: 1; }
.full-width { width: 100%; }
.row-gap { display: flex; gap: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* LOGIN */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--forest); }
.login-card { width: min(360px, 100%); background: var(--white); padding: 24px; border-radius: 18px; text-align: center; }
.login-logo { width: 58px; height: 58px; border-radius: 14px; margin-bottom: 8px; }
.login-card h1 { margin: 0 0 4px; color: var(--forest); font-size: 1.4rem; }
.err-text { color: var(--red); font-size: 0.85rem; margin-top: 8px; }

/* HEADER & TABS */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 50;
  background: var(--forest); color: var(--white);
  display: flex; align-items: center; justify-content: space-between; padding: 0 14px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; }
.brand-name { font-weight: 800; font-size: 1.1rem; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.pill-link {
  color: var(--white); text-decoration: none; font-size: 0.8rem; font-weight: 700;
  background: rgba(255,255,255,0.16); padding: 6px 10px; border-radius: 8px;
}
.btn-ghost {
  background: transparent; color: var(--white); border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 0.8rem; cursor: pointer;
}

.tab-bar {
  position: fixed; top: 56px; left: 0; right: 0; height: 54px; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--white); border-bottom: 1px solid var(--border);
}
.tab-btn {
  position: relative; border: none; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; cursor: pointer; border-bottom: 3px solid transparent;
}
.tab-btn.active { color: var(--forest); background: var(--green-soft); border-bottom-color: var(--green); }
.badge {
  position: absolute; top: 4px; right: 12px; font-style: normal;
  background: var(--red); color: #fff; font-size: 0.65rem; font-weight: 800;
  padding: 1px 5px; border-radius: 999px;
}

.main-wrap { max-width: 720px; margin: 0 auto; padding: 122px 12px 32px; }
.view { display: none; }
.view.active { display: block; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
h2 { margin: 0; color: var(--forest); font-size: 1.18rem; }
h3 { margin: 0 0 8px; color: var(--forest); font-size: 0.96rem; }

.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}

.text-input {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 0.92rem; font-family: inherit;
}
.field-lbl { display: block; font-size: 0.82rem; font-weight: 700; color: var(--forest); margin-bottom: 10px; }
.field-lbl .text-input { margin-top: 4px; font-weight: 400; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; cursor: pointer; }

.btn {
  border: none; border-radius: 10px; padding: 10px 14px; font-weight: 700; font-size: 0.88rem;
  cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.btn-sm { padding: 7px 10px; font-size: 0.8rem; border-radius: 8px; }
.btn-green { background: var(--green); color: #fff; }
.btn-dark { background: var(--forest); color: #fff; }
.btn-red { background: var(--red-soft); color: var(--red); border: 1px solid #f5c2c0; }
.btn-outline { background: var(--white); color: var(--forest); border: 1.5px solid var(--border); }

/* KPI & METRICS */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi-card { background: var(--green-soft); border: 1.5px solid var(--green-border); border-radius: var(--radius); padding: 14px; }
.kpi-label { font-size: 0.76rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.kpi-val { font-size: 1.55rem; font-weight: 900; color: var(--forest); margin: 4px 0; }
.kpi-sub { font-size: 0.76rem; color: var(--ink); }

.metric-rows { display: flex; flex-direction: column; gap: 7px; }
.metric-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--cream); border-radius: 9px; font-size: 0.86rem;
}

/* QUEUE CARDS */
.q-card { background: var(--white); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px; }
.q-card.pending { border-color: var(--green-border); }
.q-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.q-tag { font-size: 0.7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--forest); text-transform: uppercase; }
.q-body { font-size: 0.9rem; line-height: 1.45; white-space: pre-wrap; margin: 8px 0 12px; }
.q-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.q-note { font-size: 0.78rem; color: var(--muted); margin-top: 8px; }

.pill { font-size: 0.76rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--green-soft); color: var(--forest); }
.badge-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.conn-badge { font-size: 0.78rem; font-weight: 700; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); }
.conn-badge.ok { background: var(--green-soft); color: var(--forest); border-color: var(--green-border); }
.conn-badge.off { background: var(--cream); color: var(--muted); }

/* MODAL & TOAST */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: grid; place-items: center; padding: 14px; }
.modal-card { width: min(440px, 100%); background: #fff; border-radius: 16px; padding: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.close-btn { border: 1px solid var(--border); background: #fff; border-radius: 8px; width: 32px; height: 32px; font-size: 1.2rem; cursor: pointer; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200;
  background: var(--forest-dark); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 0.86rem; font-weight: 700;
}
