:root {
  --bg: #f3f6f4;
  --bg-accent: #e8f0ec;
  --surface: #ffffff;
  --ink: #1c2b26;
  --muted: #5a6b64;
  --brand: #1a5f4a;
  --brand-dark: #0f3d31;
  --brand-soft: #d4ebe3;
  --accent: #c45c26;
  --border: #d5e0db;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(28, 43, 38, 0.08);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #d4ebe3 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #f0e6dc 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
  background-attachment: fixed;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-dark);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--brand-dark);
  letter-spacing: -0.02em;
}

.nav-toggle {
  margin-left: auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

.nav {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem 1rem;
  box-shadow: var(--shadow);
}

.nav.open {
  display: flex;
}

.nav a,
.nav-user {
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  color: var(--ink);
  font-weight: 500;
}

.nav a.active,
.nav a:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.nav-user {
  color: var(--muted);
  font-size: 0.9rem;
}

.nav-logout {
  color: var(--accent) !important;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.5rem 1rem 2.5rem;
}

.page-title {
  font-family: var(--display);
  font-size: clamp(1.6rem, 4vw, 2rem);
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
  color: var(--brand-dark);
}

.page-sub {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
}

.grid-2 {
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .nav-toggle {
    display: none;
  }

  .nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    position: static;
    margin-left: auto;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    gap: 0.15rem;
  }

  .nav a,
  .nav-user {
    padding: 0.45rem 0.65rem;
    font-size: 0.92rem;
  }

  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.35rem;
}

.field {
  margin-bottom: 0.95rem;
}

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

input[type="text"],
input[type="password"],
input[type="email"],
input[type="month"],
input[type="search"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  background: #fbfcfc;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 95, 74, 0.18);
  background: #fff;
}

input[type="checkbox"] {
  width: auto;
  margin: 0 0.5rem 0 0;
  accent-color: var(--brand);
}

.checkbox-label {
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0;
  cursor: pointer;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 12px;
  padding: 0.8rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

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

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

.btn-secondary {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 9px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 500;
}

.alert-success {
  background: var(--ok-bg);
  color: var(--ok);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-info {
  background: var(--warn-bg);
  color: var(--warn);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-admin {
  background: #efe6ff;
  color: #6941c6;
}

.badge-user {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.badge-off {
  background: #f2f4f7;
  color: #667085;
}

.autocomplete {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.autocomplete-list li {
  padding: 0.7rem 0.8rem;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.95rem;
}

.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.autocomplete-empty {
  color: var(--muted);
  cursor: default !important;
  pointer-events: none;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.75rem 1.4rem;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-family: var(--display);
  margin: 0 0 0.35rem;
  font-size: 1.7rem;
  color: var(--brand-dark);
}

.login-card p {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem 0.5rem;
}

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

.content-preview {
  white-space: pre-wrap;
  word-break: break-word;
}

.filters {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .filters {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }
}

@media print {
  .topbar,
  .footer,
  .filters,
  .actions,
  .btn,
  .nav-toggle {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .card {
    box-shadow: none;
    border: 0;
    padding: 0;
  }
}
