* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f7fb;
  color: #1f2937;
}

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

code {
  background: #eef2ff;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

button,
input,
select {
  font: inherit;
}

button {
  border: none;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  background: #2563eb;
  color: white;
  cursor: pointer;
}

button.secondary {
  width: 100%;
  background: #374151;
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.65;
}

input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
}

select {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

.login-card form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.25rem;
}

.narrow-card {
  max-width: 560px;
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #111827;
  color: #f9fafb;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
}

.sidebar nav {
  display: grid;
  gap: 0.35rem;
}

.sidebar nav a {
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  color: #d1d5db;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  background: #1f2937;
  color: white;
}

.content {
  padding: 2rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1,
.login-card h1,
.card h2 {
  margin-top: 0;
}

.card h3 {
  margin-top: 1.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card,
.card {
  background: white;
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.metric-card strong {
  display: block;
  margin-top: 0.45rem;
  font-size: 1.8rem;
}

.metric-label {
  color: #6b7280;
  font-size: 0.9rem;
}

.muted {
  color: #6b7280;
}

.small {
  font-size: 0.9rem;
}

.alert {
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-top: 1rem;
}

.alert.error {
  background: #fef2f2;
  color: #991b1b;
}

.alert.success {
  background: #ecfdf5;
  color: #166534;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  font-weight: 600;
}

.secondary-link {
  background: #374151;
}

.text-link {
  color: #2563eb;
  font-weight: 600;
}

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

.inline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: end;
}

.filter-grid {
  margin-bottom: 1rem;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 0.75rem;
  align-items: end;
  margin-top: 1rem;
}

.inline-subscription-form {
  display: grid;
  grid-template-columns: minmax(90px, 120px) auto;
  gap: 0.5rem;
  align-items: center;
}

.inline-user-form {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.checkbox-row input {
  width: auto;
}

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

.action-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.field-error {
  color: #b91c1c;
  font-size: 0.9rem;
  margin: 0.35rem 0 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.85rem 0.7rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

.compact-table th,
.compact-table td {
  padding: 0.6rem 0.5rem;
  font-size: 0.92rem;
}

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

.detail-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.75rem;
}

.detail-list dt {
  font-weight: 700;
  color: #4b5563;
}

.detail-list dd {
  margin: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-submit {
  display: flex;
  align-items: end;
}

.small-button {
  padding: 0.55rem 0.8rem;
}

.pill {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.pill.success {
  background: #dcfce7;
  color: #166534;
}

.pill.warning {
  background: #fef3c7;
  color: #92400e;
}

.pill.neutral {
  background: #e5e7eb;
  color: #374151;
}

hr {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin: 0.25rem 0;
}

.plain-list {
  margin: 0;
  padding-left: 1.2rem;
}

.plain-list li + li {
  margin-top: 0.45rem;
}

.log-block {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  background: #0f172a;
  color: #e5e7eb;
  padding: 0.85rem;
  border-radius: 10px;
  max-height: 480px;
  overflow: auto;
}

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

  .sidebar {
    gap: 1rem;
  }

  .content {
    padding: 1.25rem;
  }

  .form-grid,
  .inline-grid,
  .detail-grid,
  .inline-form,
  .button-row {
    grid-template-columns: 1fr;
  }
}
