:root {
  --ink: #16213e;
  --ink-soft: #4a5578;
  --paper: #ffffff;
  --paper-muted: #f2f4f8;
  --line: #dde1ea;
  --go: #2d6a4f;
  --go-soft: #e6f2ec;
  --wait: #b8781e;
  --wait-soft: #fbeed9;
  --stop: #a83c34;
  --stop-soft: #f8e6e4;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper-muted);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: 32px;
}

.topbar {
  background: var(--ink);
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}

.topbar .sub {
  font-size: 12.5px;
  color: #b9c0d6;
  margin-top: 2px;
}

.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  position: absolute;
  top: 16px;
  right: 16px;
}

.conn-badge.online { background: var(--go-soft); color: var(--go); }
.conn-badge.offline { background: var(--stop-soft); color: var(--stop); }

.conn-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 0;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"] {
  width: 100%;
  padding: 12px 13px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
}

.field input:focus {
  outline: none;
  border-color: var(--ink-soft);
}

.field .hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.field .warn {
  font-size: 12.5px;
  color: var(--wait);
  margin-top: 6px;
  font-weight: 600;
}

.radio-group {
  display: flex;
  gap: 10px;
}

.radio-option {
  flex: 1;
  position: relative;
}

.radio-option input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.radio-option .box {
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-soft);
}

.radio-option input:checked + .box {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}

.btn-primary:active { opacity: 0.85; }

.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
  margin-top: 10px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 22px 0 10px;
  padding: 0 2px;
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--paper);
}

.entry-row .name {
  flex: 1;
  font-weight: 600;
  font-size: 14.5px;
}

.entry-row .sub {
  font-size: 12px;
  color: var(--ink-soft);
}

.status-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pending { background: var(--wait-soft); color: var(--wait); }
.status-success { background: var(--go-soft); color: var(--go); }
.status-rejected { background: var(--stop-soft); color: var(--stop); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 62, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-box {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 24px 20px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
}

.modal-box.result-pending { background: var(--wait-soft); color: var(--wait); }
.modal-box.result-success { background: var(--go-soft); color: var(--go); }
.modal-box.result-rejected { background: var(--stop-soft); color: var(--stop); }

.modal-box .big { font-size: 21px; margin-bottom: 8px; }

.modal-box .btn-primary {
  background: var(--ink);
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
  padding: 24px 0;
}

.setup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 62, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.setup-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  max-width: 360px;
  width: 100%;
}

.setup-box h2 { font-size: 16px; margin: 0 0 12px; }

/* ---- Dashboard ---- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-box .num {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.stat-box .label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
  font-weight: 600;
}

.stat-box.hero {
  grid-column: span 2;
  background: var(--ink);
  color: #fff;
}

.stat-box.hero .label { color: #b9c0d6; }
.stat-box.hero .num { font-size: 40px; }

table.device-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.device-table td, table.device-table th {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
