/* GiG Platform: Global Impact dark theme. Colors and type follow docs/BRAND.md. */

@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/montserrat-400.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/montserrat-500.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/montserrat-600.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/montserrat-700.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/montserrat-800.woff2") format("woff2"); }

:root {
  --navy: #0F2A47;
  --navy-deep: #0A1E34;
  --navy-raised: #143354;
  --blue: #2368AE;
  --blue-hover: #2B78C4;
  --grey: #797A7D;
  --light-grey: #F2F3F4;
  --white: #FFFFFF;
  --ink: #1A1A1A;
  --text: var(--light-grey);
  --text-muted: #B3BBC5;          /* derived light grey, 7:1 on navy */
  --border: rgba(121, 122, 125, 0.45);
  --border-strong: var(--grey);
  --ok: #4FB286;                  /* status colors: muted, kept out of branding */
  --warn: #D9A441;
  --error: #E06C6C;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --sidebar-w: 232px;
  --topbar-h: 64px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--navy-deep);
  color: var(--text);
  font: 400 15px/1.55 "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { color: var(--white); margin: 0 0 0.4em; line-height: 1.25; }
h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 0.8em; }
a { color: var(--white); text-decoration-color: rgba(255, 255, 255, 0.4); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--white); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; background: rgba(255, 255, 255, 0.06); padding: 0.1em 0.35em; border-radius: 4px; color: var(--light-grey); }
:focus-visible { outline: 2px solid var(--light-grey); outline-offset: 2px; }
.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; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--blue); color: var(--white); padding: 8px 12px; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.lead { font-size: 1.05rem; max-width: 70ch; }

/* Icons: Lucide outline, stroke thickened to match the brand's ~2.5px look. */
.icon { width: 20px; height: 20px; flex: none; stroke-width: 2.25; vertical-align: -4px; }
.icon-sm { width: 16px; height: 16px; vertical-align: -3px; }
.icon-lg { width: 40px; height: 40px; stroke-width: 1.75; color: var(--text-muted); }

/* App shell */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--navy);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; }
.brand img { height: 40px; width: auto; display: block; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-user form { margin: 0; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; text-decoration: none; font-weight: 500; }
.user-chip:hover { background: rgba(255, 255, 255, 0.06); }
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
/* The menu stays in place while the page scrolls; a long menu scrolls on its own. */
.sidebar {
  width: var(--sidebar-w); flex: none;
  position: sticky; top: var(--topbar-h); align-self: flex-start;
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  background: var(--navy);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sidebar a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-weight: 500;
}
.sidebar a:hover { background: rgba(255, 255, 255, 0.05); }
.sidebar a[aria-current="page"] { background: var(--blue); color: var(--white); font-weight: 600; }
.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 2.5vw, 40px) 64px; }
.main:focus { outline: none; }
.topbar .nav-toggle { display: none; }

@media (max-width: 860px) {
  .topbar .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 30; height: auto; align-self: auto;
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45); }
  .main { padding: 20px 16px 48px; }
  .user-chip span:not(.role-tag) { display: none; }
  .user-chip .role-tag { display: none; }
  .brand img { height: 34px; }
}

/* Page furniture */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; }
.crumb { margin: 0 0 8px; font-size: 0.9rem; }
.crumb a { text-decoration: none; color: var(--text-muted); display: inline-flex; gap: 6px; align-items: center; }
.crumb a:hover { color: var(--white); }
.section-title { margin-top: 28px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-weight: 500; font-size: 0.75rem; color: var(--text-muted); }

.card {
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card-link { display: block; text-decoration: none; color: inherit; transition: border-color 0.15s, background 0.15s; }
.card-link:hover { border-color: var(--blue); background: var(--navy-raised); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cards .card { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-2.tight, .grid-3.tight { gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.stack { display: grid; gap: 16px; }
.stack > .card { margin: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tool-line { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.tool-card { display: flex; gap: 14px; align-items: flex-start; }
.tool-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: var(--blue); color: var(--white); flex: none; }
.empty { text-align: center; padding: 48px 16px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-muted); }
.empty p { margin: 12px auto 0; max-width: 46ch; }
.plain-list { margin: 0; padding-left: 1.1em; }
.plain-list li { margin: 4px 0; }

/* Badges and chips */
.badge, .chip, .role-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.role-tag { background: rgba(255, 255, 255, 0.08); color: var(--light-grey); }
.chip { background: rgba(35, 104, 174, 0.25); color: var(--white); text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 0.8rem; }
.badge-active, .badge-ok { background: rgba(79, 178, 134, 0.16); color: #8FD8B6; }
.badge-disabled { background: rgba(224, 108, 108, 0.16); color: #F0A7A7; }
.badge-scheduled { background: rgba(217, 164, 65, 0.16); color: #EBC77F; }
.badge-expired, .badge-muted { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }

/* Flash messages and callouts */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; }
.flash-success { background: rgba(79, 178, 134, 0.12); border-color: rgba(79, 178, 134, 0.45); }
.flash-info { background: rgba(35, 104, 174, 0.18); border-color: rgba(35, 104, 174, 0.6); }
.flash-error { background: rgba(224, 108, 108, 0.12); border-color: rgba(224, 108, 108, 0.5); }
.flash-warning { background: rgba(235, 199, 127, 0.12); border-color: rgba(235, 199, 127, 0.5); display: block; }
.callout { background: var(--navy-deep); border: 1px solid var(--blue); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 16px; }
.codes { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 24px; }
.codes code { font-size: 1rem; letter-spacing: 0.05em; }
.steps { padding-left: 1.2em; margin: 0 0 10px; }
.qr-box { background: var(--white); border-radius: var(--radius-sm); padding: 12px; width: 204px; height: 204px; margin: 4px 0 12px; }
.qr-box img { display: block; width: 180px; height: 180px; image-rendering: pixelated; }
.key { word-break: break-all; }

/* Forms */
label, legend, .label { font-weight: 500; font-size: 0.9rem; color: var(--light-grey); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { margin-bottom: 8px; padding: 0; }
.field { display: grid; gap: 6px; }
.field-actions { align-self: end; }
.hint { font-size: 0.82rem; color: var(--text-muted); margin: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"],
input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%; max-width: 100%; min-width: 0;
  font: inherit; color: var(--white);
  background: var(--navy-deep);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 44px;
}
input::placeholder, textarea::placeholder { color: #8E97A3; }
input:focus, select:focus, textarea:focus { border-color: var(--light-grey); outline: none; box-shadow: 0 0 0 3px rgba(35, 104, 174, 0.6); }
textarea { resize: vertical; }
.input-code { font-size: 1.3rem; letter-spacing: 0.25em; max-width: 220px; text-align: center; }
.input-suffix { display: flex; align-items: center; gap: 10px; }
.input-suffix input { max-width: 120px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }
.tool-check { align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tool-check .tool-icon { width: 34px; height: 34px; }
.tool-check span span { display: block; }
.radio-cards { display: grid; gap: 8px; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.radio-card input { margin-top: 3px; accent-color: var(--blue); width: 18px; height: 18px; flex: none; }
.radio-card span span { display: block; font-weight: 400; }
.radio-card:has(input:checked) { border-color: var(--blue); background: rgba(35, 104, 174, 0.14); }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.row-form select, .row-form input { flex: 1 1 200px; width: auto; }
.inline-form { display: inline; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; align-items: end; }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } }
.sticky-actions { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--navy-deep) 35%); }
details.danger-zone { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
details.danger-zone summary { cursor: pointer; color: var(--text-muted); font-weight: 500; margin-bottom: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 0.92rem/1 "Montserrat", sans-serif;
  padding: 0 18px; min-height: 44px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary { background: transparent; color: var(--white); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--light-grey); background: rgba(255, 255, 255, 0.04); }
.btn-danger { background: transparent; color: #F0A7A7; border-color: rgba(224, 108, 108, 0.6); }
.btn-danger:hover { background: rgba(224, 108, 108, 0.12); }
.btn-link { background: none; border: 0; color: var(--text-muted); padding: 0; min-height: 32px; text-decoration: underline; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--light-grey); cursor: pointer; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--white); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--navy); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; color: var(--text-muted); background: rgba(0, 0, 0, 0.12); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.table-compact th, .table-compact td { padding: 8px 12px; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }
.table .details code { white-space: normal; word-break: break-word; background: none; padding: 0; color: var(--text-muted); }
.cell-icon { display: flex; gap: 10px; align-items: flex-start; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; }
.member-list { list-style: none; padding: 0; margin: 0; }
.member-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.member-list li:last-child { border-bottom: 0; }
.member-list form { margin: 0; }

/* Sign-in and error pages */
body.plain {
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, var(--navy) 0%, var(--navy-deep) 60%);
}
.plain-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.plain-card { width: 100%; max-width: 400px; background: var(--navy); border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; }
.plain-logo { display: block; height: 56px; width: auto; margin: 0 auto 28px; }
.plain-title { font-size: 1.4rem; text-align: center; margin-bottom: 18px; }
.plain-note { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin: 18px 0 0; }
.error-page { text-align: center; padding: 40px 0; }
.error-page h1 { font-size: 1.4rem; }

/* Installer */
.install-card { max-width: 640px; }
.checklist { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.checklist li { display: flex; gap: 8px; align-items: center; }
.checklist .bad { color: #F0A7A7; }
.checklist .good { color: #8FD8B6; }

/* Permissions table */
.perm-table { margin-bottom: 20px; }
.perm-table th:first-child { width: 52%; }
.perm-table .perm-label { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 0.92rem; color: var(--text); background: none; }
.center { text-align: center !important; }
.perm-table input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--blue); }
.perm-table input[disabled] { opacity: 0.55; }
.danger-card { border-color: rgba(224, 108, 108, 0.45); }

/* Wide tables: the action buttons stay visible at the right edge while the table scrolls sideways. */
.table .actions { position: sticky; right: 0; background: var(--navy); box-shadow: -8px 0 8px -8px rgba(0, 0, 0, 0.5); }
.table tbody tr:hover .actions { background: #11304f; }
.table th:last-child:has(.sr-only) { position: sticky; right: 0; background: #0d2640; }
@media (min-width: 1600px) { .cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.security-list li { align-items: flex-start; } .security-list li span { color: var(--text); }

/* Backups page */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card-head form { margin: 0; }
fieldset.radio-cards { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.radio-cards legend { padding: 0; margin-bottom: 6px; }
.radio-card.is-disabled { opacity: 0.55; cursor: not-allowed; }
.inline-details { display: inline-block; }
.inline-details summary { list-style: none; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details .row-form { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

/* Respect "reduce motion" in the operating system. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Long values (links, keys) wrap instead of widening the page on phones. */
.stack > * { min-width: 0; }
code.key, .link-box code, .link-box a { overflow-wrap: anywhere; word-break: break-all; }
p code, .hint code { overflow-wrap: anywhere; }
.row-actions { flex-wrap: wrap; }
input[type="file"] { max-width: 100%; min-width: 0; }

/* Health check */
.health-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.health-list li { display: flex; gap: 10px; align-items: flex-start; }
.health-list li > div { display: flex; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.health-list .hint { flex-basis: 100%; margin: 0; }
.health-ok > .icon { color: #8FD8B6; }
.health-warn > .icon { color: #EBC77F; }
.health-bad > .icon { color: #F0A7A7; }

/* Upload progress (public/assets/js/upload.js), used by every file upload */
.upload-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; text-align: left; flex-basis: 100%; }
.upload-row { background: var(--navy-deep); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.88rem; }
.upload-head, .upload-meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.upload-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.upload-pct { font-variant-numeric: tabular-nums; font-weight: 600; }
.upload-bar { height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; margin: 8px 0 6px; overflow: hidden; }
.upload-bar span { display: block; height: 100%; width: 0; background: var(--blue); transition: width 0.3s; }
.upload-meta { color: var(--text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.upload-row.is-ok .upload-bar span { background: #4FB286; }
.upload-row.is-ok .upload-time { color: #8FD8B6; }
.upload-row.is-bad .upload-time { color: #F0A7A7; }

/* Project settings: visitor pages logo */
.logo-row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview { width: 220px; min-height: 96px; display: flex; align-items: center; justify-content: center; padding: 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: radial-gradient(circle at 50% -10%, #143354 0%, #0F2A47 35%, #0A1E34 100%); }
.logo-preview img { max-width: 100%; max-height: 64px; width: auto; height: auto; }
.logo-row .field { flex: 1 1 260px; }
