:root {
  color-scheme: light;
  --blue: #2557d6;
  --blue-dark: #123f9f;
  --blue-soft: #e7efff;
  --nav: #111827;
  --nav-muted: #9ca3af;
  --ink: #1d2433;
  --muted: #81899a;
  --line: #dde3ec;
  --panel: #ffffff;
  --page: #f5f7fb;
  --green: #2ba36a;
  --green-soft: #dff4e8;
  --orange: #a46822;
  --orange-soft: #faeadb;
  --red: #bd3f42;
  --red-soft: #fde3e3;
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-weight: 650;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: linear-gradient(135deg, #f7f9ff, #eef3fb);
}

.login-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 36px;
  box-shadow: 0 18px 55px rgba(23, 29, 42, 0.08);
}

.login-logo {
  width: 56px;
  height: 56px;
  padding: 10px;
  background: var(--blue);
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

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

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.login-form label,
.field label {
  display: grid;
  gap: 8px;
  color: #4f596b;
  font-size: 14px;
}

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

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21, 91, 221, 0.12);
}

select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21, 91, 221, 0.12);
}

.primary-btn,
.ghost-btn,
.success-btn {
  height: 46px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-btn {
  background: var(--blue);
  color: white;
  box-shadow: 0 8px 18px rgba(37, 87, 214, 0.18);
}

.ghost-btn {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.success-btn {
  background: #0f9f6e;
  color: white;
  box-shadow: 0 8px 18px rgba(15, 159, 110, 0.16);
}

.compact-btn {
  height: 40px;
  padding: 0 14px;
}

.large-btn {
  height: 46px;
  justify-content: center;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
}

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

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
}

.icon-rail {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 100vh;
  background: linear-gradient(180deg, #10234d 0%, #0f172a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 22px 14px;
}

.rail-brand {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  margin-bottom: 10px;
}

.rail-brand img {
  width: 39px;
  height: 44px;
  filter: brightness(0) invert(1);
  opacity: 0.96;
}

.module-nav {
  display: grid;
  gap: 12px;
  width: 100%;
}

.module-nav button {
  position: relative;
  width: 58px;
  height: 58px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  padding: 0;
  display: grid;
  place-items: center;
  margin: 0 auto;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.module-nav button .nav-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: currentColor;
  flex: 0 0 auto;
}

.module-nav button .nav-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.module-nav .nav-label {
  position: absolute;
  z-index: 30;
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  min-width: max-content;
  pointer-events: none;
  opacity: 0;
  background: #111827;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 9px 11px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.module-nav .nav-label::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 50%;
  width: 9px;
  height: 9px;
  background: #111827;
  transform: translateY(-50%) rotate(45deg);
}

.module-nav button.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.module-nav button.active .nav-icon {
  background: var(--blue);
  color: #ffffff;
}

.module-nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  transform: translateY(-1px);
}

.module-nav button:hover .nav-label,
.module-nav button:focus-visible .nav-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.workspace {
  min-width: 0;
}

.topbar {
  height: 72px;
  display: grid;
  grid-template-columns: minmax(280px, 500px) auto auto auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.search-box {
  position: relative;
  display: block;
}

.search-box span {
  position: absolute;
  left: 15px;
  top: 9px;
  color: var(--muted);
  font-size: 22px;
}

.search-box input {
  padding-left: 46px;
  font-weight: 720;
  background: #fbfcff;
}

.session-chip {
  justify-self: end;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.session-chip span {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #e8efff;
  color: var(--blue-dark);
  display: grid;
  place-items: center;
  font-size: 12px;
}

.session-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 36px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcff 0%, var(--page) 100%);
}

.sync-status {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sync-status.ok {
  color: var(--green);
  background: var(--green-soft);
  border-color: var(--green-soft);
}

.sync-status.warn {
  color: var(--orange);
  background: var(--orange-soft);
  border-color: var(--orange-soft);
}

.content-grid {
  padding: 26px 36px 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
}

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

.metrics {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-card,
.panel,
.detail-hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.035);
}

.metric-card {
  min-height: 116px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--blue);
  opacity: 0.7;
}

.metric-card span {
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
}

.metric-card strong {
  display: block;
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0;
}

.metric-card small {
  display: block;
  margin-top: 12px;
  color: var(--blue-dark);
  font-weight: 800;
}

.panel {
  padding: 20px;
}

.detail-hero {
  grid-column: 1 / -1;
  min-height: 132px;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.detail-hero h2 {
  margin-top: 10px;
}

.detail-hero span:not(.badge) {
  color: var(--muted);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-left: 14px;
  border-left: 4px solid var(--blue);
  margin-bottom: 18px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-row button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faff;
  color: var(--muted);
  padding: 0 12px;
}

.filter-row button.active {
  background: var(--blue-soft);
  color: var(--blue-dark);
  border-color: #b7cbff;
}

.action-message {
  margin-bottom: 14px;
  border: 1px solid #b7cbff;
  background: #f4f7ff;
  color: var(--blue-dark);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
}

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

.admin-form label {
  display: grid;
  gap: 8px;
  color: #4f596b;
  font-size: 13px;
}

.admin-form .check-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 46px;
  padding-top: 20px;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
}

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

.detail-item {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.detail-item span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.detail-item strong {
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  font-weight: 720;
  line-height: 1.35;
}

tbody tr:hover {
  background: #fafcff;
}

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

.subtext {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  color: var(--green);
  background: var(--green-soft);
}

.badge.blue {
  color: var(--blue-dark);
  background: var(--blue-soft);
}

.badge.orange {
  color: var(--orange);
  background: var(--orange-soft);
}

.badge.red {
  color: var(--red);
  background: var(--red-soft);
}

.event-list,
.health-list,
.package-grid,
.renewal-list {
  display: grid;
  gap: 10px;
}

.event-item,
.health-item,
.package-card,
.renewal-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.event-item {
  background: #fbfcff;
}

.event-item span,
.health-item span,
.package-card span,
.renewal-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.subscription-table table {
  min-width: 1180px;
}

.subscription-admin-form {
  min-width: 320px;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
}

.renewal-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  background: #fbfcff;
}

.renewal-item .badge {
  flex: 0 0 auto;
}

.package-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.package-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.package-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.inline-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--blue-dark);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.pay-btn {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.danger-btn {
  min-height: 34px;
  border: 1px solid var(--red-soft);
  border-radius: 6px;
  background: #fff7f7;
  color: var(--red);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 850;
}

.info-strip {
  padding-top: 18px;
  padding-bottom: 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.48);
}

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 56px);
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 26px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.22);
}

.compact-modal {
  width: min(520px, 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
}

.tenant-admin-form {
  min-width: 360px;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.tenant-admin-form select {
  height: 36px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

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

.tenant-detail-form {
  min-width: 0;
  grid-template-columns: 1fr;
  align-items: stretch;
}

.tenant-detail-form label {
  display: grid;
  gap: 8px;
  color: #4f596b;
  font-size: 13px;
}

.tenant-detail-form select {
  height: 46px;
  font-size: 14px;
}

.form-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
}

.empty-state strong,
.empty-state span {
  display: block;
}

@media (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .content-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .admin-form,
  .package-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .row-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .tenant-admin-form,
  .subscription-admin-form {
    min-width: 0;
    width: 100%;
  }

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

  .topbar .ghost-btn,
  .session-chip {
    display: none;
  }
}

@media (max-width: 720px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .icon-rail {
    position: static;
    min-height: 74px;
    flex-direction: row;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 10px 14px;
  }

  .rail-brand {
    width: 50px;
    height: 50px;
    margin: 0 6px 0 0;
    flex: 0 0 auto;
  }

  .module-nav {
    display: flex;
    gap: 8px;
    width: auto;
  }

  .module-nav button {
    width: 50px;
    height: 50px;
    flex: 0 0 auto;
  }

  .module-nav .nav-label {
    display: none;
  }

  .page-head,
  .content-grid {
    padding-left: 18px;
    padding-right: 18px;
  }
}
