/* ==========================================================================
   Anmaya Process Portal — design system
   Light and dark are both first-class; every colour is a token.
   ========================================================================== */

:root {
  --brand-50:  #eef4ff;
  --brand-100: #dbe7ff;
  --brand-200: #bdd2ff;
  --brand-400: #6d97f5;
  --brand-500: #2f6fed;
  --brand-600: #1f56c9;
  --brand-700: #1a45a0;

  --teal-500: #12a594;
  --amber-500: #f5a524;
  --red-500: #e5484d;
  --violet-500: #8b5cf6;

  --bg:        #f6f7fb;
  --bg-sunken: #eef0f6;
  --surface:   #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef1f7;
  --border:    #e2e6ef;
  --border-strong: #cdd4e2;

  --text:      #131722;
  --text-2:    #4a5468;
  --text-3:    #767f93;
  --text-inv:  #ffffff;

  --accent:      var(--brand-500);
  --accent-weak: var(--brand-50);
  --accent-text: var(--brand-700);

  --ok:      #0f9d63;
  --ok-weak: #e6f6ee;
  --warn:      #b7791f;
  --warn-weak: #fdf3e0;
  --danger:      #c92c33;
  --danger-weak: #fdeaea;
  --info:      #1f6fb2;
  --info-weak: #e8f2fb;
  --muted-weak: #f0f1f5;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(19, 23, 34, .06), 0 1px 3px rgba(19, 23, 34, .04);
  --shadow:    0 4px 12px rgba(19, 23, 34, .07), 0 1px 3px rgba(19, 23, 34, .05);
  --shadow-lg: 0 18px 48px rgba(19, 23, 34, .18);

  --sidebar-w: 254px;
  --topbar-h: 62px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}

:root[data-theme='dark'] {
  --bg:        #0d1017;
  --bg-sunken: #080a0f;
  --surface:   #151a24;
  --surface-2: #1b212d;
  --surface-3: #232a38;
  --border:    #262d3b;
  --border-strong: #363f52;

  --text:      #e9edf5;
  --text-2:    #a7b0c2;
  --text-3:    #78829a;

  --accent:      #6d97f5;
  --accent-weak: #1a2540;
  --accent-text: #a9c2fb;

  --ok:      #3dd68c;
  --ok-weak: #11291f;
  --warn:      #f0b429;
  --warn-weak: #2b2211;
  --danger:      #ff6369;
  --danger-weak: #2e1517;
  --info:      #63b3ed;
  --info-weak: #12222f;
  --muted-weak: #1e242f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow:    0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, .6);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.011em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
h4 { font-size: .875rem; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .78rem; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Boot / loading ─────────────────────────────────────────────────────── */
.app-loading { display: grid; place-items: center; min-height: 100vh; }
.boot { text-align: center; color: var(--text-3); }
.boot__mark {
  width: 54px; height: 54px; margin: 0 auto 1rem;
  display: block; object-fit: contain;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .6; transform: scale(.94); } }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--bg);
}
@media (min-width: 960px) { .login { grid-template-columns: 1.1fr 1fr; } }

.login__aside {
  display: none;
  padding: 3rem;
  color: #fff;
  background:
    radial-gradient(1000px 600px at 15% 10%, rgba(255,255,255,.16), transparent 60%),
    linear-gradient(150deg, #16224a 0%, #1f56c9 55%, #6d3fd1 100%);
  flex-direction: column;
  justify-content: space-between;
}
@media (min-width: 960px) { .login__aside { display: flex; } }
.login__wordmark { width: 210px; max-width: 62%; height: auto; display: block; margin-bottom: 1.5rem; }
.login__aside h2 { font-size: 1.9rem; margin-bottom: .75rem; }
.login__aside p { color: rgba(255,255,255,.82); max-width: 42ch; }
.login__points { list-style: none; margin: 2rem 0 0; padding: 0; display: grid; gap: .9rem; }
.login__points li { display: flex; gap: .7rem; align-items: flex-start; color: rgba(255,255,255,.9); }
.login__points svg { flex: none; margin-top: .18rem; opacity: .9; }

.login__main { display: grid; place-items: center; padding: 1.5rem; }
.login__card { width: 100%; max-width: 400px; }
.login__brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.75rem; }
.login__logo { width: 42px; height: 42px; flex: none; display: block; object-fit: contain; }
.login__hint {
  margin-top: 1.25rem; padding: .8rem .9rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .8rem; color: var(--text-2);
}

/* ── App shell ──────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } }

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  z-index: 40;
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 84vw; max-width: var(--sidebar-w);
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: none; }
}

.sidebar__brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); min-height: var(--topbar-h);
}
.sidebar__logo { width: 34px; height: 34px; flex: none; display: block; object-fit: contain; }
.sidebar__title { font-weight: 650; font-size: .92rem; line-height: 1.2; }
.sidebar__subtitle { font-size: .72rem; color: var(--text-3); }

.sidebar__nav { flex: 1; overflow-y: auto; padding: .75rem .6rem 1.5rem; }
.nav-group { margin-bottom: 1.1rem; }
.nav-group__label {
  padding: 0 .55rem .4rem; font-size: .68rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
}
.nav-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem .55rem; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: .875rem;
  text-decoration: none; margin-bottom: 1px; position: relative;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--accent-weak); color: var(--accent-text); font-weight: 600; }
.nav-link svg { flex: none; opacity: .85; }
.nav-link__badge {
  margin-left: auto; min-width: 20px; padding: 0 6px; height: 19px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: .68rem; font-weight: 650;
}

.sidebar__footer { padding: .75rem; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .5rem; border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer; text-align: left; color: inherit; font: inherit;
}
.user-chip:hover { background: var(--surface-3); }
.user-chip__meta { min-width: 0; flex: 1; }
.user-chip__name { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__role { font-size: .72rem; color: var(--text-3); text-transform: capitalize; }

.main { display: flex; flex-direction: column; min-width: 0; }

.viewas { display: flex; align-items: center; gap: .6rem; padding: .5rem 1rem; background: var(--warn-weak); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border)); font-size: .82rem; }
.viewas strong { color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem;
  min-height: var(--topbar-h); padding: .6rem 1.25rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 1.02rem; font-weight: 650; }
.topbar__subtitle { font-size: .76rem; color: var(--text-3); }
.topbar__spacer { flex: 1; }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: none; color: var(--text-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn__dot {
  position: absolute; top: 6px; right: 6px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: .62rem; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--surface);
}
.menu-toggle { display: none; }
@media (max-width: 900px) { .menu-toggle { display: grid; } }

.content { flex: 1; padding: 1.5rem 1.25rem 3rem; max-width: 1440px; width: 100%; }
@media (min-width: 1100px) { .content { padding: 1.75rem 2rem 3.5rem; } }

.scrim {
  position: fixed; inset: 0; z-index: 35; background: rgba(8, 10, 15, .5);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.scrim.is-open { opacity: 1; pointer-events: auto; }
@media (min-width: 901px) { .scrim { display: none; } }

/* ── Page header ────────────────────────────────────────────────────────── */
.page-head {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end;
  justify-content: space-between; margin-bottom: 1.25rem;
}
.page-head__text h1 { margin-bottom: .2rem; }
.page-head__text p { color: var(--text-2); font-size: .875rem; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--border);
}
.card__head h3 { font-size: .95rem; }
.card__head p { font-size: .78rem; color: var(--text-3); margin: 0; }
.card__head-actions { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
.card__body { padding: 1.1rem; }
.card__body--flush { padding: 0; }
.card__foot { padding: .75rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ── Grid ───────────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid--sidebar { grid-template-columns: 1fr; }
@media (min-width: 1080px) { .grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); } }
.stack { display: grid; gap: 1rem; }
.stack--sm { gap: .5rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ── Stat tiles ─────────────────────────────────────────────────────────── */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat__label { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.stat__value { font-size: 1.85rem; font-weight: 680; letter-spacing: -.02em; margin: .3rem 0 .1rem; line-height: 1.1; }
.stat__hint { font-size: .78rem; color: var(--text-2); }
.stat__icon {
  position: absolute; top: .9rem; right: 1rem; width: 32px; height: 32px;
  display: grid; place-items: center; border-radius: 9px;
  background: var(--accent-weak); color: var(--accent-text);
}
.stat--ok .stat__icon { background: var(--ok-weak); color: var(--ok); }
.stat--warn .stat__icon { background: var(--warn-weak); color: var(--warn); }
.stat--danger .stat__icon { background: var(--danger-weak); color: var(--danger); }
.stat--info .stat__icon { background: var(--info-weak); color: var(--info); }
.stat.is-clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.stat.is-clickable:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .5rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: .85rem; font-weight: 550; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.btn--primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.94); }
.btn--ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn--ok:hover { filter: brightness(.94); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--sm { padding: .3rem .6rem; font-size: .78rem; }
.btn--lg { padding: .68rem 1.1rem; font-size: .93rem; }
.btn--block { width: 100%; }
.btn--icon { padding: .42rem; }

.btn-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.btn-group .btn { border: none; border-radius: 0; border-right: 1px solid var(--border); }
.btn-group .btn:last-child { border-right: none; }
.btn-group .btn.is-active { background: var(--accent-weak); color: var(--accent-text); font-weight: 620; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { display: grid; gap: .32rem; margin-bottom: .9rem; }
.field:last-child { margin-bottom: 0; }
.field > label { font-size: .8rem; font-weight: 580; color: var(--text-2); }
.field__hint { font-size: .74rem; color: var(--text-3); }
.field__error { font-size: .76rem; color: var(--danger); }
.field--required > label::after { content: ' *'; color: var(--danger); }

.input, .select, .textarea {
  width: 100%; padding: .52rem .68rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: .875rem;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input[aria-invalid='true'], .select[aria-invalid='true'], .textarea[aria-invalid='true'] { border-color: var(--danger); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { min-height: 84px; resize: vertical; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23767f93' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center; padding-right: 2rem;
}
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid--full { grid-column: 1 / -1; }

.check { display: flex; gap: .55rem; align-items: flex-start; cursor: pointer; font-size: .85rem; }
.check input { margin-top: .18rem; width: 16px; height: 16px; accent-color: var(--brand-500); flex: none; }

.fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1rem; margin-bottom: 1rem; }
.fieldset > legend { padding: 0 .4rem; font-size: .78rem; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th {
  text-align: left; padding: .6rem .85rem; font-weight: 620; font-size: .76rem;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-3);
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: .65rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }
.table--clickable tbody tr { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }

/* ── Badges and pills ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; white-space: nowrap;
  background: var(--muted-weak); color: var(--text-2);
}
.badge--ok { background: var(--ok-weak); color: var(--ok); }
.badge--warn { background: var(--warn-weak); color: var(--warn); }
.badge--danger { background: var(--danger-weak); color: var(--danger); }
.badge--info { background: var(--info-weak); color: var(--info); }
.badge--accent { background: var(--accent-weak); color: var(--accent-text); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .6rem; border-radius: 999px; font-size: .78rem;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  cursor: pointer;
}
.chip:hover { background: var(--surface-3); }
.chip.is-active { background: var(--accent-weak); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* ── Avatars ────────────────────────────────────────────────────────────── */
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: .76rem; font-weight: 650;
  background: var(--accent-weak); color: var(--accent-text);
  overflow: hidden; text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 26px; height: 26px; font-size: .66rem; }
.avatar--lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar--xl { width: 80px; height: 80px; font-size: 1.6rem; }
.person { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.person__name { font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person__meta { font-size: .75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Progress ───────────────────────────────────────────────────────────── */
.progress { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress__bar { height: 100%; border-radius: 999px; background: var(--brand-500); transition: width .3s ease; }
.progress__bar--ok { background: var(--ok); }
.progress__bar--warn { background: var(--warn); }
.progress__bar--danger { background: var(--danger); }

.meter-row { display: grid; gap: .3rem; margin-bottom: .8rem; }
.meter-row:last-child { margin-bottom: 0; }
.meter-row__top { display: flex; justify-content: space-between; font-size: .8rem; }
.meter-row__label { font-weight: 550; }
.meter-row__value { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ── Checklist ──────────────────────────────────────────────────────────── */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist__item {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .75rem 1.1rem; border-bottom: 1px solid var(--border);
}
.checklist__item:last-child { border-bottom: none; }
.checklist__item.is-done .checklist__title { color: var(--text-3); text-decoration: line-through; }
.checklist__item.is-overdue { background: var(--danger-weak); }
.checklist__box {
  width: 20px; height: 20px; flex: none; margin-top: .1rem; border-radius: 6px;
  border: 2px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: transparent; padding: 0;
}
.checklist__box:hover { border-color: var(--accent); }
.checklist__box.is-checked { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist__box.is-na { background: var(--text-3); border-color: var(--text-3); color: #fff; }
.checklist__box:disabled { cursor: not-allowed; opacity: .55; }
.checklist__main { flex: 1; min-width: 0; }
.checklist__title { font-weight: 550; font-size: .875rem; }
.checklist__desc { font-size: .79rem; color: var(--text-2); margin-top: .15rem; }
.checklist__meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; font-size: .73rem; color: var(--text-3); }
.checklist__actions { display: flex; gap: .3rem; flex: none; }

.stage-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem 1.1rem; background: var(--surface-2);
  border-bottom: 1px solid var(--border); border-top: 1px solid var(--border);
  font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2);
}
.stage-head:first-child { border-top: none; }

/* ── Flags (the four headline onboarding checks) ───────────────────────── */
.flags { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.flag {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
}
.flag__icon {
  width: 30px; height: 30px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: var(--muted-weak); color: var(--text-3);
}
.flag.is-done { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); background: var(--ok-weak); }
.flag.is-done .flag__icon { background: var(--ok); color: #fff; }
.flag__label { font-size: .78rem; font-weight: 600; }
.flag__state { font-size: .72rem; color: var(--text-3); }
.flag.is-done .flag__state { color: var(--ok); font-weight: 600; }

/* ── Camera / punch ─────────────────────────────────────────────────────── */
.punch { display: grid; gap: 1rem; }
@media (min-width: 720px) { .punch { grid-template-columns: 280px 1fr; align-items: start; } }

.camera {
  position: relative; aspect-ratio: 4 / 3; width: 100%;
  border-radius: var(--radius); overflow: hidden;
  background: #0b0e14; display: grid; place-items: center;
  border: 1px solid var(--border);
}
.camera video, .camera img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Mirror the live preview so it reads like a mirror, but not the saved capture. */
.camera video { transform: scaleX(-1); }
.camera__placeholder { color: #8b93a7; text-align: center; padding: 1rem; font-size: .82rem; }
.camera__badge {
  position: absolute; left: .6rem; top: .6rem;
  padding: .18rem .5rem; border-radius: 999px;
  background: rgba(9, 12, 18, .72); color: #fff; font-size: .7rem; font-weight: 600;
  display: flex; align-items: center; gap: .3rem;
}
.camera__badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red-500); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.punch-clock { font-size: 2.4rem; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.punch-date { color: var(--text-3); font-size: .85rem; }
.punch-times { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0; }
.punch-time { padding: .6rem .7rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.punch-time__label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; }
.punch-time__value { font-size: 1.02rem; font-weight: 620; font-variant-numeric: tabular-nums; }

.geo-note { display: flex; gap: .5rem; align-items: flex-start; font-size: .78rem; color: var(--text-2); }

/* ── Attendance calendar ────────────────────────────────────────────────── */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal__dow { text-align: center; font-size: .7rem; font-weight: 650; color: var(--text-3); padding: .3rem 0; text-transform: uppercase; }
.cal__day {
  aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); padding: .3rem; display: flex; flex-direction: column;
  font-size: .72rem; cursor: default; position: relative; overflow: hidden;
}
.cal__day.is-empty { border: none; background: none; }
.cal__num { font-weight: 620; font-size: .78rem; }
.cal__tag { margin-top: auto; font-size: .62rem; font-weight: 600; opacity: .9; }
.cal__day.s-present, .mx__cell.s-present { background: var(--ok-weak); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); color: var(--ok); }
.cal__day.s-wfh, .mx__cell.s-wfh { background: var(--info-weak); border-color: color-mix(in srgb, var(--info) 35%, var(--border)); color: var(--info); }
.cal__day.s-half_day, .mx__cell.s-half_day { background: var(--warn-weak); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); color: var(--warn); }
.cal__day.s-absent, .mx__cell.s-absent { background: var(--danger-weak); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); color: var(--danger); }
.cal__day.s-on_duty, .mx__cell.s-on_duty { background: color-mix(in srgb, var(--teal-500) 14%, var(--surface)); border-color: color-mix(in srgb, var(--teal-500) 35%, var(--border)); color: var(--teal-500); }
.cal__day.s-on_leave, .mx__cell.s-on_leave { background: var(--accent-weak); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); color: var(--accent-text); }
.cal__day.s-holiday, .mx__cell.s-holiday { background: color-mix(in srgb, var(--violet-500) 12%, var(--surface)); border-color: color-mix(in srgb, var(--violet-500) 30%, var(--border)); color: var(--violet-500); }
.cal__day.s-weekend, .mx__cell.s-weekend { opacity: .6; }
.cal__day.s-upcoming, .mx__cell.s-upcoming { opacity: .45; }
.cal__day.is-today { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Attendance overview matrix */
.mx { border-collapse: separate; border-spacing: 0; font-size: .74rem; width: max-content; min-width: 100%; }
.mx th, .mx td { padding: 2px 3px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border); }
.mx th.mx__name, .mx td.mx__name { position: sticky; left: 0; background: var(--surface); text-align: left; z-index: 2; min-width: 180px; padding-left: .75rem; }
.mx thead th { position: sticky; top: 0; background: var(--surface); z-index: 3; font-weight: 600; color: var(--text-3); font-size: .66rem; line-height: 1.15; padding: .4rem 3px; }
.mx thead th.mx__name { z-index: 4; }
.mx th.is-today { color: var(--accent); }
.mx th.is-weekend, .mx td.is-weekend { background: color-mix(in srgb, var(--text-3) 7%, transparent); }
.mx tfoot td { border-bottom: none; color: var(--text-2); padding: .35rem 3px; }
.mx__cell { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 24px; border-radius: 5px; border: 1px solid var(--border); font-weight: 650; font-size: .68rem; cursor: pointer; background: var(--surface-2); color: var(--text-3); }
.mx__cell.is-late { box-shadow: inset 0 -3px 0 var(--warn); }
.mx__cell.s-not_joined, .mx__cell.s-upcoming, .mx__cell.s-not_tracked { opacity: .3; cursor: default; }
.cal__day.s-not_tracked { opacity: .35; }
.mx__cell.s-weekend { opacity: .55; }
.mx__sum { font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 34px; }
.mx td.mx__name a { color: inherit; text-decoration: none; }
.mx td.mx__name a:hover { text-decoration: underline; }

.legend { display: flex; flex-wrap: wrap; gap: .75rem; font-size: .76rem; color: var(--text-2); }
.legend__item { display: flex; align-items: center; gap: .35rem; }
.legend__swatch { width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--border); }

/* ── Kanban ─────────────────────────────────────────────────────────────── */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(268px, 1fr); gap: .85rem; overflow-x: auto; padding-bottom: .75rem; align-items: start; }
.kanban__col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 160px; }
.kanban__head { display: flex; align-items: center; gap: .5rem; padding: .7rem .8rem; border-bottom: 1px solid var(--border); font-size: .8rem; font-weight: 650; }
.kanban__count { margin-left: auto; font-size: .72rem; color: var(--text-3); background: var(--surface-3); padding: .05rem .45rem; border-radius: 999px; }
.kanban__list { padding: .6rem; display: grid; gap: .55rem; min-height: 60px; }
.kanban__list.is-over { background: var(--accent-weak); border-radius: var(--radius-sm); }

.task-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .65rem .7rem; box-shadow: var(--shadow-sm); cursor: grab; border-left: 3px solid var(--border-strong);
}
.task-card:hover { border-color: var(--border-strong); }
.task-card.is-dragging { opacity: .45; }
.task-card--critical { border-left-color: var(--danger); }
.task-card--high { border-left-color: var(--warn); }
.task-card--medium { border-left-color: var(--accent); }
.task-card--low { border-left-color: var(--text-3); }
.task-card__title { font-weight: 570; font-size: .845rem; line-height: 1.35; }
.task-card__meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: .45rem; font-size: .72rem; color: var(--text-3); }

/* ── Timeline ───────────────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline__item { position: relative; padding: 0 0 .9rem 1.75rem; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot { position: absolute; left: 3px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.timeline__title { font-size: .84rem; font-weight: 550; }
.timeline__meta { font-size: .74rem; color: var(--text-3); }

/* ── Empty and loading states ───────────────────────────────────────────── */
.empty { text-align: center; padding: 2.5rem 1.25rem; color: var(--text-3); }
.empty__icon { width: 46px; height: 46px; margin: 0 auto .75rem; display: grid; place-items: center; border-radius: 12px; background: var(--surface-3); color: var(--text-3); }
.empty h3 { font-size: .95rem; color: var(--text-2); margin-bottom: .3rem; }
.empty p { font-size: .84rem; max-width: 44ch; margin: 0 auto .9rem; }

.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton--text { height: 12px; margin-bottom: .5rem; }
.skeleton--card { height: 104px; }

.spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: grid; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .7rem .85rem; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: .85rem;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: .2s; }
.toast__icon { flex: none; margin-top: .1rem; }
.toast--success { border-left: 3px solid var(--ok); }
.toast--success .toast__icon { color: var(--ok); }
.toast--error { border-left: 3px solid var(--danger); }
.toast--error .toast__icon { color: var(--danger); }
.toast--info { border-left: 3px solid var(--accent); }
.toast--info .toast__icon { color: var(--accent); }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: 600; }
.toast__text { color: var(--text-2); font-size: .8rem; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150; background: rgba(8, 10, 15, .55);
  display: grid; place-items: center; padding: 1rem; overflow-y: auto;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 540px; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); animation: modal-in .18s ease-out;
  max-height: calc(100vh - 2rem); display: flex; flex-direction: column;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal--lg { max-width: 760px; }
.modal--xl { max-width: 980px; }
.modal__head { display: flex; align-items: flex-start; gap: .75rem; padding: 1.1rem 1.25rem .9rem; border-bottom: 1px solid var(--border); }
.modal__head h3 { font-size: 1.02rem; }
.modal__head p { font-size: .8rem; color: var(--text-3); margin: .15rem 0 0; }
.modal__body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal__foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }

/* ── Popover (notifications, user menu) ─────────────────────────────────── */
.popover {
  position: absolute; z-index: 120; min-width: 260px; max-width: min(380px, calc(100vw - 2rem));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: modal-in .14s ease-out;
}
.popover__head { padding: .7rem .9rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .5rem; }
.popover__head h4 { font-size: .85rem; }
.popover__list { max-height: 380px; overflow-y: auto; }
.popover__item { display: block; width: 100%; text-align: left; padding: .65rem .9rem; border: none; border-bottom: 1px solid var(--border); background: none; color: inherit; font: inherit; cursor: pointer; }
.popover__item:last-child { border-bottom: none; }
.popover__item:hover { background: var(--surface-2); }
.popover__item.is-unread { background: var(--accent-weak); }
.popover__item-title { font-size: .83rem; font-weight: 560; }
.popover__item-body { font-size: .78rem; color: var(--text-2); }
.popover__item-time { font-size: .71rem; color: var(--text-3); margin-top: .15rem; }

/* ── Misc ───────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 1rem 0; border: none; }
.muted { color: var(--text-3); }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .74rem; }
.strong { font-weight: 620; }
.mono { font-family: var(--mono); font-size: .8rem; }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tab {
  padding: .55rem .85rem; border: none; background: none; cursor: pointer;
  font: inherit; font-size: .86rem; font-weight: 550; color: var(--text-3);
  border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 620; }

.note {
  padding: .75rem .9rem; border-radius: var(--radius-sm); font-size: .83rem;
  background: var(--info-weak); color: var(--info); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent);
  display: flex; gap: .55rem; align-items: flex-start;
}
.note--warn { background: var(--warn-weak); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.note--danger { background: var(--danger-weak); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.note--ok { background: var(--ok-weak); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.note svg { flex: none; margin-top: .1rem; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters .input, .filters .select { width: auto; min-width: 150px; }
.search { position: relative; flex: 1; min-width: 190px; max-width: 320px; }
.search .input { padding-left: 2.1rem; width: 100%; }
.search svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }

.bars { display: grid; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 130px) 1fr auto; gap: .6rem; align-items: center; font-size: .8rem; }
.bar-track { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }

.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 46px; }
.sparkline__bar { flex: 1; min-width: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .8; min-height: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.print-only { display: none; }
@media print {
  .sidebar, .topbar, .page-head__actions, .btn { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .print-only { display: block; }
}

/* ── Training calendar ─────────────────────────────────────────────────────── */
.tcal { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.tcal__head { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tcal__head div { padding: .4rem .5rem; font-size: .72rem; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.tcal__grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.tcal__day { min-height: 96px; padding: .3rem .35rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: .74rem; }
.tcal__day:nth-child(7n) { border-right: 0; }
.tcal__day.is-pad { background: var(--bg-sunken); }
.tcal__day.is-today { background: var(--brand-50); }
.tcal__day.is-today .tcal__num { color: var(--brand-600); font-weight: 700; }
.tcal__num { font-size: .72rem; color: var(--text-3); margin-bottom: .2rem; }
.tcal__ev { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--brand-500); background: var(--brand-50); color: var(--text); border-radius: 4px; padding: .15rem .35rem; margin-bottom: .2rem; font: inherit; font-size: .72rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcal__ev:hover { background: var(--brand-100); }
.tcal__ev.s-done { border-left-color: var(--ok); background: var(--ok-weak); }
.tcal__ev.s-cancelled { border-left-color: var(--danger); background: var(--danger-weak); text-decoration: line-through; opacity: .7; }
.tcal__due { display: block; border-left: 3px solid var(--warn); background: var(--warn-weak); color: var(--warn); border-radius: 4px; padding: .15rem .35rem; margin-bottom: .2rem; font-size: .7rem; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcal--week .tcal__day { min-height: 220px; }
@media (max-width: 720px) { .tcal__grid { grid-template-columns: 1fr; } .tcal__head { display: none; } .tcal__day.is-pad { display: none; } .tcal__day { min-height: 0; border-right: 0; } .tcal__num::before { content: attr(data-dow) ' '; } .tcal__ev { white-space: normal; } }
.tcal__ev.has-clash { border-left-color: var(--warn); background: var(--warn-weak); box-shadow: inset 0 0 0 1px var(--warn); }

/* ── Shared markdown (notes, course editor) ────────────────────────────────── */
.md h3, .md h4, .md h5, .md h6 { margin: .8rem 0 .35rem; }
.md ul, .md ol { margin: .2rem 0 .6rem 1.2rem; }
.md-code { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin: .5rem 0 .8rem; background: var(--surface-2); }
.md-code__bar { display: flex; justify-content: space-between; align-items: center; padding: .25rem .6rem; font-size: .72rem; color: var(--text-3); border-bottom: 1px solid var(--border); }
.md-code pre { margin: 0; padding: .6rem .75rem; overflow-x: auto; font-size: .8rem; line-height: 1.45; white-space: pre; }
.md-copy { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 5px; font: inherit; font-size: .72rem; padding: .1rem .5rem; cursor: pointer; }
.md-table { overflow-x: auto; margin: .5rem 0 .8rem; }
.md-table table { border-collapse: collapse; font-size: .85rem; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: .3rem .55rem; text-align: left; vertical-align: top; }
.md-table th { background: var(--surface-2); }

/* Compulsory policy training banner (app.js refreshBadges) */
.trainbar { display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem; background: var(--warn-weak); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border)); font-size: .84rem; }
.trainbar strong { color: inherit; }
.trainbar--late { background: var(--danger-weak); color: var(--danger); border-bottom-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.trainbar .spacer { flex: 1; }
/* Policy training pages */
.pt-dots { display: flex; gap: 6px; justify-content: center; margin: .8rem 0; }
.pt-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.pt-dots i.on { background: var(--brand, #0b59be); }
.pt-slide { min-height: 230px; font-size: 1rem; line-height: 1.6; }
.pt-slide h3 { margin-top: 0; }
.pt-slide ul { padding-left: 1.2rem; display: grid; gap: .45rem; }
.pt-scn { border-left: 4px solid var(--brand, #0b59be); background: var(--surface-2, #f6f8fb); padding: 1rem 1.2rem; border-radius: 8px; }
.pt-q { padding: 1rem 0; border-top: 1px solid var(--border); }
.pt-q:first-child { border-top: 0; }
.pt-opt { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; margin-top: .4rem; cursor: pointer; }
.pt-opt:hover { border-color: var(--brand, #0b59be); }
.pt-opt.ok { border-color: var(--ok); background: var(--ok-weak); }
.pt-opt.bad { border-color: var(--danger); background: var(--danger-weak); }
.pt-mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.pt-mod { border: 1px solid var(--border); border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; gap: .4rem; background: var(--surface); }
.pt-mod.locked { opacity: .55; }
.pt-timer { font-variant-numeric: tabular-nums; font-weight: 700; }
