/* SE Controls Africa — client data dashboard
   Tokens carried over from the SE Controls brand system. */

:root {
  --navy:        #1A2A3A;
  --navy-soft:   #24384C;
  --blue:        #3B8DD4;
  --blue-deep:   #1E6BB8;
  --blue-accent: #2980B9;
  --charcoal:    #2D3436;
  --body:        #4A4A4A;
  --surface:     #F0F4F8;
  --row-alt:     #EBF3FB;
  --tint:        #EAF3FB;
  --tint-line:   #C5DCEE;
  --border:      #D6DDE6;
  --red:         #E62A36;
  --red-soft:    #FDECED;
  --white:       #FFFFFF;

  --rail-w: 216px;
  --font: Calibri, Carlito, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* .drawer, .scrim and .toast all set a display value, which would otherwise
   beat the browser's own [hidden] rule and leave them permanently on screen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--body);
  background: var(--surface);
}

h1, h2, h3 { color: var(--charcoal); margin: 0; font-weight: 700; }
code { font-family: Consolas, monospace; background: var(--tint); padding: 1px 5px; border-radius: 2px; color: var(--blue-deep); }

/* ── Rail ─────────────────────────────────────────────────────────── */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail-w);
  background: var(--navy); color: #C9D6E2;
  display: flex; flex-direction: column; padding: 22px 0 16px;
}
.rail__mark { display: flex; gap: 12px; padding: 0 20px 26px; align-items: flex-start; }
.rail__bar { width: 3px; height: 38px; background: var(--white); flex: none; margin-top: 2px; }
.rail__name { color: var(--white); font-weight: 700; font-size: 17px; line-height: 1.15; }
.rail__name em { display: block; font-style: normal; font-weight: 400; font-size: 13px; color: var(--blue); }

.rail__nav { display: flex; flex-direction: column; }
.rail__link {
  background: none; border: 0; border-left: 3px solid transparent;
  color: #C9D6E2; font: inherit; text-align: left;
  padding: 10px 20px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.rail__link:hover { background: var(--navy-soft); color: var(--white); }
.rail__link.is-active { border-left-color: var(--blue); background: var(--navy-soft); color: var(--white); font-weight: 700; }
.rail__link:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

.pill {
  background: var(--red); color: var(--white); font-size: 12px; font-weight: 700;
  border-radius: 9px; padding: 1px 8px; min-width: 22px; text-align: center;
}
.pill--zero { background: var(--navy-soft); color: #8FA4B8; }

.rail__foot { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid var(--navy-soft); }
.rail__sync { font-size: 12px; color: #8FA4B8; margin: 0; }
.rail__sync strong { color: var(--white); font-weight: 600; }

/* ── Layout ───────────────────────────────────────────────────────── */
.main { margin-left: var(--rail-w); padding: 0 28px 40px; }

.head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 20px;
  padding: 26px 0 18px; border-bottom: 3px solid var(--blue); margin-bottom: 20px;
}
.head h1 { font-size: 26px; }
.head__sub { margin: 3px 0 0; font-size: 14px; }
.head__actions { display: flex; gap: 8px; flex: none; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 600; border-radius: 3px; padding: 8px 15px;
  cursor: pointer; border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.btn:focus-visible { outline: 2px solid var(--blue-deep); outline-offset: 2px; }
.btn--solid { background: var(--blue); color: var(--white); }
.btn--solid:hover { background: var(--blue-deep); }
.btn--ghost { background: var(--white); color: var(--blue-deep); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--blue); background: var(--tint); }
.btn--danger { background: var(--white); color: var(--red); border-color: #F2C4C7; }
.btn--danger:hover { background: var(--red-soft); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Stats ────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); margin-bottom: 20px; }
.stat { background: var(--white); padding: 13px 16px; }
.stat b { display: block; font-size: 23px; color: var(--charcoal); font-weight: 700; line-height: 1.1; }
.stat span { font-size: 13px; }
.stat--alert b { color: var(--red); }

/* ── Toolbar ──────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar__search {
  flex: 1 1 300px; min-width: 220px; font: inherit;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 3px; background: var(--white);
}
.toolbar__search:focus, .toolbar__sel:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.toolbar__sel { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 3px; background: var(--white); color: var(--body); max-width: 200px; }
.toolbar__clear { font: inherit; background: none; border: 0; color: var(--blue-deep); cursor: pointer; text-decoration: underline; padding: 0 6px; }

/* ── Grid ─────────────────────────────────────────────────────────── */
.tablewrap { background: var(--white); border: 1px solid var(--border); overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th {
  background: var(--blue-deep); color: var(--white); text-align: left;
  padding: 9px 12px; font-weight: 700; white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
.grid th.num { text-align: center; }
.sortable { cursor: pointer; }
.sortable:hover { background: var(--blue); }
.sortable[aria-sort]::after { content: " ▲"; font-size: 10px; }
.sortable[aria-sort="descending"]::after { content: " ▼"; }

.grid td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.grid tbody tr:nth-child(even) { background: var(--row-alt); }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--tint); box-shadow: inset 3px 0 0 var(--blue); }
.grid tbody tr:focus-visible { outline: 2px solid var(--blue-deep); outline-offset: -2px; }
.cell-company { font-weight: 600; color: var(--charcoal); }
.cell-sub { display: block; font-size: 12.5px; color: #7A8894; }
.tag { display: inline-block; background: var(--tint); border: 1px solid var(--tint-line); color: var(--blue-accent); font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 2px; }
.flagdot { display: inline-block; width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 50%; background: var(--red); color: var(--white); font-size: 12px; font-weight: 700; }
.flagdot--ok { background: var(--tint); color: var(--tint-line); }

.empty { padding: 40px 20px; text-align: center; color: #7A8894; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 16px 0; font-size: 14px; }

/* ── Review view ──────────────────────────────────────────────────── */
.lede { max-width: 68ch; margin: 0 0 18px; }
.issues { display: flex; flex-direction: column; gap: 1px; background: var(--border); border: 1px solid var(--border); }
.issue { background: var(--white); padding: 13px 16px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.issue button { font: inherit; background: none; border: 0; color: var(--blue-deep); cursor: pointer; text-decoration: underline; }
.issue__n { font-weight: 700; color: var(--red); font-size: 19px; flex: none; }

/* ── Sync view ────────────────────────────────────────────────────── */
.syncgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.panel { background: var(--white); border: 1px solid var(--border); padding: 20px 22px; }
.panel h2 { font-size: 17px; margin-bottom: 10px; }
.panel p { max-width: 60ch; }
.warn { background: var(--red-soft); border-left: 3px solid var(--red); padding: 11px 14px; }
.muted { color: #7A8894; font-size: 13px; }
.log { max-height: 460px; overflow-y: auto; font-size: 13px; }
.log__row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.log__row b { color: var(--charcoal); }

/* ── Drawer ───────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(26, 42, 58, .45); z-index: 30; }
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(560px, 100%); z-index: 40;
  background: var(--white); display: flex; flex-direction: column; box-shadow: -3px 0 18px rgba(26,42,58,.2);
}
@media (prefers-reduced-motion: no-preference) {
  .drawer { animation: slide .16s ease-out; }
  @keyframes slide { from { transform: translateX(24px); opacity: .6; } }
}
.drawer__head { background: var(--navy); color: var(--white); padding: 17px 22px; display: flex; justify-content: space-between; gap: 12px; }
.drawer__head h2 { color: var(--white); font-size: 18px; }
.drawer__meta { margin: 3px 0 0; font-size: 12.5px; color: #9FB4C7; }
.drawer__close { background: none; border: 0; color: var(--white); font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
.drawer__flags { background: var(--red-soft); border-bottom: 1px solid #F2C4C7; padding: 12px 22px; font-size: 13.5px; color: #8A1B23; }
.drawer__flags ul { margin: 6px 0 0; padding-left: 18px; }
.drawer__body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.drawer__foot { border-top: 1px solid var(--border); padding: 13px 22px; display: flex; justify-content: space-between; gap: 10px; background: var(--surface); }
.drawer__footright { display: flex; gap: 8px; }

.fset { border: 0; padding: 0; margin: 0 0 20px; }
.fset > legend { font-weight: 700; color: var(--blue-deep); font-size: 13px; padding: 0 0 6px; border-bottom: 2px solid var(--blue); width: 100%; margin-bottom: 12px; }
.frow { display: grid; grid-template-columns: 148px 1fr; gap: 10px; align-items: baseline; margin-bottom: 9px; }
.frow label { font-size: 13.5px; color: var(--body); }
.frow input, .frow textarea, .frow select {
  font: inherit; font-size: 14px; width: 100%; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: 3px; background: var(--white); color: var(--charcoal);
}
.frow textarea { min-height: 74px; resize: vertical; line-height: 1.4; }
.frow input:focus, .frow textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }
.frow--bad input { border-color: var(--red); background: var(--red-soft); }

/* ── Toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--navy); color: var(--white); padding: 11px 20px; border-radius: 3px;
  font-size: 14px; box-shadow: 0 3px 14px rgba(26,42,58,.3); max-width: 90vw;
}
.toast--bad { background: var(--red); }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .syncgrid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .rail { position: static; width: auto; flex-direction: row; align-items: center; padding: 10px 14px; gap: 14px; flex-wrap: wrap; }
  .rail__mark { padding: 0; }
  .rail__nav { flex-direction: row; }
  .rail__link { padding: 7px 12px; border-left: 0; border-bottom: 3px solid transparent; }
  .rail__link.is-active { border-left: 0; border-bottom-color: var(--blue); }
  .rail__foot { margin: 0; border: 0; padding: 0; }
  .main { margin-left: 0; padding: 0 14px 30px; }
  .head { flex-direction: column; align-items: flex-start; }
  .frow { grid-template-columns: 1fr; gap: 3px; }
}
