*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --dark: #023a49;
  --dark2: #0f4659;
  --border: #e0ddd6;
  --bg: #f0f2f4;
  --text: #1a1a1a;
  --muted: #666;
  --danger: #b42318;
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, #023a49 0%, #0f4659 100%);
}

#adminApp[hidden] {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card h1 { font-size: 22px; font-weight: 800; color: var(--dark); margin-bottom: 8px; }
.login-hint { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.login-card label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 14px; margin-bottom: 12px;
}
.login-default { font-size: 12px; color: #999; margin-top: 16px; }
.login-default code { background: #f5f5f3; padding: 2px 6px; border-radius: 4px; }
.back-link { display: inline-block; margin-top: 20px; font-size: 13px; color: var(--dark); }

.login-reset {
  width: 100%; margin-top: 12px;
  color: var(--dark) !important;
  border: 1px solid var(--border) !important;
  background: #f8f9fa !important;
  font-size: 12px; padding: 10px;
}
.login-reset:hover { background: #eef1f3 !important; }
#cmsLoadError { margin-top: 10px; }
#loginError { margin-bottom: 8px; }

.admin-app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.sidebar-brand {
  font-size: 14px; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 0 8px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-btn {
  font-family: inherit; font-size: 14px; font-weight: 500;
  text-align: left; padding: 12px 14px; border: none; border-radius: 6px;
  background: transparent; color: rgba(255,255,255,0.7); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-btn.is-active { background: rgba(255,255,255,0.14); color: #fff; font-weight: 600; }

.sidebar-footer { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }

.admin-main { flex: 1; padding: 28px 32px 48px; overflow-y: auto; }

.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.admin-header h2 { font-size: 24px; font-weight: 800; color: var(--dark); }

.save-status { font-size: 13px; color: #2d7a4f; font-weight: 500; }
.save-status.is-error { color: var(--danger); }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 24px; margin-bottom: 20px;
}
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.card-desc { font-size: 13px; color: var(--muted); margin-bottom: 20px; line-height: 1.6; }
.card-desc code { font-size: 12px; background: #f5f5f3; padding: 2px 6px; border-radius: 4px; }
.card-muted { background: #f8f9fa; }

.btn {
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 6px; border: none; cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--dark); color: #fff; cursor: pointer; }
.btn-primary:hover { background: var(--dark2); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.login-submit {
  width: 100%;
  margin-top: 4px;
  padding: 13px 18px;
  font-size: 14px;
  pointer-events: auto;
}
.btn-secondary { background: #fff; color: var(--dark); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f5f5f3; }
.btn-ghost { background: transparent; color: rgba(255,255,255,0.85); border: 1px solid rgba(255,255,255,0.2); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); }
.btn-danger { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; }
.btn-danger:hover { background: #fee4e2; }
.btn-sm { font-size: 12px; padding: 8px 12px; }
.btn-icon { padding: 6px 10px; min-width: auto; }

.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

.form-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; }

.image-list { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }

.image-item {
  display: grid; grid-template-columns: 80px 1fr auto;
  gap: 12px; align-items: center;
  padding: 12px; border: 1px solid var(--border); border-radius: 6px;
}
.image-item-thumb {
  width: 80px; height: 52px; object-fit: cover; border-radius: 4px; background: #eee;
}
.image-item input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px;
  font-family: inherit; font-size: 13px;
}
.image-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.field-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.field-grow { flex: 1; min-width: 200px; }

label span { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }

.news-form label,
.password-form label { display: block; margin-bottom: 14px; }

.news-form input,
.news-form textarea,
.password-form input,
.field-grow input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 14px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.img-preview {
  max-width: 100%; max-height: 200px; margin-top: 12px; border-radius: 6px;
  border: 1px solid var(--border); object-fit: contain; background: #f5f5f3;
}
.img-preview--sm { max-height: 120px; }

.news-admin-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.news-admin-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px; border: 1px solid var(--border); border-radius: 6px;
}
.news-admin-item img { width: 72px; height: 48px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.news-admin-item-body { flex: 1; min-width: 0; }
.news-admin-item-body strong { display: block; font-size: 14px; margin-bottom: 4px; }
.news-admin-item-body span { font-size: 12px; color: var(--muted); }
.news-admin-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

@media (max-width: 768px) {
  .admin-app { flex-direction: column; }
  .sidebar { width: 100%; }
  .image-item { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
