/* ------------------------------------------------------------------------------------------------
   app.css — AgentHub back-office styles.
   Copyright (c) Vivaticket SAS. All rights reserved.

   Implements the « Local Agent HUB » handoff (claude.ai/design): the FiscalHub / VivaLogs suite
   look — slate chrome (#2d3748) for the sidebar and the header, white panels, blue accent — in a
   light and a dark theme driven by <html data-theme>. Fonts and icons are served locally: the
   agent often runs on servers without Internet access.
   ------------------------------------------------------------------------------------------------ */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/Inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/Inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============ Design tokens ============ */
:root {
  --ah-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ah-mono-font: ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --bg: #f8f9fb;
  --panel: #fff;
  --panel2: #f9fafb;
  --border: #e5e7eb;
  --soft: #f3f4f6;
  --text: #111827;
  --text2: #6b7280;
  --muted: #9ca3af;
  --chrome: #2d3748;
  --chrome-line: rgb(255 255 255 / .08);
  --accent: #2563eb;
  --accent-h: #1d4ed8;
  --accent-soft: #eff6ff;
  --ok-bg: #ecfdf5; --ok-fg: #1b7a4b; --ok-bd: #a7f3d0; --ok-dot: #22c55e;
  --warn-bg: #fdf3e2; --warn-fg: #b7791f; --warn-bd: #f6d49b; --warn-dot: #f59e0b;
  --err-bg: #fdecea; --err-fg: #b42318; --err-bd: #f6c3bd; --err-dot: #ef4444;
  --info-bg: #eaf1fb; --info-fg: #2a5db0; --info-bd: #c7dbf5; --info-dot: #3b82f6;
  --neu-bg: #f3f4f6; --neu-fg: #4b5563; --neu-bd: #e5e7eb; --neu-dot: #9ca3af;
  --nav-bg: #fff;
  --nav-fg: #111827;
  --code: #f3f4f6;
  --shadow: 0 1px 2px rgb(16 24 40 / .05);
}

[data-theme="dark"] {
  --bg: #171b23;
  --panel: #1f2530;
  --panel2: #1a1f28;
  --border: #343a46;
  --soft: #2a2f3a;
  --text: #f3f4f6;
  --text2: #9ca3af;
  --muted: #6b7280;
  --chrome: #11151c;
  --accent: #3b82f6;
  --accent-h: #60a5fa;
  --accent-soft: #1e3a5f;
  --ok-bg: #14361f; --ok-fg: #4ade80; --ok-bd: #1f5a33;
  --warn-bg: #3a2c10; --warn-fg: #fbbf24; --warn-bd: #5c4516;
  --err-bg: #3a1816; --err-fg: #f87171; --err-bd: #6b2521;
  --info-bg: #14304f; --info-fg: #93c5fd; --info-bd: #1e4a78;
  --neu-bg: #2a2f3a; --neu-fg: #cbd5e1; --neu-bd: #343a46;
  --nav-bg: rgb(255 255 255 / .1);
  --nav-fg: #fff;
  --code: #171b23;
  --shadow: none;
}

/* Shared suite components (toasts) read the --color-* tokens: map them onto the theme. */
:root, [data-theme="dark"] {
  --color-background-primary: var(--panel);
  --color-background-secondary: var(--panel2);
  --color-border-tertiary: var(--border);
  --color-border-soft: var(--soft);
  --color-text-primary: var(--text);
  --color-text-secondary: var(--text2);
  --color-text-muted: var(--muted);
  --color-accent: var(--accent);
  --color-success-bg: var(--ok-bg);
  --color-success-fg: var(--ok-fg);
  --color-info-bg: var(--info-bg);
  --color-info-fg: var(--info-fg);
  --color-warning-bg: var(--warn-bg);
  --color-warning-fg: var(--warn-fg);
  --color-error-bg: var(--err-bg);
  --color-error-fg: var(--err-fg);
  --color-neutral-bg: var(--neu-bg);
  --color-neutral-fg: var(--neu-fg);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ah-font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); text-decoration: underline; }

[data-theme="dark"] .ah-only-light, :root:not([data-theme="dark"]) .ah-only-dark { display: none; }

.ah-mono { font-family: var(--ah-mono-font); }
.ah-meta { font-size: 12px; color: var(--text2); }
.ah-muted { color: var(--text2); }
.ah-strong { font-weight: 600; }
.ah-num { font-variant-numeric: tabular-nums; }
.ah-right { text-align: right; }
.ah-min0 { min-width: 0; }
.ah-grow { flex: 1; }
.ah-stack { display: flex; flex-direction: column; gap: 4px; }
.ah-inline-icon { display: inline-flex; align-items: center; gap: 6px; }

/* ============ Shell ============ */
.ah-shell { display: flex; min-height: 100vh; }

.ah-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--chrome);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 25;
  transition: width .18s ease;
}

.ah-sidebar--collapsed { width: 64px; }

.ah-sidebar__toggle {
  position: absolute;
  top: 20px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  color: #2d3748;
  box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  padding: 0;
  z-index: 26;
}

.ah-brand {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  overflow: hidden;
}

.ah-brand__tile {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #1e293b;
  border: 1.5px solid #60a5fa;
  color: #93c5fd;
  font-size: 20px;
}

.ah-brand__word { font-size: 17px; letter-spacing: .02em; color: #fff; white-space: nowrap; }
.ah-brand__word b { font-weight: 700; }

.ah-nav { display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.ah-nav--bottom { border-top: 1px solid var(--chrome-line); }

.ah-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.ah-nav__item .ti { font-size: 18px; flex-shrink: 0; }
.ah-nav__item:hover { color: #fff; background: rgb(255 255 255 / .06); text-decoration: none; }
.ah-nav__item.active { background: var(--nav-bg); color: var(--nav-fg); }

.ah-sidebar__spacer { flex: 1; }

.ah-hosting-card {
  flex-shrink: 0;
  margin: 0 12px 12px;
  padding: 12px;
  border-radius: 10px;
  background: rgb(255 255 255 / .05);
  border: 1px solid var(--chrome-line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ah-hosting-card__caption { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9ca3af; }
.ah-hosting-card__mode { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 600; }
.ah-hosting-card__mode .ti { font-size: 18px; color: #93c5fd; }
.ah-hosting-card__desc { font-size: 12px; color: #9ca3af; line-height: 1.4; }

.ah-sidebar--collapsed .ah-brand__word,
.ah-sidebar--collapsed .ah-nav__label,
.ah-sidebar--collapsed .ah-hosting-card__caption,
.ah-sidebar--collapsed .ah-hosting-card__desc { display: none; }

.ah-sidebar--collapsed .ah-hosting-card { padding: 10px 0; align-items: center; }
.ah-sidebar--collapsed .ah-nav__item { justify-content: center; padding: 0; }

.ah-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-x: clip; }

/* ============ Header ============ */
.ah-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: var(--chrome);
  color: #fff;
}

.ah-header__icon { font-size: 20px; color: #cbd5e1; flex-shrink: 0; }

.ah-header__title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

/* FocusOnNavigate moves focus to the title for screen readers; it is not an interactive element. */
.ah-header__title:focus { outline: none; }

.ah-mode-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgb(255 255 255 / .08);
  font-size: 12px;
  color: #e5e7eb;
  white-space: nowrap;
  flex-shrink: 0;
}

.ah-mode-pill .ti { font-size: 15px; color: #93c5fd; }
.ah-mode-pill__extra { display: inline-flex; gap: 8px; color: #9ca3af; }
.ah-mode-pill__sep { color: #6b7280; }

.ah-header__logo { height: 22px; object-fit: contain; opacity: .9; flex-shrink: 0; }
.ah-header__sep { width: 1px; height: 24px; background: rgb(255 255 255 / .15); flex-shrink: 0; }

.ah-iconbtn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 18px;
  display: grid;
  place-items: center;
}

.ah-iconbtn:hover { background: rgb(255 255 255 / .1); }

@media (max-width: 900px) {
  .ah-mode-pill__extra, .ah-header__logo, .ah-header__sep { display: none; }
}

/* ============ Content ============ */
.ah-content { flex: 1; padding: 24px; display: flex; flex-direction: column; gap: 20px; min-width: 0; outline: none; }

.ah-footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
}

.ah-footer__logo { height: 18px; object-fit: contain; opacity: .85; }

.ah-loading { display: grid; place-items: center; padding: 48px; }

.ah-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ah-subtitle { font-size: 16px; color: var(--text2); }
.ah-refresh { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); }

.ah-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.ah-dot--ok { background: var(--ok-dot); }
.ah-dot--info { background: var(--info-dot); }
.ah-dot--warn { background: var(--warn-dot); }
.ah-dot--err { background: var(--err-dot); }
.ah-dot--neu { background: var(--neu-dot); }

/* ============ Banners ============ */
.ah-banner {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid;
  color: var(--text);
}

.ah-banner > .ti { font-size: 22px; }
.ah-banner--err { background: var(--err-bg); border-color: var(--err-bd); }
.ah-banner--err > .ti, .ah-banner--err .ah-banner__title { color: var(--err-fg); }
.ah-banner--warn { background: var(--warn-bg); border-color: var(--warn-bd); }
.ah-banner--warn > .ti, .ah-banner--warn .ah-banner__title { color: var(--warn-fg); }
.ah-banner__body { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.ah-banner__title { font-weight: 600; }

.ah-banner__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 16px;
  align-items: center;
  font-size: 13px;
}

.ah-banner__grid a { font-weight: 600; white-space: nowrap; }

/* ============ Stat cards ============ */
.ah-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }

.ah-stat {
  --tone-bg: var(--neu-bg);
  --tone-fg: var(--neu-fg);
  --tone-dot: var(--neu-dot);
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--tone-dot);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ah-stat--ok { --tone-bg: var(--ok-bg); --tone-fg: var(--ok-fg); --tone-dot: var(--ok-dot); }
.ah-stat--info { --tone-bg: var(--info-bg); --tone-fg: var(--info-fg); --tone-dot: var(--info-dot); }
.ah-stat--warn { --tone-bg: var(--warn-bg); --tone-fg: var(--warn-fg); --tone-dot: var(--warn-dot); }
.ah-stat--err { --tone-bg: var(--err-bg); --tone-fg: var(--err-fg); --tone-dot: var(--err-dot); }

.ah-stat__top { display: flex; justify-content: space-between; align-items: flex-start; }
.ah-stat__label { font-size: 14px; color: var(--text2); }

.ah-stat__icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--tone-bg);
  color: var(--tone-fg);
  font-size: 18px;
}

.ah-stat__value { font-size: 26px; font-weight: 500; line-height: 1.15; }
.ah-stat--err .ah-stat__value { color: var(--err-fg); }
.ah-stat__sub { font-size: 12px; color: var(--text2); }

/* ============ Cards ============ */
.ah-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.ah-card--pad { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }

.ah-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}

.ah-card__title { margin: 0; font-size: 16px; font-weight: 600; }
.ah-card__sub { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* ============ Buttons ============ */
.ah-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.ah-btn:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.ah-btn--sm { height: 32px; padding: 0 10px; font-size: 12px; }
.ah-btn--icon { width: 34px; padding: 0; justify-content: center; }
.ah-btn--primary { height: 36px; padding: 0 14px; border: 0; background: var(--accent); color: #fff; font-weight: 600; }
.ah-btn--primary:hover { background: var(--accent-h); color: #fff; }
.ah-btn--danger-outline { border-color: var(--err-bd); color: var(--err-fg); }
.ah-btn--danger-outline:hover { background: var(--err-bg); color: var(--err-fg); }
.ah-btn--accent-outline { border-color: var(--info-bd); color: var(--accent); }
.ah-btn--accent-outline:hover { background: var(--accent-soft); color: var(--accent); }

/* ============ Badges, chips, tags ============ */
.ah-badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ah-badge--ok { background: var(--ok-bg); color: var(--ok-fg); }
.ah-badge--info { background: var(--info-bg); color: var(--info-fg); }
.ah-badge--warn { background: var(--warn-bg); color: var(--warn-fg); }
.ah-badge--err { background: var(--err-bg); color: var(--err-fg); }
.ah-badge--neu { background: var(--neu-bg); color: var(--neu-fg); }

.ah-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.ah-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 13px;
}

.ah-tag {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: middle;
}

/* ============ Worker tiles (dashboard) ============ */
.ah-worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 0 20px 20px;
}

.ah-worker-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
}

.ah-worker-tile:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.ah-worker-tile--err { border-color: var(--err-bd); background: var(--err-bg); }
.ah-worker-tile__top { display: flex; align-items: center; gap: 10px; }
.ah-worker-tile__name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ah-worker-tile__error { font-size: 12px; color: var(--err-fg); line-height: 1.4; }

.ah-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.ah-facts dt { font-size: 11px; color: var(--text2); }
.ah-facts dd { margin: 2px 0 0; font-size: 13px; font-variant-numeric: tabular-nums; }

/* ============ Lists and empty states ============ */
.ah-list { display: flex; flex-direction: column; }
.ah-list__row { display: flex; align-items: center; gap: 10px; padding: 10px 20px; border-top: 1px solid var(--border); }
.ah-card--pad .ah-list__row { padding: 10px 0; }

.ah-empty {
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.ah-empty > .ti { font-size: 32px; color: var(--muted); }
.ah-empty--inline { margin: 0 20px 20px; padding: 28px; border: 1px dashed var(--border); border-radius: 10px; }
.ah-empty__title { font-weight: 600; }
.ah-empty__text { font-size: 13px; color: var(--text2); max-width: 560px; text-wrap: pretty; }

.ah-note { padding: 12px 14px; border-radius: 10px; background: var(--soft); font-size: 13px; color: var(--text2); }

/* ============ Workers table ============ */
.ah-table-wrap { overflow-x: auto; }
.ah-table { min-width: 980px; }

.ah-table--workers .ah-table__head,
.ah-table--workers .ah-table__row {
  display: grid;
  grid-template-columns: minmax(260px, 2.2fr) 120px 150px minmax(170px, 1.3fr) minmax(170px, 1.3fr) 220px;
  gap: 16px;
  padding: 12px 20px;
  align-items: center;
}

.ah-table__head {
  background: var(--soft);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: 12px 12px 0 0;
}

.ah-table__row { border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.ah-table__row:last-child { border-bottom: 0; }
.ah-table__row:hover { background: var(--panel2); }
.ah-table__row--err { background: var(--err-bg); }
.ah-cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ah-cell-main .ah-dot { width: 9px; height: 9px; }
.ah-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ============ Drawer ============ */
.ah-drawer-backdrop { position: fixed; inset: 0; background: rgb(15 23 42 / .35); z-index: 40; }

.ah-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100%);
  z-index: 41;
  background: var(--panel);
  color: var(--text);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px -8px rgb(45 55 72 / .28);
  display: flex;
  flex-direction: column;
}

.ah-drawer__head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.ah-drawer__title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ah-drawer__title { margin: 0; font-size: 18px; font-weight: 600; }
.ah-drawer__body { flex: 1; overflow: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 20px; }
.ah-drawer__desc { margin: 0; font-size: 13px; color: var(--text2); line-height: 1.5; }
.ah-drawer__foot { display: flex; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }

.ah-kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; font-size: 13px; }
.ah-kv__k { font-size: 12px; color: var(--text2); }
.ah-kv__v { font-weight: 500; }

.ah-section { display: flex; flex-direction: column; gap: 8px; }
.ah-section__title { font-weight: 600; }

.ah-error-box {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--err-bg);
  border: 1px solid var(--err-bd);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.ah-error-box__head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ah-error-box__code { font-weight: 600; color: var(--err-fg); }

.ah-log { border: 1px solid var(--border); border-radius: 10px; background: var(--code); }

.ah-log__row {
  display: grid;
  grid-template-columns: 92px 42px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--ah-mono-font);
  font-size: 12px;
  align-items: start;
}

.ah-log__row:last-child { border-bottom: 0; }
.ah-log__time { color: var(--text2); }

.ah-log__lvl {
  justify-self: start;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  background: var(--neu-bg);
  color: var(--neu-fg);
}

.ah-log__lvl--warn { background: var(--warn-bg); color: var(--warn-fg); }
.ah-log__lvl--err { background: var(--err-bg); color: var(--err-fg); }
.ah-log__msg { overflow-wrap: anywhere; }

/* ============ About ============ */
.ah-two-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 20px;
  align-items: start;
}

.ah-identity { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px 16px; font-size: 13px; }
.ah-identity__k { color: var(--text2); }
.ah-identity .ah-mono { overflow-wrap: anywhere; }

.ah-signature { font-weight: 600; }
.ah-signature--ok { color: var(--ok-fg); }
.ah-signature--warn { color: var(--warn-fg); }
.ah-signature--err { color: var(--err-fg); }
.ah-signature--neu { color: var(--text2); }

/* ============ Forms ============ */
.ah-btn:disabled { opacity: .5; cursor: not-allowed; }
.ah-form { display: flex; flex-direction: column; gap: 6px; }
.ah-form .viva-label { margin-top: 8px; }
.ah-form > .ah-btn { margin-top: 14px; align-self: flex-start; }
.ah-field-help { font-size: 12px; color: var(--text2); }
.ah-btn--block { justify-content: center; width: 100%; height: 38px; align-self: stretch !important; }
.ah-inline-form { display: contents; }
.ah-banner--ok { background: var(--ok-bg); border-color: var(--ok-bd); }
.ah-banner--ok > .ti, .ah-banner--ok .ah-banner__title { color: var(--ok-fg); }

/* ============ Header user ============ */
.ah-user { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #e2e8f0; max-width: 180px; }
.ah-user .ti { font-size: 18px; }
.ah-user__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ Sign-in and wizard layout ============ */
.ah-auth { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }

.ah-auth__bar {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: var(--chrome);
  color: #fff;
}

.ah-auth__main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 48px 24px;
  outline: none;
}

.ah-auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ah-auth-card__title { margin: 0; font-size: 22px; font-weight: 600; }
.ah-auth-card__sub { margin: 0; color: var(--text2); font-size: 14px; }
.ah-auth-card__hint { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; overflow-wrap: anywhere; }

/* The stepper of the design's « Installation » screen: steps on the left, the step on the right. */
.ah-wizard {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.ah-wizard__title { margin: 0; font-size: 20px; font-weight: 600; }
.ah-wizard__sub { margin: 6px 0 18px; color: var(--text2); font-size: 13px; }
.ah-wizard__steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.ah-wizard__step {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.ah-wizard__step:disabled { cursor: not-allowed; opacity: .6; }
.ah-wizard__step--active { background: var(--soft); }

.ah-wizard__mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--soft);
  color: var(--text2);
}

.ah-wizard__mark--done { background: var(--ok-bg); color: var(--ok-fg); }
.ah-wizard__mark--current { background: var(--accent); color: #fff; }
.ah-wizard__label { display: flex; flex-direction: column; min-width: 0; }
.ah-wizard__name { font-weight: 500; font-size: 14px; }
.ah-wizard__state { font-size: 12px; color: var(--text2); }
.ah-wizard__panel { min-height: 320px; }
.ah-wizard__panel .ah-form { max-width: 420px; }

.ah-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.ah-checklist__row { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.ah-checklist__row > .ti { font-size: 20px; margin-top: 1px; }
.ah-checklist__icon--ok { color: var(--ok-fg); }
.ah-checklist__icon--warn { color: var(--warn-fg); }
.ah-checklist__icon--todo { color: var(--muted); }

/* ============ Settings ============ */
.ah-settings { display: flex; flex-direction: column; }
.ah-setting { display: flex; flex-direction: column; gap: 6px; padding: 16px 20px; border-top: 1px solid var(--border); }
.ah-setting__head { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ah-setting__label { font-weight: 600; font-size: 14px; }
.ah-setting__help { font-size: 12px; color: var(--text2); max-width: 760px; line-height: 1.5; }
.ah-setting__row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ah-setting__row .viva-input { flex: 1 1 280px; max-width: 480px; }
.ah-setting__source { font-size: 12px; color: var(--text2); }
.ah-setting__source--warn { color: var(--warn-fg); }

.ah-setting__row .ah-readonly { flex: 1 1 280px; }

.ah-readonly {
  max-width: 480px;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--panel2);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ah-readonly > .ti { color: var(--text2); }
.ah-readonly--err { border-color: var(--err-bd); background: var(--err-bg); color: var(--err-fg); }
.ah-readonly--err > .ti { color: var(--err-fg); }

/* ============ Administration log ============ */
.ah-toolbar { display: flex; gap: 8px; align-items: center; }
.ah-search { position: relative; flex: 0 1 420px; }
.ah-search > .ti { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text2); }
.ah-search .viva-input { padding-left: 32px; width: 100%; }

.ah-audit { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }

.ah-audit th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text2);
}

.ah-audit td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ah-audit tbody tr:last-child td { border-bottom: 0; }
.ah-audit tbody tr:hover { background: var(--panel2); }

/* ============ Request log ============ */
.ah-toolbar--wrap { flex-wrap: wrap; }
.ah-filter { flex: 0 0 auto; width: auto; }
.ah-search--sm { flex: 0 1 220px; }
.ah-btn--danger { border-color: var(--err-bd); background: var(--err-bg); color: var(--err-fg); }
.ah-requests { min-width: 980px; }
.ah-requests__refused td { background: var(--err-bg); }
.ah-requests__refused td:first-child { box-shadow: inset 3px 0 0 var(--err-fg); }
.ah-link { padding: 0; border: 0; background: none; cursor: pointer; text-decoration: underline dotted; }
.ah-link:hover { color: var(--text); }
.ah-req-stats { width: 100%; border-collapse: collapse; font-size: 13px; }
.ah-req-stats th { padding: 8px 20px; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text2); border-top: 1px solid var(--border); }
.ah-req-stats td { padding: 10px 20px; border-top: 1px solid var(--border); }
.ah-req-stats .ah-right { text-align: right; }
.ah-req-stats__refused { color: var(--err-fg); font-weight: 600; }

@media (max-width: 860px) {
  .ah-wizard { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .ah-content { padding: 16px; }
  .ah-identity { grid-template-columns: 1fr; gap: 4px; }
  .ah-identity__k { margin-top: 8px; }
  .ah-banner__grid { grid-template-columns: 1fr; }
  .ah-user__name { display: none; }
  .ah-auth__main { padding: 24px 16px; }
}

/* ============ ERP connection and scripts (step 03) ============ */
.ah-card__head--wrap { flex-wrap: wrap; }
.ah-erp-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ah-erp-title > .ti { font-size: 20px; color: var(--text2); }
.ah-actions--inline { margin: 0; flex-wrap: wrap; align-items: center; }
.ah-note--card { margin: 0 20px; display: flex; gap: 8px; align-items: flex-start; }
.ah-note .ti { font-size: 16px; }
.ah-banner--card { margin: 14px 20px 0; }

.ah-erp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px 24px;
  padding: 20px;
}

.ah-erp-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ah-erp-field .viva-label { margin: 0; }
.ah-erp-field .ah-readonly { max-width: none; }
.ah-erp-short { max-width: 140px; }
.ah-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.ah-check input { width: 16px; height: 16px; accent-color: var(--accent); }

.ah-steps { margin: 0 20px 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); }
.ah-steps--flat { margin: 0; }
.ah-steps__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }

.ah-step {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  align-items: start;
  font-size: 13px;
}

.ah-step:last-child { border-bottom: 0; }
.ah-step > .ti { font-size: 18px; color: var(--muted); }
.ah-step--passed > .ti { color: var(--ok-fg); }
.ah-step--failed > .ti { color: var(--err-fg); }
.ah-step__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.ah-step__fix { margin-top: 4px; padding: 8px 10px; border-radius: 8px; background: var(--err-bg); font-size: 12px; line-height: 1.5; }
.ah-step__fix b { color: var(--err-fg); }

.ah-scripts td:nth-child(2), .ah-scripts td:nth-child(3) { white-space: nowrap; }
.ah-scripts__group td { background: var(--soft); font-weight: 600; }
.ah-scripts__group .ti { margin-right: 6px; color: var(--text2); }
.ah-scripts tbody tr.ah-scripts__group:hover { background: var(--soft); }
.ah-scripts__subgroup td { font-weight: 600; padding-top: 14px; }
.ah-scripts__subgroup .ti { margin-right: 6px; color: var(--text2); }
.ah-scripts__subgroup .ah-meta { font-weight: 400; }

.ah-recap { margin: 4px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.ah-recap li { display: list-item; }
.ah-recap li > * + * { margin-left: 8px; }
.ah-form__section { margin-top: 14px; }

.ah-kv-grid--4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.ah-kv-grid--4 .ah-readonly { max-width: none; margin-top: 4px; }
.ah-empty--flat { padding: 12px; }
.ah-wizard__nested { display: flex; flex-direction: column; gap: 16px; }
.ah-wizard__nested .ah-card { box-shadow: none; }
/* ============ Hub connections (step 04) ============ */
.ah-hub-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.ah-hub-row__main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ah-hub-row__main .ah-mono { overflow-wrap: anywhere; }
.ah-hub-row__meta { display: flex; flex-wrap: wrap; gap: 2px; }
.ah-hub-row .ah-steps { margin: 6px 0 0; }
.ah-field-help--ok { color: var(--ok-fg); }
.ah-step--warning > .ti { color: var(--warn-fg); }
.ah-step__fix--warn { background: var(--warn-bg); }
.ah-step__fix--warn b { color: var(--warn-fg); }

/* Channel of a hub module (step 05) */
.ah-channel { display: flex; flex-direction: column; gap: 6px; }
.ah-channel__main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ah-channel__cause { display: flex; flex-direction: column; gap: 4px; }
.ah-channel--compact { flex-basis: 100%; padding-left: 18px; }
.ah-channel__history summary { cursor: pointer; }
.ah-channel__history ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ah-channel__history li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ah-list__row:has(.ah-channel--compact) { flex-wrap: wrap; }

/* Local signal (step 10) */
.ah-sig-operator { width: 220px; }
.ah-sig-trigger { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--border); align-items: start; }
.ah-sig-trigger__icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 19px; }
.ah-sig-trigger__name { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.ah-sig-trigger__why { font-size: 13px; line-height: 1.5; margin-top: 4px; }
.ah-sig-principle { margin: 0 20px 20px; }
.ah-sig-endpoints { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 16px; }
.ah-sig-endpoint__head { display: flex; align-items: center; gap: 10px; }
.ah-sig-endpoint__head > .ti { font-size: 20px; color: var(--accent); }
.ah-sig-endpoint__head > .ah-badge { margin-left: auto; }
.ah-sig-url { font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--code); overflow-wrap: anywhere; }
.ah-kv-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) {
  .ah-sig-operator { width: 100%; }
  .ah-sig-trigger { grid-template-columns: 36px minmax(0, 1fr); }
  .ah-sig-trigger > .ah-badge { grid-column: 2; justify-self: start; }
}

/* Updates (step 11) */
.ah-update-offer { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); }
.ah-update-offer__head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.ah-update-notes { white-space: pre-line; font-size: 13px; line-height: 1.5; }
