* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.header h1 {
  margin: 0;
  font-size: 28px;
}

.header p {
  margin: 6px 0 0;
  color: #6b7280;
}

button {
  border: 0;
  background: #111827;
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: bold;
  cursor: pointer;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 30px;
}

.summary div {
  background: white;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
}

.summary span {
  font-size: 32px;
  font-weight: bold;
}

.summary p {
  margin: 8px 0 0;
  color: #6b7280;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.card {
  background: white;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.card img {
  width: 100%;
  height: 210px;
  object-fit: cover;
  background: #ddd;
}

.card-content {
  padding: 16px;
}

.card-content h3 {
  margin: 12px 0;
  text-transform: capitalize;
}

.badge {
  display: inline-block;
  padding: 6px 12px;
  color: white;
  border-radius: 999px;
  font-size: 13px;
  font-weight: bold;
}

.known {
  background: #16a34a;
}

.unknown {
  background: #dc2626;
}

.empty {
  color: #6b7280;
}

@media (max-width: 640px) {
  .app {
    padding: 16px;
  }

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

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

  button {
    width: 100%;
  }
}

.auth-box {
  max-width: 420px;
  margin: 80px auto;
  background: white;
  padding: 28px;
  border-radius: 18px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.auth-box form,
.panel form {
  display: grid;
  gap: 12px;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
}

.panel {
  background: white;
  padding: 20px;
  border-radius: 18px;
  margin-bottom: 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
}

.error {
  color: #dc2626;
  font-weight: bold;
}

.button-link {
  display: inline-block;
  background: #111827;
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: bold;
  text-decoration: none;
  margin: 8px 8px 16px 0;
}

.panel ul {
  padding-left: 18px;
}

.panel li {
  margin-bottom: 12px;
}

.member-group {
  border-top: 1px solid #e5e7eb;
  padding-top: 12px;
  margin-top: 12px;
}

.member-group h3 {
  margin-bottom: 8px;
}

.saas-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 30px 22px 56px;
}

.saas-header {
  margin-bottom: 24px;
}

.saas-header h1 {
  margin: 10px 0 8px;
  font-size: clamp(28px, 3.6vw, 44px);
  letter-spacing: -0.02em;
}

.saas-header p {
  margin: 0;
  max-width: 760px;
  color: #4b5563;
}

.saas-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
  color: #111827;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
}

.saas-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
  padding: 22px;
  margin-bottom: 20px;
}

.saas-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.saas-section-head h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -0.01em;
}

.saas-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #ecfeff;
  color: #155e75;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
}

.saas-chip-accent {
  background: #ecfdf5;
  color: #166534;
}

.saas-muted {
  color: #6b7280;
  margin: 0;
}

.saas-url {
  margin: 7px 0 16px;
  font-weight: 700;
  word-break: break-word;
}

.saas-inline-form {
  display: grid;
  gap: 10px;
}

.saas-inline-row {
  display: flex;
  gap: 10px;
}

.saas-inline-row input {
  flex: 1;
}

.saas-current-plan-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.saas-current-plan-price {
  margin: 8px 0 16px;
  font-size: 20px;
  font-weight: 700;
}

.saas-usage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.saas-usage-grid article {
  background: linear-gradient(160deg, #f8fafc 0%, #eef2ff 100%);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid #dbeafe;
}

.saas-usage-grid span {
  display: block;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  margin-bottom: 6px;
}

.saas-usage-grid small {
  color: #475569;
}

.saas-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.saas-plan-card {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 16px;
  background: radial-gradient(circle at top right, #f0f9ff, #ffffff 52%);
  display: grid;
  gap: 12px;
}

.saas-plan-card-active {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.18);
}

.saas-plan-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.saas-plan-top h3 {
  margin: 0;
  font-size: 22px;
}

.saas-plan-price {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.saas-plan-price small {
  font-size: 14px;
  color: #6b7280;
  margin-left: 2px;
}

.saas-plan-features {
  margin: 0;
  padding-left: 18px;
  color: #1f2937;
  display: grid;
  gap: 6px;
}

.saas-full-btn {
  width: 100%;
}

.saas-code-block {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  margin: 10px 0;
  font-size: 13px;
}

.saas-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

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

.saas-device-list,
.saas-camera-list {
  display: grid;
  gap: 14px;
}

.saas-device-card,
.saas-camera-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}

.saas-device-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.saas-device-title-row h3,
.saas-camera-card h3 {
  margin: 0;
}

.saas-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.saas-action-row form {
  margin: 0;
}

.saas-btn-danger {
  background: #991b1b;
}

.saas-device-settings {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed #d1d5db;
}

.saas-device-settings h4 {
  margin: 0 0 6px;
}

.saas-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.saas-toggle-row input[type="checkbox"] {
  width: auto;
}

.saas-advanced > summary {
  cursor: pointer;
  margin-bottom: 10px;
}

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

.saas-form-grid > .saas-toggle-row,
.saas-form-grid-btn {
  grid-column: 1 / -1;
}

@media (max-width: 980px) {
  .saas-grid-2,
  .saas-form-grid,
  .saas-usage-grid {
    grid-template-columns: 1fr;
  }

  .saas-shell {
    padding: 20px 14px 44px;
  }
}

@media (max-width: 680px) {
  .saas-section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .saas-inline-row {
    flex-direction: column;
  }

  .saas-action-row form,
  .saas-action-row button {
    width: 100%;
  }
}

/* Dashboard refresh */
body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  background: radial-gradient(
    circle at top,
    #eff6ff 0%,
    #f8fafc 40%,
    #f1f5f9 100%
  );
}

.dash-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 22px;
}

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

.dash-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  color: #f8fafc;
  text-decoration: none;
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 700;
}

.dash-hero {
  background: linear-gradient(145deg, #ffffff 0%, #eef2ff 100%);
  border: 1px solid #dbeafe;
  border-radius: 24px;
  padding: 26px;
  margin-bottom: 18px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.dash-hero h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 50px);
  letter-spacing: -0.03em;
}

.dash-hero p {
  margin: 8px 0 0;
  color: #475569;
  font-size: 15px;
}

.dash-meta-row {
  margin-top: 14px;
}

.dash-role-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  background: #cffafe;
  color: #155e75;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.dash-stat-grid {
  margin-bottom: 20px;
}

.dash-stat-card {
  border: 1px solid #e5e7eb;
  background: linear-gradient(160deg, #ffffff 0%, #eff6ff 100%);
}

.dash-panel {
  border: 1px solid #e2e8f0;
  border-radius: 22px;
  padding: 22px;
}

.dash-panel-admin {
  background: linear-gradient(160deg, #ffffff 0%, #f8fafc 100%);
}

.dash-action-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dash-telegram-form {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.dash-telegram-form button {
  min-width: 220px;
}

.dash-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  gap: 10px;
}

.dash-list-item {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fafafa;
}

.dash-inline-links {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-inline-links form {
  margin: 0;
}

.dash-btn-danger {
  background: #b91c1c;
}

.dash-logs h2 {
  margin-bottom: 14px;
}

.dash-log-card {
  border: 1px solid #e5e7eb;
}

@media (max-width: 640px) {
  .dash-shell {
    padding: 16px;
  }

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

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

  .dash-telegram-form button {
    min-width: 0;
  }

  .dash-link-pill,
  .dash-topbar form,
  .dash-topbar button {
    width: 100%;
  }
}
