/* admin.css — App Admin console and Unit Admin panel.
   Builds on Bootstrap 5.3 and the app's green (#2c5f2d). */

:root {
  --aui-green: #2c5f2d;
  --aui-green-dark: #1a3a2a;
  --aui-bg: #f4f6f9;
  --aui-line: #e5e7eb;
  --aui-muted: #6b7280;
  --aui-amber: #b45309;
}

body.aui { background: var(--aui-bg); }

/* ── top bar ─────────────────────────────────────────────────────────── */
.aui-topbar {
  background: var(--aui-green-dark); color: #fff;
  padding: 10px 16px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 1030;
}
.aui-topbar .brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.aui-topbar .badge-admin {
  background: #e74c3c; color: #fff; font-size: .68rem; padding: 2px 8px;
  border-radius: 99px; font-weight: 700; letter-spacing: .06em;
}
.aui-topbar .badge-support { background: #2563eb; }
.aui-search-btn {
  margin-left: auto; background: rgba(255,255,255,.1); color: #e5e7eb;
  border: 1px solid rgba(255,255,255,.18); border-radius: 8px;
  padding: 5px 10px; font-size: .85rem; display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.aui-search-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.aui-search-btn kbd { background: rgba(255,255,255,.15); font-size: .7rem; }

/* ── shell ───────────────────────────────────────────────────────────── */
.aui-shell { display: flex; min-height: calc(100vh - 52px); }
.aui-nav {
  width: 210px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--aui-line);
  padding: 14px 10px;
}
.aui-nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  color: #374151; text-decoration: none; font-size: .92rem; margin-bottom: 2px;
}
.aui-nav a:hover { background: #f3f4f6; }
.aui-nav a.active { background: #e8f3e8; color: var(--aui-green); font-weight: 600; }
.aui-nav a .bi { font-size: 1.05rem; width: 18px; text-align: center; }
.aui-nav .aui-nav-count {
  margin-left: auto; background: #fde68a; color: #92400e; font-size: .7rem;
  border-radius: 99px; padding: 0 7px; font-weight: 700;
}
.aui-main { flex: 1; min-width: 0; padding: 20px 24px 60px; }

@media (max-width: 767.98px) {
  .aui-shell { flex-direction: column; }
  .aui-nav {
    width: 100%; display: flex; overflow-x: auto; gap: 4px; padding: 8px;
    border-right: 0; border-bottom: 1px solid var(--aui-line);
  }
  .aui-nav a { white-space: nowrap; margin: 0; }
  .aui-main { padding: 14px 16px 60px; }
  .aui-search-btn .aui-search-label, .aui-search-btn kbd { display: none; }
}

/* ── headings, cards ─────────────────────────────────────────────────── */
.aui-crumbs { font-size: .8rem; color: var(--aui-muted); margin-bottom: 4px; }
.aui-crumbs a { color: var(--aui-muted); text-decoration: none; }
.aui-crumbs a:hover { color: var(--aui-green); text-decoration: underline; }
.aui-h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.aui-sub { color: var(--aui-muted); font-size: .88rem; }
.aui-card { background: #fff; border: 1px solid var(--aui-line); border-radius: 12px; }
.aui-card-h {
  padding: 12px 16px; border-bottom: 1px solid var(--aui-line);
  display: flex; align-items: center; gap: 8px; font-weight: 600;
}
.aui-card-b { padding: 16px; }

.aui-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.aui-stat { background: #fff; border: 1px solid var(--aui-line); border-radius: 12px; padding: 14px 16px; }
.aui-stat .v { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.aui-stat .l { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--aui-muted); }
.aui-stat.warn .v { color: var(--aui-amber); }

/* ── tables ──────────────────────────────────────────────────────────── */
.aui-table { margin: 0; font-size: .9rem; }
.aui-table th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--aui-muted);
  font-weight: 600; background: #fafafa; border-bottom-width: 1px; white-space: nowrap;
}
.aui-table td { vertical-align: middle; }
.aui-table tr.aui-click { cursor: pointer; }
.aui-table tr.aui-click:hover td { background: #f6faf6; }
.aui-table .aui-actions { white-space: nowrap; text-align: right; }
.aui-name { font-weight: 600; }
.aui-meta { font-size: .78rem; color: var(--aui-muted); }

/* ── chips ───────────────────────────────────────────────────────────── */
.aui-chip {
  display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 9px;
  border-radius: 99px; white-space: nowrap;
}
.aui-chip-ok   { background: #d1e7dd; color: #0f5132; }
.aui-chip-warn { background: #fff3cd; color: #7a5a00; }
.aui-chip-bad  { background: #f8d7da; color: #842029; }
.aui-chip-mute { background: #e9ecef; color: #495057; }

/* ── states ──────────────────────────────────────────────────────────── */
.aui-loading { padding: 28px; text-align: center; color: var(--aui-muted); font-size: .9rem; }
.aui-empty { padding: 36px 16px; text-align: center; color: var(--aui-muted); }
.aui-empty .bi { font-size: 2rem; opacity: .4; }
.aui-empty-title { font-weight: 600; color: #374151; margin-top: 6px; }
.aui-empty-hint { font-size: .85rem; margin-top: 4px; }

/* ── unit context banner (view-as) ───────────────────────────────────── */
.aui-context {
  border-radius: 10px; padding: 10px 14px; font-size: .88rem; margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.aui-context.edit { background: #e8f3e8; color: #14532d; border: 1px solid #b7dfb9; }
.aui-context.view { background: #fff7e6; color: #7c4a03; border: 1px solid #f5d08a; }

/* ── drawer ──────────────────────────────────────────────────────────── */
.aui-drawer { width: min(520px, 100vw) !important; }
.aui-kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: .88rem; }
.aui-kv dt { color: var(--aui-muted); font-weight: 500; }
.aui-kv dd { margin: 0; word-break: break-word; }

/* ── command palette ─────────────────────────────────────────────────── */
.aui-palette .modal-dialog { margin-top: 10vh; }
.aui-palette input { font-size: 1.05rem; border: 0; box-shadow: none !important; }
.aui-palette .list-group-item { border-left: 0; border-right: 0; cursor: pointer; }
.aui-palette .list-group-item.active { background: #e8f3e8; color: #14532d; border-color: var(--aui-line); }
.aui-palette .aui-pal-group {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--aui-muted); padding: 8px 16px 4px; background: #fafafa;
}

/* audit details */
.aui-diff { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; color: #374151; }
.aui-diff .from { color: #991b1b; }
.aui-diff .to { color: #166534; }
