:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #1f2a28;
  --muted: #6b7775;
  --line: #e2e7e5;
  --brand: #2f6f5e;
  --brand-dark: #245546;
  --danger: #b03a3a;
  --draft: #b5862b;
  --approved: #2f6f5e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.1rem;
}

/* Header */
.site-header {
  background: var(--brand);
  color: #fff;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}
.brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
}
.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.nav a, .nav .linklike {
  color: #e8f1ee;
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.95rem;
}
.nav a:hover, .nav .linklike:hover { background: rgba(255, 255, 255, 0.14); }
.nav a.active { background: rgba(255, 255, 255, 0.22); }
.linklike {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}
.inline-form { display: inline; margin: 0; }

/* Main + footer */
.main { flex: 1 0 auto; padding-top: 1.6rem; padding-bottom: 2.4rem; }
.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem 0;
  background: var(--surface);
}
.site-footer p { margin: 0; }

/* Typography */
h1 { font-size: 1.6rem; margin: 0 0 0.6rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 0.6rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Cards / sections */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.4rem;
}
.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.auth-card { margin-top: 2.5rem; }
.welcome { margin-bottom: 1.2rem; }

/* Banner (announcements) */
.banner {
  background: #fff7e6;
  border: 1px solid #f0d89b;
  color: #6b531a;
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin-bottom: 0.8rem;
  font-weight: 500;
}

/* Flash messages */
.flash {
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.flash-success { background: #e7f4ef; border-color: #b6dccd; color: #1d5e4a; }
.flash-error { background: #fbeaea; border-color: #e6b9b9; color: #8f2d2d; }
.flash-notice { background: #eef3fb; border-color: #c3d4ee; color: #2c4a7a; }

/* Tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
.tile h2 { margin: 0 0 0.3rem; color: var(--brand-dark); font-size: 1.1rem; }
.tile p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.stack label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 500; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}
input[type="text"], input[type="password"], input[type="url"],
input[type="number"], input[type="date"], input[type="time"],
select, textarea {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}
.checkbox { flex-direction: row !important; align-items: center; gap: 0.5rem; font-weight: 400; }
.checkbox input { width: auto; }
input[type="file"] { padding: 0.4rem 0; border: none; }

/* Buttons */
.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  line-height: 1.2;
}
.button:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.button.primary { width: 100%; padding: 0.65rem 1rem; }
.button.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.button.ghost {
  background: #fff;
  color: var(--brand-dark);
}
.button.ghost:hover { background: #eef4f2; }
.button.danger {
  background: #fff;
  color: var(--danger);
  border-color: #e3bcbc;
}
.button.danger:hover { background: #fbeaea; }

/* Document lists */
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
  box-shadow: var(--shadow);
}
.doc-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
}
.doc-title { font-weight: 600; }
.doc-sub { color: var(--muted); }
.doc-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  color: #fff;
  background: var(--muted);
}
.badge-approved { background: var(--approved); }
.badge-draft { background: var(--draft); }
.badge-year { background: var(--brand-dark); }

/* Gatehouse background image (home + login pages) */
body.home-bg {
  background-image:
    linear-gradient(rgba(244, 246, 245, 0.32), rgba(244, 246, 245, 0.46)),
    url("/static/gatehouse.png");
  background-size: cover;
  background-position: center 30%;
  background-attachment: fixed;
  background-repeat: no-repeat;
}
/* Let the background show through the footer instead of a solid white bar. */
body.home-bg .site-footer {
  background: transparent;
  border-top-color: rgba(255, 255, 255, 0.5);
}
body.home-bg .site-footer p {
  color: var(--ink);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.85);
}
/* Lift the welcome text onto a soft translucent panel so it stays readable
   over the photo. */
body.home-bg .welcome {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

@media (max-width: 540px) {
  .grid-2 { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  /* Fixed backgrounds can be janky on mobile; scroll with the page instead. */
  body.home-bg { background-attachment: scroll; }
}
