:root {
  --navy: #1F4E78; --navy-dark: #17395a; --band: #D9E1F2; --ok: #C6EFCE; --ok-text: #006100;
  --warn: #FFEB9C; --warn-text: #9C5700; --danger: #FFC7CE; --danger-text: #C00000; --border: #d0d7de;
}
* { box-sizing: border-box; }
body { font-family: Arial, "Segoe UI", sans-serif; margin: 0; background: #f4f6f9; color: #222; }
a { color: var(--navy); }

header.topbar { background: var(--navy); color: #fff; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.brand-row { display: flex; align-items: center; gap: 14px; }
.wordmark { display: flex; align-items: center; gap: 8px; padding-right: 14px; border-right: 1px solid rgba(255,255,255,0.25); text-decoration: none; color: inherit; cursor: pointer; }
.wordmark:hover .name { opacity: 0.85; }
.wordmark .mark { width: 34px; height: 34px; border-radius: 7px; background: #fff; color: var(--navy); font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; padding: 3px; box-sizing: border-box; }
.wordmark .mark-logo { width: 100%; height: 100%; object-fit: contain; }
.wordmark .name { font-size: 13px; font-weight: 700; letter-spacing: 0.5px; line-height: 1.2; }
.wordmark .name small { display: block; font-weight: 400; font-size: 9px; color: #cdd9e6; letter-spacing: 0.4px; }
.app-version { font-size: 11px; color: #cdd9e6; opacity: 0.85; letter-spacing: 0.3px; }
header.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
header.topbar .sub { font-size: 12px; color: #cdd9e6; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.top-actions a, .top-actions button.linklike { color: #fff; text-decoration: none; opacity: 0.9; background: none; border: none; cursor: pointer; font-size: 13px; padding: 0; }
.top-actions a:hover, .top-actions button.linklike:hover { opacity: 1; text-decoration: underline; }
select.company-select { padding: 6px 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.08); color: #fff; font-size: 12.5px; }
select.company-select option { color: #222; }

.subnav { background: var(--navy-dark); padding: 0 24px; display: flex; gap: 4px; flex-wrap: wrap; }
.subnav a { color: #cdd9e6; text-decoration: none; font-size: 12.5px; font-weight: 600; padding: 11px 14px; display: inline-block; border-bottom: 3px solid transparent; }
.subnav a:hover { color: #fff; }
.subnav a.active { color: #fff; border-bottom-color: #fff; }

.subnav-groups { position: relative; }
.nav-group { position: relative; }
.nav-group-btn { background: none; border: none; color: #cdd9e6; font-size: 12.5px; font-weight: 600; padding: 11px 14px; cursor: pointer; border-bottom: 3px solid transparent; font-family: inherit; }
.nav-group-btn .caret { font-size: 9px; margin-left: 3px; position: relative; top: -1px; }
.nav-group-btn:hover { color: #fff; }
.nav-group-btn.active { color: #fff; border-bottom-color: #fff; }
.nav-group-btn.open { color: #fff; background: rgba(255,255,255,0.08); }
.nav-dropdown { display: none; position: absolute; top: 100%; left: 0; min-width: 280px; background: #fff; border-radius: 0 0 8px 8px; box-shadow: 0 6px 16px rgba(0,0,0,0.18); z-index: 50; padding: 6px 0; }
.nav-dropdown.open { display: block; }
.nav-dropdown a { display: block; color: var(--navy); text-decoration: none; font-size: 13px; font-weight: 600; padding: 10px 16px; border-bottom: none; }
.nav-dropdown a:hover { background: #f4f6f9; }
.nav-dropdown a.active { background: var(--band); color: var(--navy); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 22px; }
.card { background: #fff; border-radius: 8px; padding: 18px 20px; margin-bottom: 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.card h3 { margin: 0 0 4px 0; color: var(--navy); font-size: 16px; }
.card .sub { font-size: 12px; color: #777; margin-bottom: 14px; line-height: 1.5; }

.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; }
.form-grid .field { display: flex; flex-direction: column; }
.form-grid label { font-size: 11px; font-weight: 600; color: #555; margin-bottom: 4px; }
.form-grid input, .form-grid select { padding: 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 13px; width: 100%; }

.btn { padding: 9px 18px; background: var(--navy); color: #fff; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--navy-dark); }
.btn.secondary { background: #6b7a8f; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: var(--danger-text); }

/* Page-navigation loading bar — a thin animated bar across the very top of
   the window, shown from the moment a link is clicked or a form is
   submitted until the next page finishes loading. Same pattern used by
   GitHub/YouTube, so it reads as "the page is working" without needing any
   explanation. */
#page-loading-bar {
  position: fixed; top: 0; left: 0; height: 5px; width: 0%;
  background: linear-gradient(90deg, #f2994a, #eb5e28);
  z-index: 99999; opacity: 0; transition: width 0.25s ease, opacity 0.3s ease;
  pointer-events: none;
}
#page-loading-bar.active { opacity: 1; }

/* Button "working…" state — added to the specific button that triggered a
   form submit (or a clicked <a class="btn">), so slow actions like a BC
   sync (can take several minutes — see README) show an obvious spinner and
   can't be double-clicked while in flight. */
.btn.btn-loading { opacity: 0.7; cursor: wait; pointer-events: none; position: relative; padding-right: 30px; }
.btn.btn-loading::after {
  content: ''; position: absolute; right: 10px; top: 50%; width: 12px; height: 12px;
  margin-top: -6px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Post-login welcome page (templates/welcome.html) — a grid of section
   groups, each a colored icon + label header followed by a grid of
   clickable page tiles, replacing a flat wall of same-colored buttons. */
.welcome-intro { font-size: 14px; color: #444; }
.welcome-groups { display: flex; flex-direction: column; gap: 26px; margin-top: 18px; }
.welcome-group-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.welcome-group-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.welcome-group-icon svg { width: 17px; height: 17px; }
.welcome-group-header h4 { margin: 0; font-size: 15px; color: #1f2d3d; }
.welcome-group-count { font-size: 12px; color: #93a0b3; }
.page-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.page-tile {
  display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #e3e7ee;
  border-left: 4px solid var(--tile-accent, #6b7a8f); border-radius: 8px; padding: 14px 16px;
  text-decoration: none; color: #1f2d3d; font-weight: 600; font-size: 13.5px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.page-tile:hover { box-shadow: 0 4px 14px rgba(20, 40, 80, 0.12); transform: translateY(-2px); }
.page-tile .arrow { margin-left: auto; color: #b7c0cc; font-size: 15px; flex-shrink: 0; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { border: 1px solid #e3e7ec; padding: 6px 8px; text-align: left; }
th { background: var(--band); color: #1a355a; }
tbody tr:nth-child(even) { background: #fafbfc; }
.tablewrap { max-height: 380px; overflow-y: auto; border: 1px solid #e3e7ec; border-radius: 6px; margin-top: 10px; }
.num { text-align: right; }

.stat-row { display: flex; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 150px; background: #f4f7fb; border-radius: 6px; padding: 10px 14px; }
.stat .label { font-size: 11px; color: #667; }
.stat .value { font-size: 18px; font-weight: 700; color: var(--navy); margin-top: 2px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #e3e7ec; color: #556; }
.pill.ok { background: var(--ok); color: var(--ok-text); }
.pill.warn { background: var(--warn); color: var(--warn-text); }
.pill.danger { background: var(--danger); color: var(--danger-text); }
.pill.info { background: var(--band); color: var(--navy-dark); }

.banner { background: var(--warn); color: var(--warn-text); padding: 10px 16px; border-radius: 6px; font-size: 12.5px; margin-bottom: 18px; line-height: 1.5; }
.flash-list { list-style: none; padding: 0; margin: 0 0 16px 0; }
.flash { padding: 10px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 8px; }
.flash.error { background: var(--danger); color: var(--danger-text); }
.flash.success { background: var(--ok); color: var(--ok-text); }

.flow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #556; margin-bottom: 6px; flex-wrap: wrap; }
.flow .step { background: var(--band); padding: 4px 10px; border-radius: 12px; }
.flow .arrow { color: #99a; }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { max-width: 380px; width: 100%; background: #fff; border-radius: 10px; padding: 28px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); text-align: center; }
.auth-card h2 { margin-top: 0; color: var(--navy); }
.auth-card input { width: 100%; padding: 10px; margin: 8px 0; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.auth-card button { width: 100%; padding: 10px; margin-top: 6px; }
.auth-card .note { font-size: 11px; color: #888; margin-top: 14px; line-height: 1.4; text-align: left; }
.auth-card .brandline { font-weight: 800; color: var(--navy); letter-spacing: 0.5px; margin-bottom: 6px; }
