:root {
  --bg: #0b1220;
  --card: #131c2e;
  --border: #233149;
  --text: #e8eef7;
  --muted: #9fb0c8;
  --accent: #3b82f6;
  --danger: #ef4444;
  --ok: #22c55e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--card);
}
.topbar .brand { font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: var(--text); }
.whoami { color: var(--muted); font-size: 13px; }

/* Shell: sidebar + main content */
.shell { display: flex; align-items: stretch; }
body.app .shell { height: calc(100vh - 55px); }
.sidebar { width: 230px; flex: 0 0 230px; overflow-y: auto; background: var(--card);
  border-right: 1px solid var(--border); padding: 20px 14px; }
.sidebar-newpage { display: block; width: 100%; text-align: center; margin-bottom: 18px; }
.sidebar .sb-group { margin-bottom: 6px; }
.sidebar .sb-group:last-child { margin-bottom: 0; }
.sidebar .sb-country { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; margin-bottom: 2px;
  border-radius: 7px; cursor: pointer; list-style: none; user-select: none; }
.sidebar .sb-country::-webkit-details-marker { display: none; }
.sidebar .sb-country:hover { background: rgba(255,255,255,.05); color: var(--text); }
.sidebar .sb-country::before { content: "▸"; font-size: 10px; transition: transform .15s ease; flex: 0 0 auto; }
.sidebar .sb-group[open] > .sb-country::before { transform: rotate(90deg); }
.sidebar .sb-country .flag { font-size: 13px; }
.sidebar .sb-schools { display: flex; flex-direction: column; gap: 1px; }
.sidebar .sb-link { display: block; padding: 7px 10px; border-radius: 7px; color: var(--text);
  text-decoration: none; font-size: 13.5px; border-left: 2px solid transparent; }
.sidebar .sb-link:hover { background: rgba(255,255,255,.05); }
.sidebar .sb-link.active { background: rgba(59,130,246,.15); border-left-color: var(--accent); font-weight: 600; }

/* Folder-tree headers (e.g. "Type Rating" > "320"/"737") keep the same
   color/format as a school name link (.sb-link) rather than the bold
   uppercase country style — only the expand/collapse triangle is added. */
.sidebar .sb-folder-summary { display: flex; align-items: center; gap: 6px; cursor: pointer;
  list-style: none; user-select: none; margin-bottom: 2px; }
.sidebar .sb-folder-summary::-webkit-details-marker { display: none; }
.sidebar .sb-folder-summary::before { content: "▸"; font-size: 10px; color: var(--muted);
  transition: transform .15s ease; flex: 0 0 auto; }
.sidebar .sb-group[open] > .sb-folder-summary::before { transform: rotate(90deg); }
.sidebar .sb-folder-summary .sb-link { flex: 1; padding-left: 0; }
.sidebar .sb-folder .sb-schools { padding-left: 14px; }
.shell > .content { flex: 1; min-width: 0; overflow-y: auto; }

.wrap { margin: 0; padding: 20px 24px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* Homepage-embedded dashboard pages (DGCA CPL Requirements, Type Rating) */
.card.embed { padding: 0; overflow: hidden; }
.embed-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); }
.embed-head h2 { margin: 0; }
.embed-frame { display: block; width: 100%; height: 640px; border: 0; background: #fff; }
.embed-frame-short { height: 320px; }

/* Cards & forms */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px; margin-bottom: 24px;
}
.auth-card { max-width: 380px; margin: 8vh auto 0; }
.row-2col { display: flex; gap: 20px; }
.row-2col .card { flex: 1; min-width: 0; }

.gc-table-wrap { overflow-x: auto; margin-bottom: 14px; }
.gc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.gc-table th, .gc-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.gc-table th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.gc-table td { padding: 4px 6px; }
.gc-table td input { margin: 0; padding: 7px 8px; font-size: 13.5px; background: transparent; border-color: transparent; }
.gc-table td input:hover { border-color: var(--border); }
.gc-table td input:focus { background: var(--bg); border-color: var(--accent); }
.gc-admin { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.gc-admin .row-form input { flex: 1 1 120px; }

.notice-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.notice { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.notice:last-child { border-bottom: 0; padding-bottom: 0; }
.notice-body { font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }
.notice-file { display: inline-block; margin-top: 6px; font-size: 12.5px; color: var(--accent); text-decoration: none; }
.notice-file:hover { text-decoration: underline; }
.notice-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.notice-form { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.notice-form textarea { margin: 0; min-height: 60px; }
.notice-form .row-form input[type=file] { flex: 1 1 160px; padding: 8px 10px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-block; padding: 10px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:hover { border-color: var(--accent); }

.linkbtn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 13px; font-weight: 600; padding: 0;
}
.linkbtn.danger { color: var(--danger); }
.inline { display: inline; }
.inline select { width: auto; margin: 0; }

/* Add-person row form */
.row-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-form input, .row-form select { width: auto; margin-top: 0; flex: 1 1 160px; }

/* People table */
table.people { width: 100%; border-collapse: collapse; font-size: 14px; }
table.people th, table.people td {
  text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border);
}
table.people th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr.inactive { opacity: .5; }
td.actions { display: flex; gap: 14px; align-items: center; }
td.actions input { width: 130px; margin: 0; }

/* Messages */
.flash { background: rgba(34,197,94,.12); border: 1px solid var(--ok); color: var(--text);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }
.error { background: rgba(239,68,68,.12); border: 1px solid var(--danger); color: var(--text);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }


/* Page view (full-width) */
.page-main { display: flex; flex-direction: column; height: calc(100vh - 55px); }
.pageview { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.pagebar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 22px; background: var(--card); border-bottom: 1px solid var(--border); }
.pagebar .left { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.pagebar .back { color: var(--muted); text-decoration: none; font-size: 20px; line-height: 1; }
.pagebar .pt { font-weight: 600; font-size: 15px; white-space: nowrap; }
.pagebar .pt-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pagebar .actions { display: flex; gap: 9px; align-items: center; flex: 0 0 auto; }

.editbar { display: flex; align-items: center; gap: 12px; padding: 9px 22px;
  background: rgba(59,130,246,.12); border-bottom: 1px solid var(--accent); font-size: 13px; }
.editbar .tip b { color: var(--accent2, #60a5fa); }
.editbar .grow { flex: 1; }

.pageframe { flex: 1; width: 100%; border: 0; background: #fff; min-height: 0; }
.pageview.editing .pageframe { box-shadow: inset 0 0 0 2px var(--accent); }

/* Brochures strip for non-dashboard pages only. Dashboards render their own
   brochures section inline under the hero (see dashboard/render.go), which is
   where they belong; plain pages have no hero to sit under, so they get this
   docked strip instead. */
.brochures { flex: 0 0 auto; background: var(--card); border-top: 1px solid var(--border); }
.broc-summary { display: flex; align-items: center; gap: 9px;
  padding: 13px 22px; font-size: 13px; font-weight: 600; }
.broc-count { color: var(--muted); font-weight: 400; font-size: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; }
.broc-body { padding: 0 22px 16px; }
.broc-item { display: flex; align-items: baseline; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--border); }
.broc-item:last-of-type { border-bottom: 0; }
.broc-name { color: var(--accent); text-decoration: none; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.broc-name:hover { text-decoration: underline; }
.broc-meta { color: var(--muted); font-size: 12px; flex: 1; }
.broc-form { padding-top: 12px; border-top: 1px solid var(--border); margin-top: 4px; }
.broc-form input[type=file] { flex: 1 1 200px; padding: 8px 10px; }

.btn { display: inline-flex; align-items: center; gap: 7px; }
.btn.sm { padding: 7px 12px; font-size: 13px; }

/* Component editor — preview-first: the form is hidden, sections pop over the
   preview on click. */
.wrap.wide { max-width: 1280px; }
.editor-layout { display: flex; flex-direction: column; gap: 12px; }
.editor-layout .editor { display: contents; } /* editbar + popover flow into the column */
.ed-store[hidden] { display: none; }          /* holds all fields (still submitted) */
.ed-hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.save-status { color: var(--muted); font-size: 12px; margin-right: 8px; }
.editbar .add-block-type { width: auto; margin: 0; }
.editor-preview.full { width: 100%; }
#preview { width: 100%; height: calc(100vh - 128px); border: 1px solid var(--border); border-radius: 12px; background: #fff; }

.ed-popover { position: fixed; z-index: 60; width: min(560px, 92vw); max-height: 82vh; overflow: auto;
  background: var(--card); border: 1px solid var(--accent); border-radius: 12px;
  box-shadow: 0 26px 64px -18px rgba(0,0,0,.85); }
.ed-popover[hidden] { display: none; }
.pop-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--border); }
.pop-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pop-body { padding: 14px 16px 16px; }
.pop-body > .ed-sec { background: transparent; border: 0; padding: 0; margin: 0; }
.pop-body > .ed-sec > h2, .pop-body > .ed-sec > .ed-head { display: none; } /* title is in pop-head */
.pop-body > .block-edit { border: 0; padding: 0; background: transparent; }
.pop-body > .block-edit > .block-edit-head .block-tag { display: none; } /* type shown in pop-head */
.pop-body > .tab-edit { border: 0; padding: 0; margin: 0; background: transparent; }
.pop-body > .tab-edit > .tab-blocks { display: none; } /* edit blocks by clicking them in the preview */
.editor { padding-bottom: 60px; }
.editbar.sticky { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; margin-bottom: 22px; }
.ed-sec { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.ed-sec > h2 { font-size: 15px; margin-bottom: 14px; }
.ed-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.ed-head h2 { font-size: 15px; margin: 0; }
.editor label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.editor input, .editor select, .editor textarea { margin-top: 5px; }

.pills-edit, .stats-edit { display: flex; flex-direction: column; gap: 8px; }
.pill-edit { display: flex; gap: 8px; align-items: center; }
.pill-edit input { flex: 1; margin: 0; }
.pill-edit select { width: auto; margin: 0; }
.stat-edit { display: flex; gap: 8px; align-items: center; }
.stat-edit input { margin: 0; }
.stat-edit .w-icon { width: 70px; flex: 0 0 auto; }

.tab-edit { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; background: rgba(255,255,255,.02); }
.tab-edit-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.tab-edit-head .tab-name { margin: 0; font-weight: 600; }
.tab-blocks { display: flex; flex-direction: column; gap: 12px; }
.card-edit { border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; background: var(--bg); }
.card-edit-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.card-edit-head .card-title { margin: 0; flex: 1; font-weight: 600; }
.card-edit-head .width-sel { width: auto; margin: 0; }
.rows-edit { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.rows-edit td { padding: 3px 4px; }
.rows-edit td input { margin: 0; }
.rows-edit td:last-child { width: 28px; text-align: center; }
.opaque-edit { display: flex; align-items: center; gap: 10px; border: 1px dashed var(--border);
  border-radius: 9px; padding: 10px 14px; background: rgba(255,255,255,.02); }
.opaque-label { flex: 1; font-size: 13px; color: var(--muted); }
.tab-actions { margin-top: 12px; display: flex; gap: 8px; align-items: center; }
.tab-actions .add-block-type { width: auto; margin: 0; }

/* highlight when a block/section is targeted by a preview click */
.ed-focus { animation: edFocus 1.6s ease-out; border-radius: 10px; }
@keyframes edFocus {
  0%   { box-shadow: 0 0 0 2px var(--accent), 0 0 0 7px rgba(59,130,246,.25); }
  100% { box-shadow: 0 0 0 2px transparent, 0 0 0 7px transparent; }
}

.block-edit { border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; background: var(--bg); }
.block-edit-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.block-edit-head .grow { flex: 1; }
.block-edit-head .card-title { margin: 0; flex: 1; font-weight: 600; }
.block-edit-head .width-sel { width: auto; margin: 0; }
.block-tag { font-family: var(--mono, ui-monospace, Menlo, monospace); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; }
.block-edit textarea, .block-edit > input[type=text], .block-edit > select { margin: 0 0 4px; }
.block-edit .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.items-body td input, .trows-body td input, .th-row th input { margin: 0; }
.th-row th { padding: 2px 4px; }
.table-edit { overflow-x: auto; }
