:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

html {
  font-size: 16px;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(148, 163, 184, 0.18), transparent 24%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  color: var(--text);
}

a {
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(43, 52, 65, 0.96) 0%, rgba(31, 41, 55, 0.96) 100%);
  backdrop-filter: blur(14px);
}

.app-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  min-width: 0;
}

.app-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.app-logo {
  display: block;
  height: 48px;
  width: auto;
  object-fit: contain;
}

.app-brand {
  font-size: 1.15rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f8fafc;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  min-width: 0;
}

.app-nav a {
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  color: rgba(248, 250, 252, 0.82);
  text-decoration: none;
  white-space: nowrap;
}

.app-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.logout-form {
  margin: 0;
}

.logout-form .btn-dark {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.logout-form .btn-dark:hover,
.logout-form .btn-dark:focus {
  background: #fff;
  border-color: #fff;
  color: #0f172a;
}

.app-footer {
  padding: 1.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.toast-stack {
  position: fixed;
  top: 88px;
  right: 24px;
  z-index: 1200;
}

.app-toast {
  min-width: 300px;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 1rem 1.1rem;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
  color: #fff;
}

.app-toast.is-success {
  background: linear-gradient(135deg, #166534 0%, #15803d 100%);
}

.app-toast.is-error {
  background: linear-gradient(135deg, #991b1b 0%, #dc2626 100%);
}

.app-toast-body {
  font-weight: 700;
}

.app-toast-close {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.9;
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 170px);
  padding: 2rem 0;
}

.login-panel,
.admin-panel,
.form-panel {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.login-panel {
  max-width: 480px;
  padding: 2.2rem;
}

.login-brand,
.panel-kicker {
  display: inline-block;
  margin-bottom: 0.9rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-panel h1,
.admin-panel h2,
.form-panel h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.9rem, 3vw, 2.4rem);
  line-height: 1.05;
}

.login-panel p,
.table-muted {
  color: var(--muted);
}

.login-form .form-control,
.form-panel .form-control,
.form-panel .form-select {
  min-height: 3.2rem;
  border-color: var(--line-strong);
  border-radius: 16px;
  background: #fff;
}

.form-panel textarea.form-control {
  min-height: auto;
}

.login-form .form-control:focus,
.form-panel .form-control:focus,
.form-panel .form-select:focus,
.form-check-input:focus {
  border-color: #0f172a;
  box-shadow: 0 0 0 0.2rem rgba(15, 23, 42, 0.08);
}

.admin-panel,
.form-panel {
  margin: 2rem 0;
  padding: 1.8rem;
}

.panel-head,
.panel-actions,
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-head {
  margin-bottom: 1.4rem;
}

.panel-actions {
  flex-wrap: wrap;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.stat-card,
.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.stat-card {
  padding: 1.2rem 1.3rem;
}

.stat-card span {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--muted);
}

.stat-card strong {
  font-size: 2rem;
  line-height: 1;
}

.admin-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.4fr;
  gap: 1.25rem;
}

.admin-card {
  padding: 1rem;
  overflow: hidden;
}

.admin-card-wide {
  grid-column: 1 / -1;
}

.card-head {
  margin-bottom: 0.8rem;
}

.card-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.table-shell {
  overflow-x: auto;
}

.table {
  margin-bottom: 0;
}

.table thead th {
  color: var(--muted);
  font-weight: 700;
  border-bottom-color: var(--line);
}

.table td,
.table th {
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
  border-color: var(--line);
  vertical-align: middle;
}

.actions-column {
  width: 1%;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.table-actions form {
  margin: 0;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  text-decoration: none;
}

.icon-btn-edit:hover {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

.icon-btn-delete {
  color: #b91c1c;
}

.icon-btn-delete:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.btn {
  border-radius: 14px;
  padding: 0.8rem 1.15rem;
  font-weight: 700;
}

.btn-sm {
  padding: 0.5rem 0.8rem;
  border-radius: 12px;
}

.btn-dark,
.btn-dark:hover,
.btn-dark:focus {
  background: #0f172a;
  border-color: #0f172a;
}

.btn-outline-dark {
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-outline-dark:hover {
  background: #0f172a;
  border-color: #0f172a;
}

.thumb-preview {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 16px;
  background: var(--surface-soft);
}

.logo-preview {
  object-fit: contain;
  padding: 0.45rem;
  background: #fff;
  border: 1px solid var(--line);
}

.form-panel .form-check {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.text-danger {
  font-size: 0.92rem;
}

@media (max-width: 992px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .app-nav {
    flex: 1 1 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .panel-head,
  .panel-actions,
  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-header {
    position: static;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    padding: 0.9rem 0;
  }

  .app-brand {
    font-size: 1rem;
    line-height: 1.2;
  }

  .app-brand {
    display: none;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .login-panel,
  .admin-panel,
  .form-panel {
    padding: 1.25rem;
    border-radius: 22px;
  }

  .app-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .app-nav a,
  .app-logo-link {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  .app-logo {
    height: 36px;
    margin: 0 auto;
  }

  .logout-form {
    width: 100%;
  }

  .logout-form .btn {
    width: 100%;
  }

  .toast-stack {
    top: 78px;
    right: 12px;
    left: 12px;
  }

  .app-toast {
    min-width: 0;
    max-width: none;
  }

  .actions-column {
    width: auto;
  }

  .table-actions {
    justify-content: flex-start;
  }

  .table-actions .btn,
  .table-actions form,
  .table-actions .icon-btn {
    width: 100%;
  }

  .table-actions form .btn,
  .table-actions form .icon-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .app-nav {
    grid-template-columns: 1fr;
  }

  .app-nav a {
    text-align: center;
  }
}
