:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --paper: #ffffff;
  --soft: #f9fafb;
  --navy: #0d2b57;
  --red: #e63946;
  --blue: #1d4ed8;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar,
.brand-row,
.main-nav,
main,
.site-footer {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
}

.restricted-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--navy);
  font-weight: 700;
}

.brand-row {
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(280px, 1fr);
  align-items: center;
  gap: 28px;
  padding: 18px 0;
}

.brand img {
  display: block;
  width: 100%;
  height: auto;
}

.search-form {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.search-form input,
.login-panel input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 12px;
  font: inherit;
}

.search-form button,
.login-panel button,
.primary-link,
.admin-filter button,
.article-form button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.search-form button:hover,
.login-panel button:hover,
.primary-link:hover,
.admin-filter button:hover,
.article-form button:hover {
  background: #d32f2f;
  transform: translateY(-1px);
}

.main-nav {
  display: flex;
  gap: 24px;
  min-height: 44px;
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--navy);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  padding: 40px 0 30px;
}

.featured-story {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 40px;
  background: #0d2b57;
  color: #fff;
  border-radius: 12px;
}

.eyebrow {
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.featured-story .eyebrow {
  text-shadow:
    -1px -1px 0 rgba(0,0,0,0.7), 1px -1px 0 rgba(0,0,0,0.7),
    -1px 1px 0 rgba(0,0,0,0.7), 1px 1px 0 rgba(0,0,0,0.7);
}

.featured-story h1 {
  max-width: 780px;
  margin: 12px 0 14px;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1;
  text-shadow:
    -1px -1px 1px rgba(0,0,0,0.9), 1px -1px 1px rgba(0,0,0,0.9),
    -1px 1px 1px rgba(0,0,0,0.9), 1px 1px 1px rgba(0,0,0,0.9),
    0 0 8px rgba(0,0,0,0.6);
}

.featured-story p {
  max-width: 680px;
  color: #e5eaf1;
  font-size: 18px;
  line-height: 1.45;
  text-shadow:
    -1px -1px 0 rgba(0,0,0,0.8), 1px -1px 0 rgba(0,0,0,0.8),
    -1px 1px 0 rgba(0,0,0,0.8), 1px 1px 0 rgba(0,0,0,0.8),
    0 0 6px rgba(0,0,0,0.5);
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: #d7deea;
  font-size: 13px;
}

.featured-story .story-meta {
  text-shadow:
    -1px -1px 0 rgba(0,0,0,0.7), 1px -1px 0 rgba(0,0,0,0.7),
    -1px 1px 0 rgba(0,0,0,0.7), 1px 1px 0 rgba(0,0,0,0.7);
}

.side-rail {
  border-top: 4px solid var(--red);
  background: var(--soft);
  padding: 22px;
}

.side-rail h2,
.section-header h2 {
  margin: 0;
  font-size: 22px;
}

.side-rail ol {
  margin: 16px 0 0;
  padding-left: 22px;
}

.side-rail li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  line-height: 1.35;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 24px 0 16px;
}

.section-header a {
  color: var(--blue);
  font-weight: 700;
}

.news-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding-bottom: 40px;
}

.news-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  background: var(--paper);
}

.news-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}

.news-card h3 {
  margin: 14px 18px 10px;
  font-size: 20px;
  line-height: 1.3;
}

.news-card p {
  margin: 0 18px 18px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.news-card h3 {
  margin: 10px 18px;
  font-size: 21px;
  line-height: 1.2;
}

.news-card p,
.muted {
  color: var(--muted);
  line-height: 1.5;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 40px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  margin-top: 60px;
}

.site-footer > div {
  max-width: 720px;
}

.footer-quote {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.compact .topbar {
  min-height: 56px;
}

.narrow-page {
  max-width: 760px;
  padding: 44px 0;
}

.search-form.full {
  margin: 18px 0;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--navy);
}

.login-shell {
  width: min(460px, calc(100% - 32px));
  margin: 0 auto;
}

.login-brand img {
  display: block;
  width: min(340px, 100%);
  margin: 0 auto 18px;
}

.login-panel {
  background: #fff;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.login-panel h1 {
  margin: 0 0 8px;
}

.login-panel p {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-panel label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 700;
}

.login-panel button {
  width: 100%;
  margin-top: 18px;
}

.alert {
  border-left: 4px solid var(--red);
  background: #fff1ef;
  padding: 12px;
  color: #8e1d14;
}

.version-badge {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  opacity: 0.7;
}

.admin-version {
  text-align: right;
}

.admin-page {
  background: var(--soft);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
  padding: 0 24px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.admin-brand {
  font-weight: 900;
}

.admin-header nav {
  display: flex;
  gap: 18px;
  font-weight: 700;
}

.admin-layout {
  padding: 34px 0;
}

.welcome-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.welcome-panel h1 {
  margin: 8px 0 8px;
}

.admin-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.action-card {
  display: grid;
  gap: 8px;
  min-height: 140px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 24px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.action-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.08);
}

.action-card strong {
  font-size: 20px;
}

.action-card span {
  color: var(--muted);
  line-height: 1.45;
}

.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title-row h1 {
  margin: 8px 0 0;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 4px;
  font-weight: 800;
}

.primary-link {
  background: var(--red);
  color: #fff;
}

.secondary-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
}

.admin-filter {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 110px;
  gap: 10px;
  margin-bottom: 18px;
}

.admin-filter input,
.admin-filter select,
.article-form input,
.article-form select,
.article-form textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 12px;
  background: #fff;
  font: inherit;
}

.admin-filter button,
.article-form button {
  min-height: 42px;
  border: 0;
  border-radius: 4px;
  padding: 0 18px;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

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

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

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

.admin-table tr:hover {
  background: var(--soft);
}

.admin-table th {
  color: var(--navy);
  font-size: 13px;
  text-transform: uppercase;
}

.admin-table small {
  display: block;
  margin-top: 4px;
  color: var(--blue);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.table-actions form {
  margin: 0;
}

.danger-link {
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
}

.danger-link:hover {
  text-decoration: underline;
}

.article-form {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 22px;
}

.article-form label {
  font-weight: 800;
  color: var(--navy);
}

.article-form textarea {
  min-height: 320px;
  padding: 12px;
  line-height: 1.5;
  resize: vertical;
}

.cover-upload-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
}

.cover-upload-box input[type='file'] {
  padding: 8px;
  background: #fff;
}

.cover-upload-box small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.cover-upload-box img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}

.article-page {
  width: min(860px, calc(100% - 32px));
  padding: 42px 0;
}

.article-page h1 {
  margin: 10px 0 12px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
}

.article-subtitle {
  color: var(--muted);
  font-size: 21px;
  line-height: 1.45;
}

.article-page .story-meta {
  color: var(--muted);
  margin: 18px 0 24px;
}

.article-cover {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 28px;
}

.article-content {
  font-size: 18px;
  line-height: 1.8;
  color: #374151;
}

.article-content p {
  margin-bottom: 1.5em;
}

.search-results {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.result-item {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.result-item h2 {
  margin: 8px 0;
}

@media (max-width: 820px) {
  .brand-row,
  .hero-grid,
  .news-list,
  .admin-actions,
  .admin-filter,
  .form-grid,
  .cover-upload-box {
    grid-template-columns: 1fr;
  }

  .main-nav {
    overflow-x: auto;
    gap: 18px;
  }

  .featured-story {
    min-height: 330px;
    padding: 24px;
  }
}

@media (max-width: 560px) {
  .topbar,
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 0;
  }

  .search-form {
    flex-direction: column;
  }

  .search-form button {
    width: 100%;
  }
}
