:root {
  color-scheme: light;
  --navy: #17213f;
  --navy-2: #20315f;
  --blue: #17a9d7;
  --green: #00ad74;
  --ink: #1d2433;
  --muted: #667085;
  --line: #dce3ea;
  --soft: #f5f8fb;
  --white: #ffffff;
  --danger: #c2413b;
  --shadow: 0 18px 50px rgba(23, 33, 63, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(23, 169, 215, 0.08), transparent 30%),
    linear-gradient(315deg, rgba(0, 173, 116, 0.09), transparent 28%),
    var(--soft);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  align-items: center;
  gap: 56px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-block.compact {
  gap: 12px;
}

.brand-mark {
  width: 62px;
  height: 62px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 5px;
}

.brand-mark span {
  display: block;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, var(--green), var(--blue));
}

.brand-mark span:nth-child(1) {
  height: 34px;
}

.brand-mark span:nth-child(2) {
  height: 48px;
}

.brand-mark span:nth-child(3) {
  height: 62px;
  background: var(--navy);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--navy);
  letter-spacing: 0;
}

h1 {
  font-size: 42px;
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

.login-card,
.panel-card,
.side-panel,
.metric {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(220, 227, 234, 0.9);
  box-shadow: var(--shadow);
}

.login-card {
  display: grid;
  gap: 18px;
  padding: 28px;
  border-radius: 8px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--white);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 169, 215, 0.14);
}

.button {
  height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.primary {
  color: var(--white);
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  box-shadow: 0 10px 24px rgba(23, 33, 63, 0.22);
}

.secondary {
  color: var(--navy);
  border-color: var(--line);
  background: var(--white);
}

.ghost {
  color: var(--navy);
  background: transparent;
  border-color: var(--line);
}

.danger {
  color: var(--danger);
  background: #fff7f6;
  border-color: #f0c8c5;
}

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

.app-view {
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  font-size: 26px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

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

.app-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
}

.tab-button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.tab-button.active {
  color: var(--white);
  background: var(--navy);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
}

.overview-card {
  min-height: 260px;
}

.signal-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.signal-list div {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 8px 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.signal-list strong,
.signal-list small {
  display: block;
  grid-column: 2;
}

.signal-list strong {
  color: var(--navy);
}

.signal-list small {
  color: var(--muted);
}

.signal-dot {
  grid-row: 1 / span 2;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #9aa8b8;
}

.signal-dot.good {
  background: var(--green);
}

.signal-dot.warn {
  background: #d89518;
}

.signal-dot.bad {
  background: var(--danger);
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.summary-row:last-child {
  border-bottom: 0;
}

.summary-row span {
  color: var(--muted);
  font-weight: 800;
}

.summary-row strong {
  color: var(--navy);
  font-size: 24px;
}

.metric {
  min-height: 92px;
  border-radius: 8px;
  padding: 18px;
}

.metric span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  color: var(--navy);
  font-size: 22px;
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.side-panel,
.panel-card {
  border-radius: 8px;
}

.side-panel {
  padding: 20px;
  position: sticky;
  top: 18px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.step-list {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.step {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.step span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--navy);
  background: #eaf2f7;
  font-weight: 900;
}

.step strong,
.step small {
  display: block;
}

.step small {
  margin-top: 3px;
  color: var(--muted);
}

.step.active {
  border-color: rgba(0, 173, 116, 0.35);
  background: rgba(0, 173, 116, 0.06);
}

.step.active span {
  color: var(--white);
  background: var(--green);
}

.action-stack {
  display: grid;
  gap: 10px;
}

.action-stack.horizontal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.main-panel {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
}

.panel-card {
  padding: 20px;
}

.qr-box {
  min-height: 322px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5df;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
}

.qr-box img {
  width: 280px;
  height: 280px;
  display: block;
}

.empty-state {
  display: grid;
  gap: 8px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--navy);
}

.compact-state {
  min-height: 120px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--navy);
  background: #eaf2f7;
  font-size: 12px;
  font-weight: 900;
}

.groups-list {
  display: grid;
  gap: 10px;
}

.source-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.source-form .button {
  min-width: 150px;
}

.detected-sources {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(23, 169, 215, 0.24);
  border-radius: 8px;
  background: rgba(23, 169, 215, 0.05);
}

.detected-sources strong,
.detected-sources small {
  display: block;
}

.detected-sources strong {
  color: var(--navy);
  font-size: 14px;
}

.detected-sources small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.detected-sources-list {
  display: grid;
  gap: 8px;
}

.detected-sources-list > span {
  color: var(--muted);
  font-size: 13px;
}

.source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.source-row strong,
.source-row small {
  display: block;
}

.source-row strong {
  color: var(--navy);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.source-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.activity-card {
  grid-column: 1 / -1;
}

.counter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.counter-grid article {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
}

.counter-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.counter-grid strong {
  color: var(--navy);
  font-size: 24px;
}

.events-list {
  display: grid;
  gap: 8px;
  max-height: 270px;
  overflow: auto;
  padding-right: 4px;
}

.admin-panel {
  margin-top: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.admin-box {
  display: grid;
  gap: 12px;
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfdff;
}

.admin-box h3 {
  margin: 0;
  color: var(--navy);
  font-size: 16px;
}

.main-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.main-status strong {
  color: var(--navy);
}

.mini-qr-box {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5df;
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}

.mini-qr-box img {
  width: 170px;
  height: 170px;
}

.users-table-wrap {
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  background: #fff;
}

.users-table th,
.users-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.users-table th {
  color: var(--navy);
  background: #eef5f9;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

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

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.mini-button {
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.mini-button.danger-text {
  color: var(--danger);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 33, 63, 0.42);
}

.modal-card {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.event-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid #9aa8b8;
  border-radius: 8px;
  background: #fbfdff;
}

.event-row.success {
  border-left-color: var(--green);
}

.event-row.warn {
  border-left-color: #d89518;
}

.event-row.error {
  border-left-color: var(--danger);
}

.event-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.event-body strong,
.event-body small {
  display: block;
}

.event-body strong {
  color: var(--navy);
  font-size: 14px;
}

.event-body small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.group-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.group-row strong {
  display: block;
  color: var(--navy);
  font-size: 15px;
}

.group-row small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--white);
  background: var(--navy);
  box-shadow: var(--shadow);
  font-weight: 700;
}

@media (max-width: 900px) {
  .login-view,
  .workspace,
  .main-panel,
  .status-strip,
  .counter-grid,
  .admin-grid,
  .overview-grid,
  .source-form {
    grid-template-columns: 1fr;
  }

  .app-tabs {
    width: 100%;
  }

  .login-view {
    gap: 28px;
    padding: 32px 0;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  h1 {
    font-size: 34px;
  }

  .side-panel {
    position: static;
  }
}
