:root {
  --bg-green-start: #eef8f0;
  --bg-green-end: #d6ead8;
  --bg-red-start: #fff1f1;
  --bg-red-end: #f2c9c9;
  --text-main: #173127;
  --text-muted: #5b7265;
  --text-alert: #7f1d1d;
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-alert: rgba(121, 17, 17, 0.12);
  --line: rgba(23, 49, 39, 0.1);
  --primary: #1f5f4a;
  --primary-hover: #184b3b;
  --danger: #b42323;
  --danger-hover: #951c1c;
  --surface: #f8fbf8;
  --shadow: 0 24px 60px rgba(22, 49, 39, 0.16);
  --ok: #1f8a4c;
  --modal-overlay: rgba(16, 29, 23, 0.45);
}

:root.theme-dark {
  --bg-green-start: #0d1713;
  --bg-green-end: #15241d;
  --bg-red-start: #2a1414;
  --bg-red-end: #1d0d0d;
  --text-main: #edf7f1;
  --text-muted: #a8beb2;
  --text-alert: #ffb0b0;
  --card-bg: rgba(18, 31, 25, 0.92);
  --card-alert: rgba(122, 30, 30, 0.22);
  --line: rgba(237, 247, 241, 0.12);
  --primary: #3fa97a;
  --primary-hover: #31845f;
  --danger: #d34b4b;
  --danger-hover: #b53e3e;
  --surface: #13211b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  --ok: #61d98f;
  --modal-overlay: rgba(0, 0, 0, 0.58);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-main);
  background: linear-gradient(160deg, var(--bg-green-start), var(--bg-green-end));
  transition: background 0.25s ease, color 0.25s ease;
}

body.auth-body,
body.dashboard-body,
body.status-body {
  position: relative;
}

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

button,
input,
select {
  font: inherit;
}

.flash-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 20;
  display: grid;
  gap: 10px;
}

.flash {
  min-width: 260px;
  padding: 14px 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  background: var(--card-bg);
}

.site-credit {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 5;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

:root.theme-dark .site-credit {
  background: rgba(255, 255, 255, 0.04);
}

.flash--error {
  color: #d34b4b;
  border-left: 4px solid #c93939;
}

.flash--success {
  color: var(--primary);
  border-left: 4px solid #2d8f6e;
}

.auth-shell,
.dashboard-shell,
.status-page {
  min-height: 100vh;
}

.auth-shell {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.82), transparent 35%),
    linear-gradient(160deg, var(--bg-green-start), var(--bg-green-end));
}

.auth-card,
.panel-card,
.status-card,
.stat-card {
  background: var(--card-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: min(100%, 460px);
  border-radius: 30px;
  padding: 34px 28px;
}

.auth-title,
.page-title {
  margin: 0;
}

.auth-subtitle,
.page-subtitle,
.empty-state {
  color: var(--text-muted);
}

.auth-form,
.customer-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

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

.field span {
  font-size: 0.92rem;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-main);
}

.primary-button,
.secondary-button,
.ghost-button,
.theme-toggle {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, border 0.2s ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.theme-toggle:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--primary-hover);
}

.primary-button--full {
  width: 100%;
}

.secondary-button {
  background: var(--danger);
  color: #fff;
  font-weight: 700;
}

.secondary-button:hover {
  background: var(--danger-hover);
}

.ghost-button {
  background: rgba(31, 95, 74, 0.08);
  color: var(--primary);
  font-weight: 700;
}

.theme-toggle {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--line);
}

.theme-toggle--icon {
  width: 48px;
  height: 48px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 1.1rem;
}

.auth-note {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(31, 95, 74, 0.08);
  color: var(--text-muted);
}

.dashboard-shell {
  padding: 32px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.82), transparent 35%),
    linear-gradient(160deg, var(--bg-green-start), var(--bg-green-end));
}

.topbar,
.status-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.page-subtitle {
  margin-top: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.stat-card {
  border-radius: 24px;
  padding: 22px;
}

.stat-card span {
  color: var(--text-muted);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.stat-card--danger strong {
  color: var(--danger);
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 22px;
  margin-top: 24px;
}

.panel-card {
  border-radius: 30px;
  padding: 24px;
}

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

.customer-list {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.customer-item {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: var(--surface);
}

.customer-item__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.customer-item__header h3 {
  margin: 0;
}

.customer-item__header p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.badge--success {
  background: rgba(31, 95, 74, 0.1);
  color: var(--primary);
}

.badge--danger {
  background: rgba(180, 35, 35, 0.1);
  color: var(--danger);
}

.customer-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.customer-meta dt {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.customer-meta dd {
  margin: 6px 0 0;
  font-weight: 700;
}

.customer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.license-tools {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.license-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.field--compact {
  min-width: 120px;
}

.field--compact input {
  padding: 12px 14px;
}

.field--date {
  min-width: 200px;
}

.inline-link {
  color: var(--primary);
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--modal-overlay);
  z-index: 30;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(100%, 520px);
  border-radius: 28px;
  padding: 24px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

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

.modal-header h2 {
  margin: 0;
}

.modal-close {
  border: 0;
  background: transparent;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-subtitle,
.modal-note {
  color: var(--text-muted);
}

.password-output {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(31, 95, 74, 0.08);
}

.password-output code {
  font-size: 1.05rem;
  font-weight: 700;
  word-break: break-all;
  color: var(--text-main);
}

.status-page {
  display: grid;
  align-content: center;
  gap: 24px;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.82), transparent 35%),
    linear-gradient(160deg, var(--bg-green-start), var(--bg-green-end));
  transition: background 0.35s ease, color 0.35s ease;
}

.status-page--alert {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.3), transparent 35%),
    linear-gradient(160deg, var(--bg-red-start), var(--bg-red-end));
}

.status-topbar {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10;
  width: auto;
  justify-self: auto;
  justify-content: end;
}

.status-card {
  width: min(100%, 700px);
  justify-self: center;
  text-align: center;
  padding: 34px 26px;
  border-radius: 30px;
  transition: background 0.35s ease;
}

.status-page--alert .status-card {
  background: var(--card-alert);
}

.status-label {
  margin: 0 0 10px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.status-message {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.status-message--ok {
  color: var(--ok);
}

.status-detail {
  margin: 14px 0 0;
  min-height: 1.5em;
  color: var(--text-muted);
  font-size: 1rem;
}

.status-details {
  margin-top: 22px;
}

.status-details__summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
  list-style: none;
  user-select: none;
}

.status-details__summary::-webkit-details-marker {
  display: none;
}

.status-details__summary::after {
  content: "▾";
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}

.status-details[open] .status-details__summary::after {
  transform: rotate(180deg);
}

.status-page--alert .status-message,
.status-page--alert .status-detail,
.status-page--alert .status-label {
  color: var(--text-alert);
}

.status-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.status-info-grid article {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

:root.theme-dark .status-info-grid article {
  background: rgba(255, 255, 255, 0.04);
}

.status-info-grid span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-info-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

@media (max-width: 960px) {
  .stats-grid,
  .panel-grid,
  .status-info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .dashboard-shell {
    padding: 18px;
  }

  .topbar,
  .status-topbar,
  .customer-item__header,
  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .status-topbar {
    top: 16px;
    right: 16px;
  }

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

  .site-credit {
    bottom: 12px;
    font-size: 0.74rem;
    padding: 7px 12px;
  }
}
