:root {
  --navy: #032051;
  --green: #03572a;
  --green-soft: #e8f5ee;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --muted: #64748b;
  --text: #0f172a;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(3, 32, 81, 0.06), 0 8px 24px rgba(3, 32, 81, 0.08);
  --radius: 12px;
  --sidebar-w: 252px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

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

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--navy);
}

/* ─── Login ─── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(145deg, var(--navy) 0%, #061a40 55%, var(--green) 100%);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.75rem;
}

.brand-mark {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.15rem;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
}

.login-brand .sub {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0.75rem 0 0;
}

/* ─── App shell ─── */
.dashboard-body {
  overflow-x: hidden;
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.35rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand .brand-mark {
  background: rgba(255, 255, 255, 0.15);
}

.brand-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
}

.brand-sub {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.nav-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

.sidebar-footer {
  padding: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item.logout {
  color: rgba(255, 255, 255, 0.65);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
}

.sidebar-backdrop.show {
  display: block;
}

/* ─── Main content ─── */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 1.5rem 1.75rem 2.5rem;
}

.topbar {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.page-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.25;
}

.page-sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.menu-btn {
  display: none;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  align-items: center;
  justify-content: center;
  padding: 0;
}

.menu-btn svg {
  width: 20px;
  height: 20px;
  color: var(--navy);
}

.flash {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
  border: 1px solid #bbf7d0;
}

.flash.error {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

.hidden {
  display: none !important;
}

/* ─── Toolbar ─── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-pill {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
}

/* ─── Media cards ─── */
.media-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .media-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.media-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #e2e8f0;
  overflow: hidden;
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.media-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.media-meta {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
}

.media-title {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.35;
}

.media-desc {
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ─── List cards ─── */
.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 0.65rem;
  box-shadow: var(--shadow);
}

.list-card.read {
  opacity: 0.7;
}

.list-card strong {
  color: var(--navy);
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.btn:hover {
  opacity: 0.9;
}

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

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-sm {
  padding: 0.42rem 0.7rem;
  font-size: 0.8rem;
  flex: 1;
  min-width: 0;
}

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

/* ─── Forms ─── */
.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.35rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: #fff;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(3, 32, 81, 0.12);
}

.field-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* ─── Image picker ─── */
.image-picker {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #f8fafc;
  cursor: pointer;
}

.image-picker:hover {
  border-color: var(--navy);
}

.image-picker-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #eef2f6;
}

.image-picker-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-picker-empty {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.image-picker-empty strong {
  display: block;
  color: var(--navy);
  margin-bottom: 0.2rem;
  font-size: 0.875rem;
}

.image-picker input[type="file"] {
  display: none;
}

.image-picker-footer {
  padding: 0.45rem 0.75rem;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: #fff;
}

.uploading {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--navy);
}

/* ─── Modal ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal-panel {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
}

.modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--muted);
}

.modal-body {
  padding: 1.15rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  padding-top: 0.25rem;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  max-width: 540px;
  box-shadow: var(--shadow);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* ─── Mobile ─── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

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

  .main {
    margin-left: 0;
    padding: 1rem;
  }

  .menu-btn {
    display: inline-flex;
  }
}
