/* Shared styles for every page, in the style of AdminLTE: a light grey
   workspace, white cards with a soft shadow and a coloured top edge, and
   Bootstrap-like controls. Community branding sets --brand and --accent at
   runtime (see branding.js); everything else derives from them. */

:root {
  --brand: #1f6f5c;
  --brand-ink: #ffffff;          /* text on --brand, set for contrast */
  --accent: #f2a541;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #212529;
  --muted: #6c757d;
  --line: #dee2e6;
  --input-line: #ced4da;
  --danger: #dc3545;
  --ok: #28a745;
  --info: #17a2b8;
  --warning: #ffc107;
  --radius: 4px;
  --shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
  --sidebar-bg: #343a40;
  --sidebar-text: #c2c7d0;
  --sidebar-line: #4b545c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #454d55;
    --card: #343a40;
    --text: #f8f9fa;
    --muted: #adb5bd;
    --line: #56606a;
    --input-line: #6c757d;
    --danger: #e4606d;
    --ok: #3cb95a;
    --shadow: 0 0 1px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.5);
    --sidebar-bg: #2a2f34;
    --sidebar-line: #3f474e;
    color-scheme: dark;
  }
  /* Brand colours are often dark; lighten links so they stay readable. */
  a:not(.button) { color: color-mix(in srgb, var(--brand) 45%, #ffffff); }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; font-weight: 500; }
h1 { font-size: 26px; font-weight: 400; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
svg.icon { flex: none; vertical-align: middle; }

/* ---------- simple pages without the sidebar (login, shared post) ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  border-top: 3px solid var(--brand);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; margin-right: auto; min-width: 0; color: var(--text); }
.topbar .brand img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: var(--shadow); }
.topbar .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 420px; margin: 0 auto; padding: 16px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 20px; margin-bottom: 16px; position: relative;
}
/* A card that starts with a heading gets an AdminLTE-style header bar and a
   coloured top edge ("card-outline"). */
.card:has(> h2:first-child), .card:has(> .spread:first-child > h2) { border-top: 3px solid var(--brand); }
.card > h2:first-child, .card > .spread:first-child {
  margin: -16px -20px 16px; padding: 12px 20px; border-bottom: 1px solid var(--line);
  font-size: 17px; font-weight: 400;
}
.card > .spread:first-child h2 { margin: 0; font-size: 17px; font-weight: 400; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.spread > h1 { margin: 0; }
.page > .spread:first-child, .page > h1:first-child { margin-bottom: 16px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a {
  padding: 8px 14px; text-decoration: none; color: var(--muted); border: 1px solid transparent;
  border-radius: var(--radius) var(--radius) 0 0; margin-bottom: -1px; white-space: nowrap;
}
.tabs a.active { color: var(--text); background: var(--card); border-color: var(--line) var(--line) var(--card); }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
label.field .hint { display: block; font-weight: normal; color: var(--muted); font-size: 13px; margin-top: 4px; }
label.field .error { display: block; color: var(--danger); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=url], input[type=search],
input[type=date], input[type=datetime-local], input[type=time], select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--card);
  padding: 7px 12px; border: 1px solid var(--input-line); border-radius: var(--radius); min-height: 38px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: color-mix(in srgb, var(--brand) 60%, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}
button:focus-visible, .button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
textarea { min-height: 90px; resize: vertical; }
input[type=color] { width: 48px; height: 38px; padding: 2px; border: 1px solid var(--input-line); border-radius: var(--radius); background: var(--card); }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix > span {
  display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--input-line); border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius); background: var(--bg); color: var(--muted); font-size: 14px; white-space: nowrap;
}
.input-prefix > input { border-radius: 0 var(--radius) var(--radius) 0; }
.input-suffix > span { order: 2; border: 1px solid var(--input-line); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.input-suffix > input { border-radius: var(--radius) 0 0 var(--radius); }
.code-input { font-size: 28px !important; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }

button, .button {
  font: inherit; font-weight: 400; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius); border: 1px solid var(--input-line); background: var(--card); color: var(--text);
  text-decoration: none; min-height: 38px; line-height: 1.4; transition: filter .15s;
}
button:hover, .button:hover { text-decoration: none; filter: brightness(.96); }
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.danger, .button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.link { border: 0; background: none; color: var(--brand); padding: 0; min-height: 0; text-decoration: underline; }
button.small, .button.small { padding: 3px 10px; min-height: 30px; font-size: 13.5px; }
button:disabled { opacity: .55; cursor: default; filter: none; }
.block { width: 100%; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
a.rowlink { color: inherit; text-decoration: none; }
a.rowlink:hover .title { text-decoration: underline; color: var(--brand); }
.thumb { width: 44px; height: 44px; border-radius: var(--radius); object-fit: cover; background: var(--line); flex: none; }

/* Badges (AdminLTE "badge") */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: var(--radius); background: var(--line); color: var(--text); margin-left: 6px; white-space: nowrap; }
.pill.ok { background: var(--ok); color: #fff; }
.pill.warn { background: var(--warning); color: #1f2d3d; }
.pill.bad { background: var(--danger); color: #fff; }

/* ---------- small boxes (dashboard tiles) ---------- */
.small-boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.small-box { position: relative; border-radius: var(--radius); box-shadow: var(--shadow); color: #fff; overflow: hidden; display: block; text-decoration: none; }
.small-box:hover { text-decoration: none; filter: brightness(.95); }
.small-box .inner { padding: 12px 14px; position: relative; z-index: 1; }
.small-box .inner b { display: block; font-size: 34px; font-weight: 700; line-height: 1.1; }
.small-box .inner span { font-size: 15px; }
.small-box svg.icon { position: absolute; right: 12px; top: 14px; width: 64px; height: 64px; opacity: .25; }
.small-box .more { display: block; text-align: center; padding: 3px 0; background: rgba(0,0,0,.1); color: rgba(255,255,255,.9); font-size: 13.5px; position: relative; z-index: 1; }
.bg-info { background: var(--info); }
.bg-success { background: var(--ok); }
.bg-warning { background: var(--warning); color: #1f2d3d !important; }
.bg-warning .more { color: #1f2d3d; }
.bg-danger { background: var(--danger); }
.bg-brand { background: var(--brand); color: var(--brand-ink) !important; }

/* ---------- feedback ---------- */
.notice {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border-left: 4px solid var(--warning);
  background: var(--card); box-shadow: var(--shadow);
}
.notice.error { border-left-color: var(--danger); }
.notice.warning { border-left-color: var(--warning); margin-bottom: 12px; }
#toast {
  position: fixed; right: 16px; top: 70px; z-index: 100;
  background: var(--ok); color: #fff; padding: 10px 16px; border-radius: var(--radius); max-width: min(360px, calc(100vw - 32px));
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
#toast.error { background: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* ---------- login (AdminLTE "login-box") ---------- */
body.login-page { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; }
.login-head { text-align: center; margin: 40px 0 16px; }
.login-head img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; margin-bottom: 10px; box-shadow: var(--shadow); background: #fff; }
.login-head .mark {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center;
  background: var(--brand); color: var(--brand-ink); font-size: 34px; font-weight: 700; box-shadow: var(--shadow);
}
.login-head h1 { font-size: 30px; font-weight: 300; margin-bottom: 4px; }
.login-page .card { border-top: 3px solid var(--brand); }
.login-page > main { width: 100%; }

/* Links styled as tiles keep their own colours (beats the dark-mode link colour). */
a.small-box, a.small-box:hover { color: #fff; }
a.small-box.bg-warning, a.small-box.bg-warning:hover { color: #1f2d3d; }
a.small-box.bg-brand, a.small-box.bg-brand:hover { color: var(--brand-ink); }
.bg-brand .more { color: inherit; }
#view > .spread:first-child, #view > h1:first-child { margin-bottom: 16px; }
.small-box .inner b { font-size: clamp(24px, 3vw, 32px); }
/* Grid cells and inputs may shrink below their natural width (date pickers
   are wide), so fields never spill out of their card. */
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
input, select, textarea { min-width: 0; max-width: 100%; }

.center { text-align: center; }
/* Privacy notice */
.privacy h2 { margin-top: 24px; font-size: 18px; }
.privacy ul { padding-left: 20px; }
.privacy li { margin: 4px 0; }
