:root {
  --navy: #0f2942;
  --sky: #1e6091;
  --accent: #d97706;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

header {
  background: var(--navy);
  color: #fff;
  padding: 1rem 1.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.nav-wrap {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.5px;
}

.brand p {
  margin: 0;
  font-size: 0.85rem;
  color: #cbd5e1;
}

nav {
  display: flex;
  gap: 0.75rem;
}

nav a {
  color: #fff;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  background: rgba(255,255,255,0.08);
  transition: background 0.15s;
}

nav a:hover, nav a.active {
  background: var(--sky);
}

main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

/* News Cards */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.pill {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.pill.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card img {
  width: 100%;
  height: 210px;
  object-fit: cover;
  cursor: zoom-in;
}

.card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: #e0f2fe;
  color: var(--sky);
  margin-bottom: 0.5rem;
}

.card h2 {
  margin: 0.2rem 0 0.5rem;
  font-size: 1.15rem;
}

.meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

/* Database Controls */
.controls {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 0.75rem;
  background: var(--card);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

@media (max-width: 850px) {
  .controls { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .controls { grid-template-columns: 1fr; }
}

.controls input, .controls select, .controls button {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.controls button {
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  border: none;
}

.stats-bar {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: #f1f5f9;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover { background: #e2e8f0; }

tr:hover { background: #f8fafc; }

.thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: block;
}

.no-photo {
  width: 64px;
  height: 48px;
  background: #f1f5f9;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--muted);
}

/* Native Modal Dialog */
dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 820px;
  width: 92%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.35);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.75);
}

.modal-content {
  padding: 1.25rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.modal-header h3 { margin: 0; }

.close-btn {
  background: #e2e8f0;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
}

.modal-img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #0f172a;
  border-radius: 8px;
}

.modal-details {
  margin-top: 0.9rem;
  font-size: 0.95rem;
}