:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --sidebar: #101820;
  --sidebar-soft: #17232d;
  --text: #17212f;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #dde5ec;
  --line-strong: #c9d4de;
  --accent: #128c7e;
  --accent-strong: #075e54;
  --accent-soft: #e7f7f2;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --warn: #a15c07;
  --warn-soft: #fff3d6;
  --info-soft: #e8eef7;
  --shadow: 0 18px 42px rgba(16, 24, 40, .07);
  --shadow-soft: 0 6px 18px rgba(16, 24, 40, .045);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(18, 140, 126, .06), rgba(18, 140, 126, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 236px;
  height: 100vh;
  flex: 0 0 236px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px 14px;
  color: #f4fbf8;
  background:
    linear-gradient(180deg, rgba(18, 140, 126, .18), rgba(18, 140, 126, 0) 180px),
    var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, .08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 6px 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 28px rgba(18, 140, 126, .28);
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand strong {
  display: block;
  font-size: 17px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: rgba(244, 251, 248, .62);
  font-size: 12px;
}

.sidebar nav {
  display: grid;
  gap: 5px;
}

.sidebar a,
.ghost {
  width: 100%;
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(244, 251, 248, .8);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-weight: 650;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}

.sidebar a:hover,
.ghost:hover {
  background: rgba(255, 255, 255, .07);
  color: #fff;
}

.sidebar a.active {
  color: #fff;
  background: rgba(18, 140, 126, .22);
  border-color: rgba(18, 140, 126, .32);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
}

.user-chip > span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
  overflow: hidden;
}

.user-chip > span img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.user-chip strong,
.user-chip small {
  display: block;
}

.user-chip small {
  color: rgba(244, 251, 248, .58);
  font-size: 12px;
}

.content {
  min-width: 0;
  flex: 1;
  padding: 18px 20px 28px;
  overflow-x: auto;
}

.topbar {
  max-width: 1360px;
  margin: 0 auto 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 11px 14px;
  border: 1px solid rgba(221, 229, 236, .8);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow-soft);
}

.topbar strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.page-surface {
  max-width: 1360px;
  margin: 0 auto;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  min-height: 38px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin: 0;
}

h1,
h2 {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: #0f1728;
  font-size: 24px;
  line-height: 1.18;
  font-weight: 820;
}

h2 {
  margin: 20px 0 10px;
  color: #263245;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 800;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-soft);
}

.card.inline input,
.card.inline select {
  width: auto;
  min-width: 180px;
}

.card.inline span {
  color: var(--muted);
  font-weight: 700;
}

.grid .card {
  position: relative;
  overflow: hidden;
  min-height: 86px;
}

.grid .card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--accent);
}

.metric {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.value {
  margin-top: 7px;
  color: #101828;
  font-size: 25px;
  line-height: 1;
  font-weight: 850;
}

table {
  width: 100%;
  margin-bottom: 14px;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.table-panel {
  width: 100%;
  overflow-x: auto;
  margin-bottom: 14px;
  border-radius: var(--radius);
}

.table-panel table {
  min-width: 880px;
}

.accounts-table {
  min-width: 1280px;
}

th,
td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 12.5px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f7fa;
  color: #344054;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}

td {
  color: #243044;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:nth-child(even) td {
  background: #fbfcfd;
}

tbody tr:hover td {
  background: #f5fbf8;
}

td input,
td select {
  min-width: 78px;
  max-width: 170px;
  min-height: 34px;
  padding: 7px 8px;
}

.form {
  width: min(100%, 880px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px 14px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: #344054;
  font-size: 13px;
  font-weight: 780;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color .16s ease, box-shadow .16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(18, 140, 126, .7);
  box-shadow: 0 0 0 3px rgba(18, 140, 126, .12);
}

input[type="checkbox"] {
  width: auto;
  min-height: 0;
  accent-color: var(--accent);
}

input[type="file"] {
  padding: 8px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.button,
button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(18, 140, 126, .18);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.button:hover,
button:hover {
  background: var(--accent-strong);
  box-shadow: 0 10px 24px rgba(18, 140, 126, .24);
}

.button:active,
button:active {
  transform: translateY(1px);
}

.button.secondary,
button.secondary {
  background: #334155;
  box-shadow: 0 8px 18px rgba(51, 65, 85, .15);
}

.button.secondary:hover,
button.secondary:hover {
  background: #1f2937;
}

.button.danger,
button.danger {
  background: var(--danger);
  box-shadow: 0 8px 18px rgba(180, 35, 24, .16);
}

.button.danger:hover,
button.danger:hover {
  background: #8f1d15;
}

.ghost {
  min-height: 40px;
  justify-content: flex-start;
  background: transparent;
  color: rgba(244, 251, 248, .78);
  box-shadow: none;
}

.ghost:hover {
  background: rgba(255, 255, 255, .07);
  color: #fff;
  box-shadow: none;
}

.inline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

td.inline {
  max-width: 420px;
}

td.inline form {
  margin: 0;
}

td.inline button,
td.inline .button {
  min-height: 32px;
  padding: 7px 9px;
  font-size: 12px;
}

td.inline label {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.alert {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.alert.success {
  border-color: #b7ead2;
  background: #ecfdf3;
  color: #05603a;
}

.alert.error {
  border-color: #fecdca;
  background: var(--danger-soft);
  color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--info-soft);
  color: #344054;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

.badge.active,
.badge.connected,
.badge.sent,
.badge.positivo,
.badge.valid {
  background: #dcfae6;
  color: #067647;
}

.badge.paused,
.badge.pending,
.badge.pendente,
.badge.unknown,
.badge.checking,
.badge.pending_check,
.badge.processing {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.error,
.badge.failed,
.badge.negativo,
.badge.cancelled,
.badge.invalid,
.badge.disconnected {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.connecting,
.badge.neutro,
.badge.draft,
.badge.opening,
.badge.pairing,
.badge.timeout {
  background: #e8f4ff;
  color: #175cd3;
}

.badge.unknown {
  background: var(--info-soft);
  color: #344054;
}

.login {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login .form {
  width: min(420px, 92vw);
  margin: 0;
  box-shadow: var(--shadow);
  grid-template-columns: 1fr;
}

.login h1 {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.qr-code {
  width: 112px;
  height: 112px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.qr-code.large {
  width: 260px;
  height: 260px;
}

.qr-panel {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 8px 0 4px;
}

.qr-loading {
  display: none;
  justify-items: center;
  gap: 8px;
  padding: 18px;
  color: var(--muted);
}

.qr-loading strong {
  color: var(--text);
}

.qr-loading small,
.qr-status small {
  color: var(--muted);
}

.qr-status {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #d7efe9;
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(15, 23, 42, .48);
}

.modal.open {
  display: flex;
}

.modal-dialog {
  width: min(560px, 96vw);
  max-height: 90vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-dialog.wide {
  width: min(880px, 96vw);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
}

.modal-form {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.toggle-line {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex: none;
    border-right: 0;
  }

  .sidebar nav {
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  }

  .sidebar-footer {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .content {
    padding: 14px;
  }

  .topbar,
  .page-title {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  h1 {
    font-size: 22px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card,
  .form,
  .topbar {
    padding: 12px;
  }

  .form {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px;
    white-space: nowrap;
  }
}
