:root {
  --bg: #eef4f8;
  --surface: #ffffff;
  --surface-soft: #f6f9fc;
  --ink: #17202a;
  --muted: #64748b;
  --line: #d8e2ec;
  --brand: #1261a6;
  --brand-dark: #0b3d66;
  --teal: #159184;
  --amber: #e9a208;
  --rose: #cf4968;
  --green: #2f8f46;
  --shadow: 0 18px 42px rgba(18, 36, 64, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #edf5fb 0%, #f8fafc 52%, #eef4f8 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

[hidden] {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 440px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.back-link {
  display: inline-flex;
  margin-bottom: 18px;
  color: var(--brand-dark);
  font-weight: 800;
}

.login-mark,
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--brand-dark);
}

.login-mark span,
.brand-mark span {
  border-radius: 3px;
}

.login-mark span:nth-child(1),
.brand-mark span:nth-child(1) {
  background: #38bdf8;
}

.login-mark span:nth-child(2),
.brand-mark span:nth-child(2) {
  background: #facc15;
}

.login-mark span:nth-child(3),
.brand-mark span:nth-child(3) {
  background: #fb7185;
}

.login-mark span:nth-child(4),
.brand-mark span:nth-child(4) {
  background: #34d399;
}

.login-card h1 {
  margin: 20px 0 8px;
  color: var(--brand-dark);
  font-size: 34px;
  line-height: 1.08;
}

.login-card p,
.security-note {
  color: var(--muted);
}

label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: #334155;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(18, 97, 166, 0.12);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand strong {
  display: block;
  color: var(--brand-dark);
  font-size: 20px;
}

.brand small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.side-nav {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.side-nav button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 12px;
  background: transparent;
  color: #334155;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.side-nav button:hover,
.side-nav button.active {
  background: #e8f2fb;
  color: var(--brand-dark);
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(216, 226, 236, 0.9);
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(12px);
}

.topbar strong {
  display: block;
  color: var(--brand-dark);
  font-size: 20px;
}

.topbar span {
  color: var(--muted);
}

.menu-toggle {
  display: none;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.user-box span,
.user-box small {
  display: block;
}

.content {
  padding: 22px;
}

.loading,
.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.toolbar,
.filters,
.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.filters {
  justify-content: flex-start;
}

.page-section {
  display: grid;
  gap: 16px;
}

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

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(18, 36, 64, 0.07);
}

.stat-card {
  min-height: 116px;
  padding: 16px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  color: var(--brand-dark);
  font-size: 34px;
  line-height: 1;
}

.stat-card small {
  display: block;
  margin-top: 8px;
  color: #64748b;
}

.panel {
  padding: 16px;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  color: var(--brand-dark);
}

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

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

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

th {
  background: #f3f7fb;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

td {
  color: #243447;
}

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

.title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}

.thumb {
  width: 58px;
  height: 42px;
  flex: 0 0 58px;
  border-radius: 6px;
  object-fit: cover;
  background: #e7eef5;
}

.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e7f5f3;
  color: #0f766e;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.draft,
.badge.hidden,
.badge.inactive {
  background: #fff3d0;
  color: #8a5a00;
}

.badge.blocked,
.badge.cancelled,
.badge.suspicious {
  background: #fde8ef;
  color: #9f1239;
}

.badge.deleted,
.badge.finished {
  background: #e7eef5;
  color: #475569;
}

.badge.active {
  background: #e7f5f3;
  color: #0f766e;
}

.row-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  padding: 9px 12px;
  background: #e7eef5;
  color: var(--brand-dark);
  font-weight: 800;
  cursor: pointer;
}

.btn:hover,
.btn:focus-visible {
  outline: none;
  filter: brightness(0.97);
}

.btn.primary {
  background: var(--brand);
  color: #fff;
}

.btn.success {
  background: var(--green);
  color: #fff;
}

.btn.warn {
  background: var(--amber);
  color: #17202a;
}

.btn.danger {
  background: var(--rose);
  color: #fff;
}

.btn.ghost {
  border: 1px solid var(--line);
  background: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.check-row input {
  width: auto;
  min-height: auto;
}

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

.modal {
  width: min(100%, 980px);
  max-height: min(92vh, 940px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 80px rgba(2, 8, 23, 0.28);
  overflow: hidden;
}

.modal.small {
  width: min(100%, 540px);
}

.modal-header,
.modal-footer {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-header h2 {
  margin: 0;
  color: var(--brand-dark);
}

.modal-body {
  padding: 16px;
  overflow: auto;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}

.preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.preview-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e7eef5;
}

.preview-card div {
  padding: 14px;
}

.preview-card h3 {
  margin: 0 0 8px;
  color: var(--brand-dark);
}

.preview-card p {
  margin: 0;
  color: var(--muted);
}

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #102a43;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.log-list li {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.log-list strong {
  display: block;
  color: var(--brand-dark);
}

.log-list span {
  color: var(--muted);
  font-size: 14px;
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: 270px;
    transform: translateX(-104%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-flex;
    min-height: 38px;
    border: 0;
    border-radius: var(--radius);
    padding: 8px 12px;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
  }

  .stats-grid,
  .two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .user-box {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .content {
    padding: 14px;
  }

  .stats-grid,
  .two-columns,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .section-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filters input,
  .filters select,
  .filters button,
  .toolbar .btn,
  .section-actions .btn {
    width: 100%;
  }
}
