:root {
  --bg: #0b0f0d;
  --surface: #131a17;
  --surface-2: #19231f;
  --line: #304039;
  --text: #f5f7f6;
  --muted: #a7b2ad;
  --green: #27c67a;
  --green-dark: #06402b;
  --amber: #f2b705;
  --red: #ff5a5f;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(145deg, rgba(6, 64, 43, 0.25), transparent 42%),
    var(--bg);
}

button, input, select { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(242, 183, 5, 0.42);
  outline-offset: 2px;
}

.shell { min-height: 100vh; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 28px;
  padding: 28px;
}

.brand {
  color: var(--text);
  font-size: 25px;
  font-weight: 800;
}

.brand::after { content: ""; color: var(--green); }

.login-view > .brand { text-align: center; font-size: 32px; }

.login-panel {
  width: min(420px, calc(100vw - 40px));
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(19, 26, 23, 0.96);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 28px; font-size: 30px; line-height: 1.14; }
h2 { margin-bottom: 0; font-size: 23px; }

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface-2);
}

input { padding: 0 14px; }
select { min-width: 230px; padding: 0 38px 0 13px; }

button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #07120d;
  background: var(--green);
  font-weight: 800;
}

button:hover { filter: brightness(1.08); }
button:disabled { cursor: not-allowed; opacity: 0.45; }
.login-panel button { width: 100%; margin-top: 18px; }
.secondary { border-color: var(--line); color: var(--text); background: var(--surface-2); }
.quiet { color: var(--muted); background: transparent; }
.danger { border-color: rgba(255, 90, 95, 0.45); color: #ffd9da; background: rgba(255, 90, 95, 0.12); }

.form-error { min-height: 20px; margin: 14px 0 0; color: var(--red); font-size: 13px; }

.dashboard { width: min(1500px, 100%); margin: 0 auto; padding: 0 28px 60px; }

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }

.status-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-online { border-color: rgba(39, 198, 122, 0.48); color: var(--green); background: rgba(39, 198, 122, 0.1); }
.status-offline { border-color: rgba(255, 90, 95, 0.5); color: #ff9a9d; background: rgba(255, 90, 95, 0.1); }
.status-checking { color: var(--amber); }

.toolbar {
  min-height: 92px;
  display: grid;
  grid-template-columns: auto minmax(220px, 360px) 1fr;
  align-items: center;
  gap: 14px;
}

.toolbar label { margin: 0; }
.last-refresh { justify-self: end; color: var(--muted); font-size: 12px; }

.provision-section {
  margin-bottom: 28px;
  padding: 22px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--surface);
}

.provision-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.provision-field { min-width: 0; }
.provision-field label { margin-bottom: 7px; }
.provision-form button { min-height: 48px; }

.activation-result {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.activation-result span,
.activation-result p { color: var(--muted); font-size: 12px; }
.activation-result strong { display: block; margin-top: 5px; overflow-wrap: anywhere; }
.activation-result code {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid rgba(39, 198, 122, 0.45);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface-2);
  font-size: 15px;
  overflow-wrap: anywhere;
  user-select: all;
}
.activation-result p { grid-column: 2 / -1; margin: -3px 0 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 42px;
}

.stats article {
  min-height: 112px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stats span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stats strong { font-size: 36px; line-height: 1; }
.stats .positive { color: var(--green); }
.stats .negative { color: var(--red); }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading > span { color: var(--muted); font-size: 13px; }

.reports-section { margin-bottom: 42px; }

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.report-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--surface);
}

.report-card.is-pending { border-left-color: var(--amber); }
.report-card.needs-attention { border-left-color: var(--red); }

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.report-store { margin: 0 0 5px; font-size: 18px; }
.report-date, .report-footer { margin: 0; color: var(--muted); font-size: 12px; }
.report-state { color: var(--green); font-size: 11px; font-weight: 800; text-align: right; }
.is-pending .report-state { color: var(--amber); }
.needs-attention .report-state { color: var(--red); }

.report-values {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.report-value {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.report-value span { display: block; min-height: 30px; color: var(--muted); font-size: 11px; }
.report-value strong { display: block; margin-top: 7px; font-size: 16px; overflow-wrap: anywhere; }
.report-footer { margin-top: 16px; }

.device-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.device-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.device-card.is-online { border-left: 4px solid var(--green); }
.device-card.is-offline { border-left: 4px solid var(--red); }

.device-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.device-name { margin: 0 0 5px; font-size: 18px; }
.device-store { margin: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.device-state { font-size: 12px; font-weight: 800; }
.device-state.online { color: var(--green); }
.device-state.offline { color: #ff9a9d; }

.device-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}

.device-meta div { min-width: 0; }
.device-meta dt { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.device-meta dd { margin: 0; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }

.command-row { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.command-row button { min-height: 38px; padding: 0 12px; font-size: 12px; }

.empty-state {
  padding: 42px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.notice {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: min(420px, calc(100vw - 44px));
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 7px;
  color: var(--text);
  background: #101713;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.notice.error { border-left-color: var(--red); }

@media (max-width: 900px) {
  .device-grid, .report-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr 1fr; }
  .report-values { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .activation-result { grid-template-columns: 1fr; }
  .activation-result p { grid-column: 1; }
}

@media (max-width: 680px) {
  .dashboard { padding: 0 16px 40px; }
  .topbar { align-items: flex-start; padding: 18px 0; }
  .topbar-actions { justify-content: flex-end; flex-wrap: wrap; }
  .status-pill { order: -1; }
  .toolbar { grid-template-columns: 1fr; padding: 18px 0 24px; }
  .toolbar select { min-width: 0; }
  .provision-section { padding: 18px; }
  .provision-form { grid-template-columns: 1fr; }
  .last-refresh { justify-self: start; }
  .stats { grid-template-columns: 1fr; gap: 9px; }
  .stats article { min-height: 82px; padding: 17px; }
  .device-card { padding: 18px; }
  .report-card { padding: 18px; }
  .device-meta { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  button, .device-card { transition: filter 150ms ease, border-color 150ms ease, transform 150ms ease; }
  button:active { transform: translateY(1px); }
}
