/* ==========================================================================
   Nova Finance Group Trade - Institutional UI Stylesheet
   Tone: top-tier private bank / wealth platform. Restrained palette.
   ========================================================================== */

:root {
  --c-bg: #f5f6f8;
  --c-bg-deep: #ebedf1;
  --c-surface: #ffffff;
  --c-surface-2: #fafbfc;
  --c-border: #d6dade;
  --c-border-strong: #b9bfc6;
  --c-text: #1c2530;
  --c-text-muted: #5b6675;
  --c-text-soft: #8a93a0;
  --c-accent: #0e2c4d;
  --c-accent-strong: #08213c;
  --c-accent-soft: #e6ecf3;
  --c-gold: #b08a3c;
  --c-gold-soft: #f3ebd9;
  --c-success: #2e7d4f;
  --c-success-soft: #e6f1ea;
  --c-warn: #b46a00;
  --c-warn-soft: #fbf0dc;
  --c-error: #b3261e;
  --c-error-soft: #fbe6e4;
  --c-info: #1c4f8b;
  --c-info-soft: #e6eef7;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --shadow-soft: 0 1px 2px rgba(15, 25, 40, 0.04), 0 1px 3px rgba(15, 25, 40, 0.06);
  --shadow-pop: 0 8px 24px rgba(15, 25, 40, 0.10), 0 2px 6px rgba(15, 25, 40, 0.06);

  --sidebar-w: 252px;
  --topbar-h: 56px;
  --subnav-h: 44px;
  --drawer-w: 380px;
  --space-page: 20px;
  --space-panel: 16px;

  --font-sans: "Sora", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Plus Jakarta Sans", "Sora", var(--font-sans);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ============================================================
   LOGIN
   ============================================================ */
.screen-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: linear-gradient(135deg, #0e2c4d 0%, #08213c 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-pop);
  position: relative;
  overflow: hidden;
}
.login-card-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--c-gold) 0%, #d4b56a 50%, var(--c-gold) 100%);
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--c-accent);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; justify-content: center; }
.brand-mark {
  width: 44px; height: 44px; background: var(--c-accent); color: #fff;
  border-radius: var(--r-md); display: flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: 1px;
}
.brand-text .brand-name { font-weight: 700; font-size: 15px; color: var(--c-accent); }
.brand-text .brand-product { font-size: 12px; color: var(--c-text-muted); letter-spacing: .4px; text-transform: uppercase; }
.brand-logo { max-height: 56px; max-width: 240px; object-fit: contain; }
.portal-pill {
  display: inline-block; margin: 0 auto 14px;
  font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px;
  background: var(--c-accent-soft); color: var(--c-accent);
  text-align: center; font-weight: 700;
}
.portal-internal .portal-pill { background: var(--c-accent-soft); color: var(--c-accent); }
.portal-client   .portal-pill { background: #eaf3ee; color: var(--c-success); }
.portal-broker   .portal-pill { background: var(--c-gold-soft); color: var(--c-gold); }
.portal-partners .portal-pill { background: #efe8f7; color: #4a3d6b; }
.portal-partners .sidebar-link.active { border-left-color: #7c5cbf; }
.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--c-accent);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-sub { margin: 0 0 24px; color: var(--c-text-muted); font-size: 13px; }
.login-card label { display: block; margin-bottom: 16px; font-size: 12px; color: var(--c-text-muted); }
.login-card input {
  width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 1px solid var(--c-border); border-radius: var(--r-md); font-size: 14px;
  font-family: var(--font-sans); background: #fff; color: var(--c-text);
}
.login-card input:focus { outline: 2px solid var(--c-accent); outline-offset: -1px; }
.login-card button {
  width: 100%; padding: 11px; background: var(--c-accent); color: #fff; border: none;
  border-radius: var(--r-md); font-weight: 600; cursor: pointer; font-size: 14px;
  margin-top: 8px;
}
.login-card button:hover { background: var(--c-accent-strong); }
.login-card button:disabled { background: var(--c-text-soft); cursor: not-allowed; }
.login-card .btn-oidc {
  margin-top: 10px;
  width: 100%;
  background: transparent;
  color: var(--c-accent);
  border: 1px solid var(--c-accent);
}
.login-card .btn-oidc:hover { background: rgba(215, 180, 90, 0.12); }
.login-error {
  min-height: 18px; color: var(--c-error); font-size: 12px; margin-bottom: 4px;
}
.login-foot {
  margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--c-border);
  font-size: 11px; color: var(--c-text-soft); display: flex; justify-content: space-between;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.screen-app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar workspace";
  height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: var(--c-accent);
  color: #cfd6df;
  overflow-y: auto;
  border-right: 1px solid var(--c-accent-strong);
  display: flex; flex-direction: column;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.sidebar-brand .mark {
  width: 32px; height: 32px; background: var(--c-gold); color: var(--c-accent);
  border-radius: var(--r-sm); font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.sidebar-brand .logo {
  width: 32px; height: 32px; border-radius: var(--r-sm); object-fit: contain; background: #fff;
}
.sidebar-brand .name { color: #fff; font-weight: 700; font-size: 13px; }
.sidebar-brand .sub  { color: #9aa6b6; font-size: 10.5px; letter-spacing: .4px; text-transform: uppercase; }
.portal-client .sidebar-link.active { border-left-color: var(--c-success); }
.portal-broker .sidebar-link.active { border-left-color: var(--c-gold); }

.sidebar-section { padding: 14px 0 6px; }
.sidebar-section-title {
  padding: 4px 16px; font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase;
  color: #8a96a8;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  color: #cbd2dd; cursor: pointer; font-size: 13px; border-left: 2px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,0.04); color: #fff; }
.sidebar-link.active {
  background: rgba(255,255,255,0.06); color: #fff;
  border-left-color: var(--c-gold);
}
.sidebar-link .ico {
  width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
  color: inherit; flex-shrink: 0;
}
.sidebar-foot {
  margin-top: auto; padding: 10px 16px; font-size: 11px; color: #7d8a9b;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.topbar {
  grid-area: topbar;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
  box-shadow: var(--shadow-soft);
}
.topbar .crumbs {
  flex: 1; display: flex; align-items: center; gap: 8px; color: var(--c-text-muted); font-size: 13px;
}
.topbar .crumbs .sep { color: var(--c-text-soft); }
.topbar .crumbs strong { color: var(--c-text); font-weight: 600; }
.topbar .actions { display: flex; align-items: center; gap: 12px; }
.topbar .badge-env {
  font-size: 10.5px; padding: 3px 8px; border-radius: 999px;
  background: var(--c-success-soft); color: var(--c-success); font-weight: 600;
  letter-spacing: .4px; text-transform: uppercase;
}
.topbar .user {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: var(--r-md);
  cursor: pointer;
}
.topbar .user:hover { background: var(--c-bg-deep); }
.topbar .user .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--c-accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.topbar .user .meta { line-height: 1.1; font-size: 12px; }
.topbar .user .meta .name { color: var(--c-text); font-weight: 600; }
.topbar .user .meta .role { color: var(--c-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }

.workspace {
  grid-area: workspace;
  overflow-y: auto;
  padding: 20px 28px 60px;
  background: var(--c-bg);
}

/* ============================================================
   COMPONENTS
   ============================================================ */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 20px;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; color: var(--c-text); font-family: var(--font-display); letter-spacing: -0.02em; }
.page-sub  { color: var(--c-text-muted); margin: 4px 0 0; font-size: 13px; }
.page-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--c-border-strong); background: var(--c-surface);
  border-radius: var(--r-md); cursor: pointer; font-size: 13px; font-family: inherit;
  color: var(--c-text);
}
.btn:hover { background: var(--c-bg-deep); }
.btn-primary {
  background: var(--c-accent); color: #fff; border-color: var(--c-accent);
}
.btn-primary:hover { background: var(--c-accent-strong); }
.btn-danger {
  background: var(--c-error); color: #fff; border-color: var(--c-error);
}
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--c-bg-deep); }
.btn-sm { padding: 4px 8px; font-size: 12px; }

.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); margin-bottom: 16px;
}
.tab {
  padding: 8px 14px; cursor: pointer; font-size: 13px; color: var(--c-text-muted);
  border-bottom: 2px solid transparent; user-select: none;
}
.tab:hover { color: var(--c-text); }
.tab.active { color: var(--c-accent); border-bottom-color: var(--c-accent); font-weight: 600; }

.cards-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
  padding: 16px; box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { border-color: var(--c-border-strong); }
.card.is-clickable:hover, .card[role="button"]:hover {
  border-color: rgba(176, 138, 60, 0.45);
  box-shadow: var(--shadow-pop);
}
.card-title { font-size: 11px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .5px; margin: 0 0 6px; }
.card-value { font-size: 26px; font-weight: 700; color: var(--c-text); }
.card-foot  { margin-top: 8px; font-size: 11px; color: var(--c-text-soft); }

.panel {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
  margin-bottom: 16px; overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--c-surface-2); border-bottom: 1px solid var(--c-border);
}
.panel-header h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--c-text); }
.panel-body { padding: 16px; }
.panel-body.no-pad { padding: 0; }

/* Two-column responsive form grid for dedicated full-page forms. */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 24px;
}
@media (max-width: 760px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

/* Granular permission checkbox grid (personnel management). */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 18px;
}
@media (max-width: 760px) { .perm-grid { grid-template-columns: 1fr; } }
.perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border, #e3e7ee);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background .12s, border-color .12s;
}
.perm-item:hover { background: var(--surface-hover, #f5f7fb); }
.perm-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* ===================== WEBMAIL (Thunderbird/cPanel style) ===================== */
.webmail {
  display: grid;
  grid-template-columns: 210px 340px 1fr;
  gap: 0;
  border: 1px solid var(--c-border, #e3e7ee);
  border-radius: 10px;
  overflow: hidden;
  min-height: 540px;
  background: var(--c-surface, #fff);
}
@media (max-width: 1100px) { .webmail { grid-template-columns: 180px 1fr; } .wm-reader { display: none; } }
.wm-folders { border-right: 1px solid var(--c-border, #e3e7ee); padding: 12px 8px; background: var(--c-surface-2, #fafbfd); }
.wm-folder-list { display: flex; flex-direction: column; gap: 2px; }
.wm-folder {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px; color: var(--c-text, #1c2430);
  text-decoration: none; cursor: pointer; transition: background .12s;
}
.wm-folder:hover { background: var(--surface-hover, #eef1f6); }
.wm-folder.active { background: var(--c-primary, #2563eb); color: #fff; font-weight: 600; }
.wm-folder.active .badge { background: rgba(255,255,255,.25); color: #fff; }
.wm-folder-sep { height: 1px; background: var(--c-border, #e3e7ee); margin: 8px 4px; }
.wm-list { border-right: 1px solid var(--c-border, #e3e7ee); display: flex; flex-direction: column; min-width: 0; }
.wm-list-head { padding: 12px; border-bottom: 1px solid var(--c-border, #e3e7ee); display: flex; flex-direction: column; gap: 8px; }
.wm-list-title { font-weight: 700; font-size: 15px; }
.wm-list-body { overflow-y: auto; flex: 1; }
.wm-row { display: flex; gap: 8px; padding: 11px 12px; border-bottom: 1px solid var(--c-border-light, #f0f2f6); cursor: pointer; }
.wm-row:hover { background: var(--surface-hover, #f5f7fb); }
.wm-row.active { background: var(--c-primary-soft, #eaf1ff); }
.wm-row.unread .wm-row-subject, .wm-row.unread .wm-row-who { font-weight: 700; }
.wm-row.unread { border-left: 3px solid var(--c-primary, #2563eb); }
.wm-row-star { font-size: 16px; color: #f0a500; line-height: 1; cursor: pointer; }
.wm-row-main { min-width: 0; flex: 1; }
.wm-row-top { display: flex; justify-content: space-between; gap: 8px; }
.wm-row-who { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-row-subject { font-size: 13.5px; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-row-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-reader { padding: 0; display: flex; flex-direction: column; min-width: 0; }
.wm-reader-pane { display: flex; flex-direction: column; height: 100%; }
.wm-reader-head { padding: 16px 18px; border-bottom: 1px solid var(--c-border, #e3e7ee); }
.wm-reader-subject { margin: 0 0 8px; font-size: 18px; }
.wm-reader-meta { display: flex; flex-direction: column; gap: 2px; }
.wm-reader-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.wm-reader-body { padding: 18px; overflow-y: auto; flex: 1; line-height: 1.55; font-size: 14px; }
.wm-attachments { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--c-border-light, #f0f2f6); }
.wm-att-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; background: var(--c-surface-2, #f1f4f9); border-radius: 14px; font-size: 12px; }
.wm-att-x { border: none; background: none; cursor: pointer; font-size: 14px; color: var(--c-text-muted, #888); }
.wm-compose { display: flex; flex-direction: column; gap: 8px; }
.wm-compose-editor { margin-top: 6px; }
.wm-signature-preview { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--c-border, #d8dee8); }
.wm-sig-box { padding: 10px 12px; border-radius: 8px; background: var(--c-surface-2, #f6f8fb); font-size: 13px; }
.wm-compose-attbar { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.wm-compose-atts { display: flex; gap: 6px; flex-wrap: wrap; }
.wm-cfg-sep { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted, #7a8290); margin: 14px 0 4px; }
.file-input {
  width: 100%;
  font-size: 13px;
  padding: 8px;
  border: 1px dashed var(--c-border);
  border-radius: 6px;
  background: var(--c-bg-subtle, transparent);
  cursor: pointer;
}

/* ----- WYSIWYG visual editor ----- */
.wysiwyg {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--c-surface-2, #f5f6f8);
  border-bottom: 1px solid var(--c-border);
}
.wysiwyg-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--c-text, #1c2530);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.wysiwyg-btn:hover { background: rgba(0,0,0,0.06); border-color: var(--c-border); }
.wysiwyg-select {
  height: 30px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  padding: 0 6px;
}
.wysiwyg-sep { width: 1px; height: 20px; background: var(--c-border); margin: 0 4px; }
.wysiwyg-area {
  padding: 18px 22px;
  outline: none;
  font-size: 14px;
  line-height: 1.6;
  color: #1c2530;
  background: #fff;
  overflow-y: auto;
  max-height: 640px;
}
.wysiwyg-area:focus { box-shadow: inset 0 0 0 2px rgba(40,90,160,0.12); }
.wysiwyg-area h1 { font-size: 22px; margin: 12px 0 8px; }
.wysiwyg-area h2 { font-size: 18px; margin: 12px 0 6px; }
.wysiwyg-area h3 { font-size: 15px; margin: 10px 0 6px; }
.wysiwyg-area p { margin: 0 0 10px; }
.wysiwyg-area blockquote {
  margin: 10px 0; padding: 6px 14px;
  border-left: 3px solid var(--c-gold, #c8a24a); color: #4a5563;
}
.wysiwyg-area table { border-collapse: collapse; margin: 10px 0; }
.wysiwyg-area td, .wysiwyg-area th { border: 1px solid #c8cdd4; padding: 4px 8px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.table th { background: var(--c-surface-2); font-weight: 600; color: var(--c-text-muted);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
.table tbody tr:hover { background: var(--c-bg-deep); cursor: pointer; }

.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
}
.badge-success { background: var(--c-success-soft); color: var(--c-success); }
.badge-warn    { background: var(--c-warn-soft); color: var(--c-warn); }
.badge-error   { background: var(--c-error-soft); color: var(--c-error); }
.badge-info    { background: var(--c-info-soft); color: var(--c-info); }
.badge-neutral { background: var(--c-bg-deep); color: var(--c-text-muted); }

.empty {
  padding: 40px; text-align: center; color: var(--c-text-muted); font-size: 13px;
}
.empty .em-icon {
  display: inline-block; width: 40px; height: 40px;
  border-radius: 50%; background: var(--c-bg-deep); margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-left: auto; margin-right: auto;
}

.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-row label { font-size: 12px; color: var(--c-text-muted); }
.form-row input, .form-row select, .form-row textarea {
  padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-family: inherit; font-size: 13px; background: #fff; color: var(--c-text);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: 2px solid var(--c-accent); outline-offset: -1px; border-color: var(--c-accent);
}
.form-row textarea { min-height: 100px; resize: vertical; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,25,40,0.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--c-surface); border-radius: var(--r-lg); width: 100%; max-width: 520px;
  box-shadow: var(--shadow-pop); overflow: hidden;
}
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--c-border); display:flex; align-items:center; justify-content:space-between; }
.modal-body { padding: 20px; max-height: 65vh; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: 8px; background: var(--c-surface-2); }
.modal-close { cursor: pointer; color: var(--c-text-muted); font-size: 18px; }
.modal-close:hover { color: var(--c-text); }

.kv-list { font-size: 13px; }
.kv-list .kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--c-border); }
.kv-list .kv:last-child { border-bottom: none; }
.kv-list .k { color: var(--c-text-muted); font-size: 12px; }
.kv-list .v { color: var(--c-text); }

.toast {
  position: fixed; bottom: 24px; right: 24px; min-width: 240px; max-width: 360px;
  background: var(--c-text); color: #fff; padding: 12px 16px; border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); font-size: 13px; z-index: 200;
}
.toast.error { background: var(--c-error); }
.toast.success { background: var(--c-success); }

.section-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.section-tab {
  padding: 5px 10px; border: 1px solid var(--c-border); border-radius: 999px;
  font-size: 12px; cursor: pointer; background: var(--c-surface);
  color: var(--c-text-muted);
}
.section-tab.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.section-tab:hover:not(.active) { background: var(--c-bg-deep); }

.code {
  font-family: var(--font-mono); font-size: 12px; background: var(--c-surface-2);
  padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--c-border);
  white-space: pre-wrap; word-break: break-all; color: var(--c-text);
}

.muted { color: var(--c-text-muted); }
.small { font-size: 12px; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }

/* ============================================================
   3-TIER LAYOUT: TOPBAR + SUB-NAV + BREADCRUMB
   ============================================================ */
.topbar-stack {
  grid-area: topbar;
  display: flex; flex-direction: column;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-soft);
}
.topbar-row {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: var(--topbar-h);
}
.subnav-row {
  display: flex; align-items: center; gap: 4px;
  padding: 0 20px; min-height: 38px;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
  overflow-x: auto;
}
.subnav-tab {
  padding: 8px 12px; font-size: 13px; cursor: pointer;
  color: var(--c-text-muted); border-bottom: 2px solid transparent;
  white-space: nowrap; user-select: none;
}
.subnav-tab:hover { color: var(--c-text); }
.subnav-tab.active {
  color: var(--c-accent); border-bottom-color: var(--c-accent);
  font-weight: 600;
}
.subnav-meta {
  margin-left: auto; padding: 0 12px; font-size: 11.5px;
  color: var(--c-text-soft); display: flex; align-items: center; gap: 8px;
}

.crumbs-link {
  cursor: pointer; color: var(--c-text-muted);
}
.crumbs-link:hover { color: var(--c-accent); text-decoration: underline; }

/* ============================================================
   PAGE HEADER (entity & module headers)
   ============================================================ */
.page-header { gap: 24px; }
.page-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 8px; font-size: 12px; color: var(--c-text-muted);
}
.page-meta .pm-item { display: inline-flex; align-items: center; gap: 4px; }

.entity-header {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
  padding: 18px 22px; margin-bottom: 16px; box-shadow: var(--shadow-soft);
}
.entity-header h1 { margin: 0; font-size: 20px; color: var(--c-text); font-weight: 700; }
.entity-header .eh-id {
  font-family: var(--font-mono); font-size: 11px; color: var(--c-text-muted);
  background: var(--c-bg-deep); padding: 2px 6px; border-radius: var(--r-sm);
}
.entity-header .eh-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.entity-header .eh-meta {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 10px; font-size: 12.5px; color: var(--c-text-muted);
}
.entity-header .eh-meta strong { color: var(--c-text); font-weight: 600; }
.entity-header .eh-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.entity-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--c-border);
  margin-bottom: 16px; overflow-x: auto;
}
.entity-tab {
  padding: 10px 16px; cursor: pointer; font-size: 13px; color: var(--c-text-muted);
  border-bottom: 2px solid transparent; user-select: none; white-space: nowrap;
}
.entity-tab:hover { color: var(--c-text); }
.entity-tab.active {
  color: var(--c-accent); border-bottom-color: var(--c-accent); font-weight: 600;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filters-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 14px; background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); margin-bottom: 12px; box-shadow: var(--shadow-soft);
}
.filters-bar .filter-input,
.filters-bar .filter-select {
  padding: 6px 10px; border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-size: 13px; font-family: inherit; background: #fff; color: var(--c-text);
  min-width: 130px;
}
.filters-bar .filter-input:focus, .filters-bar .filter-select:focus {
  outline: 2px solid var(--c-accent); outline-offset: -1px; border-color: var(--c-accent);
}
.filters-bar .filter-spacer { flex: 1; }
.filters-bar .filter-search { min-width: 220px; }

.list-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.list-toolbar .lt-info { font-size: 12px; color: var(--c-text-muted); }

/* ============================================================
   DRAWER
   ============================================================ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(15,25,40,0.35); z-index: 90;
}
.drawer-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: var(--drawer-w);
  background: var(--c-surface); border-left: 1px solid var(--c-border);
  box-shadow: var(--shadow-pop); z-index: 95; display: flex; flex-direction: column;
}
.drawer-panel.wide { width: 540px; }
.drawer-header {
  padding: 14px 18px; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--c-surface-2);
}
.drawer-header h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--c-text); }
.drawer-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.drawer-foot {
  padding: 12px 18px; border-top: 1px solid var(--c-border);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--c-surface-2);
}
.drawer-close { cursor: pointer; color: var(--c-text-muted); font-size: 18px; padding: 0 4px; }
.drawer-close:hover { color: var(--c-text); }

/* ============================================================
   THREE-PANE EMAIL LAYOUT
   ============================================================ */
.email-layout {
  display: grid; gap: 12px; height: calc(100vh - var(--topbar-h) - 100px);
  grid-template-columns: 320px 1fr;
}
.email-layout.with-thread {
  grid-template-columns: 280px 1fr 360px;
}
.email-pane {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
  display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}
.email-pane-header {
  padding: 10px 14px; border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-2); font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
}
.email-pane-body { flex: 1; overflow-y: auto; padding: 0; }
.email-list-item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--c-border);
}
.email-list-item:hover { background: var(--c-bg-deep); }
.email-list-item.active { background: var(--c-accent-soft); border-left: 3px solid var(--c-accent); }
.email-list-item .eli-subject { font-weight: 600; font-size: 13px; color: var(--c-text); }
.email-list-item .eli-meta { font-size: 11.5px; color: var(--c-text-muted); margin-top: 2px; }

.email-message {
  padding: 14px 16px; border-bottom: 1px solid var(--c-border);
}
.email-message .em-from { font-weight: 600; font-size: 13px; color: var(--c-text); }
.email-message .em-to   { font-size: 12px; color: var(--c-text-muted); margin-top: 2px; }
.email-message .em-time { float: right; font-size: 11.5px; color: var(--c-text-soft); }
.email-message .em-body {
  margin-top: 10px; white-space: pre-wrap; font-size: 13px; color: var(--c-text);
  line-height: 1.6;
}
.email-message.draft { background: var(--c-warn-soft); }
.email-message .em-tag {
  display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 999px;
  background: var(--c-info-soft); color: var(--c-info); font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px; margin-left: 8px;
}
.email-message.outbound { background: var(--c-bg); }

.email-composer {
  border-top: 1px solid var(--c-border); padding: 12px 16px;
  background: var(--c-surface-2);
}
.email-composer textarea {
  width: 100%; min-height: 110px; padding: 8px 10px;
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-size: 13px; font-family: inherit; resize: vertical;
}
.email-composer .ec-row { display: flex; gap: 8px; margin-bottom: 8px; }
.email-composer .ec-row label { font-size: 12px; color: var(--c-text-muted); width: 38px; padding-top: 8px; }
.email-composer .ec-row input { flex: 1; }

/* ============================================================
   AI CHAT
   ============================================================ */
.ai-chat {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
  display: flex; flex-direction: column; min-height: 480px; overflow: hidden;
}
.ai-chat-body {
  padding: 18px; overflow-y: auto; flex: 1; max-height: 60vh;
}
.ai-message {
  margin-bottom: 14px; max-width: 80%;
  padding: 10px 14px; border-radius: var(--r-md);
  font-size: 13px; line-height: 1.6; white-space: pre-wrap;
}
.ai-message.user {
  margin-left: auto; background: var(--c-accent); color: #fff;
}
.ai-message.assistant {
  margin-right: auto; background: var(--c-surface-2); border: 1px solid var(--c-border);
  color: var(--c-text);
}
.ai-message .am-meta { font-size: 11px; opacity: .7; margin-bottom: 4px; }
.ai-input-row {
  border-top: 1px solid var(--c-border); padding: 12px 16px;
  background: var(--c-surface-2); display: flex; gap: 8px; align-items: flex-end;
}
.ai-input-row textarea {
  flex: 1; min-height: 60px; max-height: 200px; resize: vertical;
  padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-size: 13px; font-family: inherit;
}

/* ============================================================
   ACTIONS REQUIRED LIST (dashboard)
   ============================================================ */
.actions-list {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
  overflow: hidden;
}
.actions-list .al-row {
  padding: 10px 14px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; border-bottom: 1px solid var(--c-border); cursor: pointer;
}
.actions-list .al-row:last-child { border-bottom: none; }
.actions-list .al-row:hover { background: var(--c-bg-deep); }
.actions-list .al-label { font-size: 13px; color: var(--c-text); }
.actions-list .al-meta { font-size: 11.5px; color: var(--c-text-muted); }
.actions-list .al-kind {
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--c-accent-soft); color: var(--c-accent);
  font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}

/* ============================================================
   DOC PREVIEW & DETAIL
   ============================================================ */
.doc-preview {
  width: 100%; min-height: 60vh;
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  background: var(--c-surface-2);
}
.doc-preview-iframe { width: 100%; min-height: 60vh; border: 0; }
.doc-preview-img { width: 100%; max-height: 60vh; object-fit: contain; }
.doc-preview-text {
  width: 100%; max-height: 60vh; overflow: auto; padding: 12px;
  font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap;
}

/* ============================================================
   WIZARD (onboarding)
   ============================================================ */
.wizard-stepper {
  display: flex; align-items: center; gap: 8px; margin-bottom: 24px;
  flex-wrap: wrap;
}
.wizard-step {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  border: 1px solid var(--c-border); border-radius: 999px;
  font-size: 12px; color: var(--c-text-muted); background: var(--c-surface);
}
.wizard-step.active { border-color: var(--c-accent); color: var(--c-accent); font-weight: 600; }
.wizard-step.done { border-color: var(--c-success); color: var(--c-success); }
.wizard-step .ws-num {
  width: 18px; height: 18px; border-radius: 50%; background: var(--c-bg-deep);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
}
.wizard-step.active .ws-num { background: var(--c-accent); color: #fff; }
.wizard-step.done .ws-num { background: var(--c-success); color: #fff; }

/* ============================================================
   STATUS / SCROLL helpers
   ============================================================ */
.scroll-x { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.text-mono { font-family: var(--font-mono); font-size: 12px; }

.detail-grid {
  display: grid; gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 980px) {
  .detail-grid.two { grid-template-columns: 2fr 1fr; }
}

.empty-soft {
  padding: 20px; text-align: center; color: var(--c-text-muted); font-size: 12.5px;
  background: var(--c-surface-2); border-radius: var(--r-md);
  border: 1px dashed var(--c-border);
}

.pagination {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 6px; padding: 8px 12px; font-size: 12px; color: var(--c-text-muted);
}
.pagination button {
  padding: 4px 8px; font-size: 12px;
}

.tag-list { display: flex; gap: 4px; flex-wrap: wrap; }
.tag-list .tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 4px;
  background: var(--c-bg-deep); color: var(--c-text-muted);
}

.split { display: flex; align-items: center; gap: 8px; }

.stat-line {
  display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 12px;
  background: var(--c-surface-2); border-radius: var(--r-md);
  margin-bottom: 12px; font-size: 12px;
}
.stat-line .sl-item .sl-num { font-weight: 700; color: var(--c-text); }
.stat-line .sl-item .sl-lab { color: var(--c-text-muted); margin-right: 2px; }

/* ============================================================
   BATCH 2 - SHELL UI / ROUTER / COMPONENTI BASE
   Additive only: no existing class is removed or restyled.
   ============================================================ */

/* App-shell layout extended to host the sub-nav row between topbar
   and workspace. When #subnav is .hidden the row collapses to 0. */
.screen-app {
  grid-template-rows: var(--topbar-h) auto 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar subnav"
    "sidebar workspace";
}
#subnav {
  grid-area: subnav;
}
.sidebar-hub-list {
  padding: 10px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* Modern, icon-forward primary navigation. Each macro-function is a prominent
   icon + label tile; clicking opens the dedicated area workspace. */
.sidebar-hub-link {
  margin: 1px 10px;
  padding: 9px 12px;
  border-radius: 10px;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  border-left: 0;
  transition: background .12s ease, color .12s ease, transform .08s ease;
}
.sidebar-hub-link .ico {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #b9c3d1;
  transition: background .12s ease, color .12s ease;
}
.sidebar-hub-link .ico svg { width: 17px; height: 17px; }
.sidebar-hub-link:hover { background: rgba(255,255,255,0.05); color: #fff; transform: translateX(1px); }
.sidebar-hub-link:hover .ico { color: #fff; background: rgba(255,255,255,0.12); }
.sidebar-hub-link.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-left: 0;
}
.sidebar-hub-link.active .ico {
  background: var(--c-gold);
  color: var(--c-accent);
}
.sidebar-hub-link.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--c-gold);
  border-radius: 0 3px 3px 0;
}
.sidebar-hub-link { position: relative; }
.subnav-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}
.subnav-hub-modules {
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-2);
}
.subnav-module-sections {
  background: var(--c-surface);
}
#subnav.hidden {
  display: none !important;
}

/* ----- Sidebar group collapse + activity badge ----- */
.sidebar-group-header {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none;
  padding: 6px 16px;
}
.sidebar-group-header:hover { color: #fff; }
.sidebar-group-header .ico { color: #8a96a8; flex-shrink: 0; }
.sidebar-section.is-collapsed .sidebar-link { display: none; }
.sidebar-link-label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--c-gold); color: var(--c-accent);
  font-size: 10.5px; font-weight: 700; letter-spacing: .2px;
  margin-left: auto;
}

/* ----- Topbar: search placeholder + crumb-bar alias ----- */
.crumb-bar { display: flex; align-items: center; gap: 8px; }
.crumb-bar .crumb-root { color: var(--c-text-muted); font-size: 12.5px; }
.crumb-bar .crumb-entity { color: var(--c-text); font-weight: 600; }
.topbar-search {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 1px solid var(--c-border);
  border-radius: var(--r-md); background: var(--c-surface-2);
  color: var(--c-text-muted); min-width: 200px;
}
.topbar-search-input {
  border: 0; outline: 0; background: transparent;
  font-size: 12.5px; flex: 1; color: var(--c-text);
  font-family: inherit;
}
.topbar-search-input::placeholder { color: var(--c-text-soft); }
.topbar-search-input:disabled { cursor: not-allowed; color: var(--c-text-soft); }

/* ----- Sub-nav (top) - alias on top of existing .subnav-row ----- */
.subnav-top {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px; min-height: 38px;
  background: var(--c-surface-2);
  border-top: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
}
.subnav-top .subnav-tab {
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--c-border); background: var(--c-surface);
  color: var(--c-text-muted); font-size: 12px; cursor: pointer;
  white-space: nowrap;
}
.subnav-top .subnav-tab:hover { color: var(--c-text); background: var(--c-bg-deep); }
.subnav-top .subnav-tab.active {
  background: var(--c-accent); color: #fff; border-color: var(--c-accent);
  font-weight: 600;
}
.subnav-meta {
  margin-left: auto; padding: 0 8px; font-size: 11.5px;
  color: var(--c-text-soft);
}

/* ----- Status badge (alias) ----- */
.badge-status { font-weight: 600; }

/* ----- Filter bar (alias on top of existing .filters-bar) ----- */
.filter-bar { /* class is also rendered alongside .filters-bar */ }
.filter-bar .filter-cell {
  display: flex; flex-direction: column; gap: 2px;
}
.filter-bar .filter-label { font-size: 11px; }
.filter-bar .filter-spacer { flex: 1; min-width: 12px; }

/* ----- Empty-pro / skeleton ----- */
.empty-pro {
  padding: 36px 28px;
  text-align: center;
  color: var(--c-text-muted);
  font-size: 13px;
  background: var(--c-surface-2);
  border: 1px dashed var(--c-border);
  border-radius: var(--r-md);
}
.empty-pro .ep-title {
  display: block; font-size: 13.5px; color: var(--c-text); font-weight: 600;
  margin-bottom: 4px;
}
.empty-pro .ep-hint { font-size: 12px; color: var(--c-text-soft); }

@keyframes nova-skeleton-shimmer {
  0%   { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
  display: inline-block; vertical-align: middle;
  background-color: var(--c-bg-deep);
  background-image: linear-gradient(90deg, var(--c-bg-deep) 0%, var(--c-surface-2) 50%, var(--c-bg-deep) 100%);
  background-size: 200px 100%;
  background-repeat: no-repeat;
  border-radius: var(--r-sm);
  animation: nova-skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-line { height: 12px; width: 100%; }
.skeleton-block { height: 80px; width: 100%; display: block; }

/* ----- Data-table reusable component ----- */
.data-table-wrap { display: block; }
.data-table-wrap .list-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
.data-table-wrap .list-toolbar .lt-left { display: flex; gap: 8px; align-items: center; }
.data-table-wrap .list-toolbar .filter-search { min-width: 240px; }
.data-table-wrap .list-toolbar .lt-info { font-size: 12px; color: var(--c-text-muted); }
.data-table .dt-th-sortable {
  cursor: pointer; user-select: none;
}
.data-table .dt-th-sortable:hover { background: var(--c-bg-deep); }
.data-table .dt-th-label { vertical-align: middle; margin-right: 4px; }
.data-table .dt-row-clickable { cursor: pointer; }
.data-table tbody tr.dt-skeleton-row { cursor: default; }
.data-table tbody tr.dt-skeleton-row:hover { background: transparent; }

/* ----- EntityDetail standard layout ----- */
.ent-shell {
  display: flex; flex-direction: column;
  gap: 16px;
}
.ent-profile { gap: 18px; }
.ent-hero-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg, 14px);
  padding: 0;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.ent-hero-card::before {
  content: '';
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--c-accent), var(--c-accent-strong));
}
.ent-hero-top {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px; padding: 14px 20px 0;
}
.ent-hero-identity { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ent-type-pill {
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  background: var(--c-accent-soft); color: var(--c-accent);
}
.ent-id-chip {
  font-size: 11px; font-family: ui-monospace, monospace;
  padding: 3px 8px; border-radius: 6px;
  background: var(--c-surface-2); color: var(--c-text-muted);
  border: 1px solid var(--c-border);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ent-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ent-hero-main {
  display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; padding: 12px 20px 16px;
}
.ent-hero-title { margin: 0; font-size: 22px; font-weight: 700; color: var(--c-text); line-height: 1.25; }
.ent-hero-sub { margin-top: 4px; font-size: 13px; color: var(--c-text-muted); font-weight: 500; }
.ent-hero-status { flex-shrink: 0; }
.ent-pipeline {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 0 20px 16px; border-bottom: 1px solid var(--c-border);
}
.ent-pipeline-step {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 14px; border-radius: 10px; min-width: 100px;
  border: 1px solid var(--c-border); background: var(--c-surface-2);
}
.ent-pipeline-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-muted); font-weight: 600; }
.ent-pipeline-value { font-size: 13px; font-weight: 600; }
.ent-pipeline-ok { border-color: #b8e6c8; background: #f0faf3; }
.ent-pipeline-warn { border-color: #f5dfa8; background: #fffbf0; }
.ent-pipeline-bad { border-color: #f0c4c4; background: #fff5f5; }
.ent-kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px; background: var(--c-border);
  border-top: 1px solid var(--c-border);
}
.ent-kpi-card {
  background: var(--c-surface); padding: 14px 18px; text-align: left;
}
.ent-kpi-clickable { cursor: pointer; transition: background var(--t-fast, .15s); }
.ent-kpi-clickable:hover { background: var(--c-accent-soft); }
.ent-kpi-value { font-size: 24px; font-weight: 700; color: var(--c-text); line-height: 1.1; }
.ent-kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted); margin-top: 4px; font-weight: 600; }
.ent-kpi-hint { margin-top: 2px; font-size: 11px; }
.ent-header { /* extends .entity-header */ }
.ent-grid {
  display: grid; gap: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 1100px) {
  .ent-grid { grid-template-columns: 300px 1fr; }
}
.ent-summary {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  align-self: start;
}
.ent-summary-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 8px;
}
.ent-summary-title {
  text-transform: uppercase; letter-spacing: .5px;
  font-size: 10.5px; font-weight: 700; color: var(--c-text-muted);
}
.ent-summary-edit { flex-shrink: 0; }
.ent-summary-kv .ent-kv-row { padding: 8px 0; border-bottom: 1px solid var(--c-border); }
.ent-summary-kv .ent-kv-row:last-child { border-bottom: none; }
.ent-content {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 0;
  min-height: 280px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.ent-tabs {
  display: flex; gap: 0; flex-wrap: nowrap;
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
  padding: 0 12px;
  background: var(--c-surface-2);
}
.ent-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 14px; cursor: pointer; font-size: 13px;
  color: var(--c-text-muted);
  border-bottom: 2px solid transparent;
  user-select: none; white-space: nowrap;
  margin-bottom: -1px;
}
.ent-tab:hover { color: var(--c-text); background: rgba(0,0,0,.02); }
.ent-tab.active {
  color: var(--c-accent); border-bottom-color: var(--c-accent); font-weight: 600;
  background: var(--c-surface);
}
.ent-tab-badge {
  font-size: 10px; font-weight: 700; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px;
  background: var(--c-accent-soft); color: var(--c-accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.ent-tab.active .ent-tab-badge { background: var(--c-accent); color: #fff; }
.ent-tab-panel { padding: 0; }
.ent-tab-body { padding: 18px 20px; }
.ent-main { display: block; }
.ent-foot {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 10px 16px; background: var(--c-surface-2);
  border-radius: var(--r-md); border: 1px solid var(--c-border);
  font-size: 12px; color: var(--c-text-muted);
}
.ent-foot-item::before { content: '·'; margin-right: 6px; color: var(--c-border-strong); }
.ent-foot-item:first-child::before { content: none; margin: 0; }
.ent-section-head { margin-bottom: 16px; }
.ent-section-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--c-text); }
.ent-form { max-width: 640px; }
.ent-form-grid {
  display: grid;
  gap: 0 20px;
  max-width: 720px;
}
@media (min-width: 900px) {
  .ent-form-grid { grid-template-columns: 1fr 1fr; }
  .ent-form-grid .form-row { grid-column: span 1; }
  .ent-form-grid .ent-form-actions { grid-column: 1 / -1; }
}
.ent-form-actions {
  display: flex; justify-content: flex-end; margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--c-border);
}
.client-detail-page .ent-shell,
.broker-detail-page .ent-shell { margin-top: 0; }
.ent-drawer { /* applied alongside .drawer-panel */ }
.ent-drawer .drawer-section + .drawer-section { margin-top: 14px; }
.ent-drawer .drawer-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--c-text-muted); margin-bottom: 6px;
}

/* ----- Modal wide ----- */
.modal.modal-wide { max-width: 720px; }

/* ============================================================
   DETAIL VIEW (web-app style) — used in position/commission
   detail modals and entity drill-downs.
   ============================================================ */
.dm { display: flex; flex-direction: column; gap: 18px; }
.dm-hero {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--c-accent) 0%, var(--c-accent-strong) 100%);
  color: #fff;
  box-shadow: var(--shadow-soft);
}
.dm-hero-icon {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.14); color: #fff;
}
.dm-hero-main { flex: 1; min-width: 0; }
.dm-eyebrow {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 700; color: rgba(255,255,255,.7); margin-bottom: 4px;
}
.dm-title { font-size: 20px; font-weight: 700; line-height: 1.2; word-break: break-word; }
.dm-subtitle { font-size: 13px; color: rgba(255,255,255,.82); margin-top: 3px; }
.dm-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.dm-badges .badge { background: rgba(255,255,255,.16); color: #fff; }

.dm-stats {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.dm-stat {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-border-strong);
  border-radius: var(--r-md);
  transition: box-shadow var(--t-fast, .15s);
}
.dm-stat:hover { box-shadow: var(--shadow-soft); }
.dm-stat-icon {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--c-bg-deep); color: var(--c-text-muted);
}
.dm-stat-body { min-width: 0; }
.dm-stat-value { font-size: 18px; font-weight: 700; color: var(--c-text); line-height: 1.15; word-break: break-word; }
.dm-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted); margin-top: 2px; font-weight: 600; }
.dm-stat-hint { margin-top: 2px; }
.dm-stat--accent  { border-left-color: var(--c-accent); }
.dm-stat--accent  .dm-stat-icon { background: var(--c-accent-soft); color: var(--c-accent); }
.dm-stat--success { border-left-color: var(--c-success); }
.dm-stat--success .dm-stat-icon { background: var(--c-success-soft); color: var(--c-success); }
.dm-stat--warn    { border-left-color: var(--c-warn); }
.dm-stat--warn    .dm-stat-icon { background: var(--c-warn-soft); color: var(--c-warn); }
.dm-stat--error   { border-left-color: var(--c-error); }
.dm-stat--error   .dm-stat-icon { background: var(--c-error-soft); color: var(--c-error); }
.dm-stat--info    { border-left-color: var(--c-info); }
.dm-stat--info    .dm-stat-icon { background: var(--c-info-soft); color: var(--c-info); }
.dm-stat--neutral { border-left-color: var(--c-border-strong); }

.dm-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.dm-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700; color: var(--c-text-muted); margin-bottom: 10px;
}
.dm-meta { display: grid; gap: 1px; }
.dm-meta-row {
  display: grid; grid-template-columns: 160px 1fr; gap: 12px;
  padding: 7px 0; border-bottom: 1px dashed var(--c-border); font-size: 13px;
}
.dm-meta-row:last-child { border-bottom: none; }
.dm-meta-k { color: var(--c-text-muted); font-size: 12px; }
.dm-meta-v { color: var(--c-text); word-break: break-word; }
.dm-note {
  font-size: 13px; line-height: 1.6; color: var(--c-text);
  white-space: pre-wrap; max-height: 220px; overflow: auto;
}
.dm-textarea {
  width: 100%; padding: 9px 10px; border-radius: var(--r-md);
  border: 1px solid var(--c-border); font-family: inherit; font-size: 13px;
  resize: vertical;
}
.dm-textarea:focus { outline: 2px solid var(--c-accent); outline-offset: 1px; border-color: var(--c-accent); }
.dm-stats + .dm-section, .dm-section + .dm-section { margin-top: 0; }
@media (max-width: 560px) {
  .dm-meta-row { grid-template-columns: 1fr; gap: 2px; }
}

/* Modal close button styling already present (.modal-close); ensure
   keyboard focus ring stays visible without overriding existing rules. */
.modal-close:focus-visible,
.drawer-close:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* ----- Sidebar focus state for collapsible group headers ----- */
.sidebar-group-header:focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: -2px;
}

/* ----- Crumbs link button look ----- */
.crumbs-link:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* ============================================================
   EMAIL 3-PANE LAYOUT (Batch 3)
   ============================================================ */
.email-3pane {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}
@media (min-width: 1100px) {
  .email-3pane {
    grid-template-columns: 320px minmax(0, 1fr) 360px;
    align-items: start;
  }
}
.email-pane {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  min-height: 480px;
}
.email-pane-left { padding: 12px; }
.email-pane-center { padding: 16px 18px; }
.email-pane-right { padding: 12px 14px; }

.email-left-header { margin-bottom: 8px; }
.email-thread-list {
  max-height: 70vh;
  overflow-y: auto;
  border-top: 1px solid var(--c-border);
}
.email-thread-row {
  padding: 10px 8px;
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  user-select: none;
}
.email-thread-row:hover { background: var(--c-bg-deep); }
.email-thread-row.active {
  background: var(--c-accent-soft);
  border-left: 3px solid var(--c-accent);
}
.email-thread-row .etr-subject {
  font-size: 13px; color: var(--c-text); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.email-thread-row .etr-meta {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 11px;
}
.email-thread-row .etr-status { margin-top: 4px; }

.email-thread-pane { display: flex; flex-direction: column; gap: 12px; }
.email-thread-head .eth-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.email-thread-head .eth-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.email-message-list { display: flex; flex-direction: column; gap: 10px; }
.email-message-card {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  background: var(--c-surface-2);
}
.email-message-card .emc-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 12px;
}
.email-message-card .emc-body {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-top: 6px;
  color: var(--c-text);
}

.email-composer label {
  display: block; margin-top: 6px; font-size: 11px;
}
.email-composer textarea {
  font-family: inherit;
}

/* ============================================================
   INTERNATIONALIZATION (i18n)
   - Language selectors (topbar + login)
   - RTL minimal support: applied when <html dir="rtl"> and
     body.rtl are toggled by setLocale().
   ============================================================ */
.lang-select {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  padding: 5px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  min-width: 110px;
  max-width: 160px;
}
.lang-select:hover { background: var(--c-bg-deep); }
.lang-select:focus-visible {
  outline: 2px solid var(--c-accent); outline-offset: 1px;
}
.topbar-lang {
  display: inline-flex; align-items: center;
}
.lang-select-topbar {
  height: 32px;
}
.login-lang {
  display: flex; justify-content: flex-end;
  margin-bottom: 6px;
}
.lang-select-login {
  height: 30px; min-width: 130px;
}

/* RTL: keep institutional look but flip flow + alignment + sidebar
   anchor. We avoid restyling component internals, only invert layout
   primitives so the same components render correctly mirrored. */
html[dir="rtl"] body,
body.rtl {
  text-align: right;
  direction: rtl;
}
html[dir="rtl"] .ent-shell,
body.rtl .ent-shell {
  flex-direction: row-reverse;
}
html[dir="rtl"] .topbar,
body.rtl .topbar,
html[dir="rtl"] .topbar-row,
body.rtl .topbar-row {
  flex-direction: row-reverse;
}
html[dir="rtl"] .topbar .actions,
body.rtl .topbar .actions {
  flex-direction: row-reverse;
}
html[dir="rtl"] .crumbs,
body.rtl .crumbs,
html[dir="rtl"] .crumb-bar,
body.rtl .crumb-bar {
  flex-direction: row-reverse;
}
html[dir="rtl"] .screen-app,
body.rtl .screen-app {
  grid-template-columns: 1fr var(--sidebar-w);
  grid-template-areas:
    "topbar sidebar"
    "workspace sidebar";
}
html[dir="rtl"] .sidebar,
body.rtl .sidebar {
  border-right: none;
  border-left: 1px solid var(--c-accent-strong);
}
html[dir="rtl"] .sidebar-link,
body.rtl .sidebar-link {
  border-left: none;
  border-right: 2px solid transparent;
  flex-direction: row-reverse;
  text-align: right;
}
html[dir="rtl"] .sidebar-link.active,
body.rtl .sidebar-link.active {
  border-right-color: var(--c-gold);
}
html[dir="rtl"] .ent-grid,
body.rtl .ent-grid {
  direction: rtl;
}
html[dir="rtl"] .modal-foot,
body.rtl .modal-foot,
html[dir="rtl"] .drawer-foot,
body.rtl .drawer-foot {
  flex-direction: row-reverse;
}
html[dir="rtl"] .page-header,
body.rtl .page-header {
  flex-direction: row-reverse;
}
html[dir="rtl"] .form-row label,
body.rtl .form-row label {
  text-align: right;
}
html[dir="rtl"] .toast,
body.rtl .toast {
  right: auto;
  left: 24px;
}
html[dir="rtl"] .drawer-panel,
body.rtl .drawer-panel {
  right: auto;
  left: 0;
}
html[dir="rtl"] .login-foot,
body.rtl .login-foot {
  flex-direction: row-reverse;
}
html[dir="rtl"] .pagination,
body.rtl .pagination {
  flex-direction: row-reverse;
}
html[dir="rtl"] .filters-bar,
body.rtl .filters-bar,
html[dir="rtl"] .filter-bar,
body.rtl .filter-bar {
  flex-direction: row-reverse;
}

/* Track 3 WS5: workspace quick-approval and mobile surfaces */
.approval-quick-list {
  margin-top: 8px;
}
.approval-quick-card {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-bg-soft);
  padding: 10px;
  margin-top: 8px;
  cursor: pointer;
}
.approval-quick-card:hover {
  border-color: var(--c-accent);
}
.approval-quick-card:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}
.approval-quick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.approval-quick-body {
  display: grid;
  gap: 2px;
}

@media (min-width: 980px) {
  .approval-quick-list {
    display: none;
  }
}

/* M1 — NovaShell, global search, notifications, institutional errors */
.workspace.is-loading {
  opacity: 0.55;
  pointer-events: none;
}
.institutional-error {
  border: 1px solid var(--c-error);
  background: var(--c-error-soft);
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin: 12px 0;
}
.institutional-error-title {
  font-weight: 600;
  margin-bottom: 6px;
}
.topbar-search {
  position: relative;
  min-width: 220px;
}
.global-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  max-height: 320px;
  overflow: auto;
}
.global-search-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 1px solid var(--c-border);
}
.global-search-item:hover,
.global-search-item.is-active {
  background: var(--c-accent-soft);
}
.global-search-type {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--c-text-muted);
}
.topbar-notif {
  position: relative;
}
.topbar-notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--c-gold);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}
.notification-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--c-border);
  background: transparent;
  cursor: pointer;
}
.notification-row.is-static {
  cursor: default;
}
.workspace-overview-panel {
  margin-bottom: 12px;
}
.workspace-overview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}
.input-error {
  border-color: var(--c-error) !important;
}

/* Phase 2 — institutional dashboard hero + command palette */
.institutional-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
  padding: 20px 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  background: linear-gradient(135deg, var(--c-surface) 0%, var(--c-accent-soft) 100%);
  box-shadow: var(--shadow-soft);
  border-left: 4px solid var(--c-gold);
}
.institutional-hero-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--c-accent);
}
.institutional-hero-sub {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 13px;
  max-width: 52ch;
}
.institutional-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.institutional-hero-chip {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
}
.institutional-hero-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
  justify-content: center;
}
.institutional-hero-stat {
  text-align: right;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
}
.institutional-hero-stat .n {
  font-size: 24px;
  font-weight: 700;
  color: var(--c-accent);
  line-height: 1.1;
}
.institutional-hero-stat .l {
  font-size: 11px;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.command-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 33, 60, 0.42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}
.command-palette-overlay.hidden { display: none; }
.command-palette-panel {
  width: min(640px, 100%);
  background: var(--c-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-pop);
  padding: 14px 16px 12px;
}
.command-palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--c-accent);
  font-family: var(--font-display);
}
.command-kbd {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--c-border);
  background: var(--c-bg);
  color: var(--c-text-muted);
}
.command-palette-search .topbar-search { min-width: 100%; }
.command-palette-search .global-search-dropdown { position: static; margin-top: 6px; max-height: 220px; }
.command-palette-section-title {
  margin: 12px 0 8px;
  font-size: 10.5px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--c-text-soft);
  font-weight: 600;
}
.command-palette-quick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
}
.command-palette-quick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  color: var(--c-text);
}
.command-palette-quick-item:hover {
  border-color: var(--c-gold);
  background: var(--c-gold-soft);
}
.command-palette-quick-sub {
  padding-left: 28px;
  font-size: 13px;
  color: var(--c-text-muted);
}
.command-palette-sub-prefix {
  opacity: 0.6;
  margin-right: 6px;
}
.command-palette-foot {
  margin-top: 10px;
  font-size: 11px;
  color: var(--c-text-soft);
}
.topbar-search-input::placeholder { color: var(--c-text-soft); }
.command-palette-trigger .command-kbd {
  font-size: 10px;
  padding: 2px 5px;
}

@media (max-width: 860px) {
  .institutional-hero {
    grid-template-columns: 1fr;
  }
  .institutional-hero-stat { text-align: left; }
}

/* ==========================================================================
   PHASE 10 — VISUAL REFRESH (global, all three portals)
   Appended last so it refines the design system via the cascade without
   rewriting earlier rules. Modernises tokens, adds per-portal identity,
   and polishes every key surface (sidebar, topbar, cards, tables, forms).
   ========================================================================== */
:root {
  /* Cooler, higher-contrast neutral ramp */
  --c-bg: #f3f5f9;
  --c-bg-deep: #e7ebf2;
  --c-surface: #ffffff;
  --c-surface-2: #f7f9fc;
  --c-border: #dde3ec;
  --c-border-strong: #c3ccd9;
  --c-text: #15212e;
  --c-text-muted: #56657a;
  --c-text-soft: #8997a8;

  /* Richer institutional navy + warmer gold */
  --c-accent: #102e52;
  --c-accent-strong: #0a2240;
  --c-accent-soft: #e7eef6;
  --c-gold: #b58a37;
  --c-gold-soft: #f5edda;

  /* Portal identity accent (defaults to internal navy) */
  --c-portal: #102e52;
  --c-portal-2: #1c4a82;
  --c-portal-soft: #e7eef6;
  --c-portal-contrast: #ffffff;

  /* Modern radii + layered shadows */
  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 14px;
  --r-xl: 20px;
  --shadow-soft: 0 1px 2px rgba(16, 30, 55, 0.04), 0 2px 6px rgba(16, 30, 55, 0.05);
  --shadow-pop: 0 12px 34px rgba(16, 30, 55, 0.14), 0 4px 12px rgba(16, 30, 55, 0.08);
  --shadow-ring: 0 0 0 3px var(--c-portal-soft);
  --t-fast: .14s cubic-bezier(.4,0,.2,1);
}

/* ---- Per-portal identity accents ---- */
body.portal-internal { --c-portal: #102e52; --c-portal-2: #1c4a82; --c-portal-soft: #e7eef6; }
body.portal-client   { --c-portal: #1f7a52; --c-portal-2: #2ea36c; --c-portal-soft: #e6f3ec; }
body.portal-broker   { --c-portal: #a9772a; --c-portal-2: #cf9a3e; --c-portal-soft: #f6edda; }

body {
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(28,74,130,0.05), transparent 60%),
    var(--c-bg);
}

/* ---- Custom scrollbars (subtle, coherent) ---- */
* { scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--c-text-soft); background-clip: content-box; }

/* ---- Sidebar: gradient + pill active state + portal accent ---- */
.sidebar {
  background: linear-gradient(185deg, var(--c-accent) 0%, var(--c-accent-strong) 100%);
  border-right: none;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.04);
  padding-bottom: 8px;
}
body.portal-client .sidebar { background: linear-gradient(185deg, #0c3a28 0%, #06241a 100%); }
body.portal-broker .sidebar { background: linear-gradient(185deg, #3a2c12 0%, #241a09 100%); }

.sidebar-brand { padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand .mark { background: var(--c-portal-2); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.25); }

.sidebar-link, .sidebar-hub-link {
  margin: 2px 10px; padding: 9px 12px; border-radius: 10px;
  border-left: none !important; transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.sidebar-link:hover, .sidebar-hub-link:hover { background: rgba(255,255,255,0.07); transform: translateX(1px); }
.sidebar-link.active, .sidebar-hub-link.active {
  background: linear-gradient(90deg, var(--c-portal-2), rgba(255,255,255,0.04));
  color: #fff; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}
.sidebar-link.active::before, .sidebar-hub-link.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--c-gold);
}
.sidebar-link, .sidebar-hub-link { position: relative; }

/* ---- Topbar: crisp, with portal accent underline ---- */
.topbar, .topbar-stack {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: 0 1px 0 rgba(16,30,55,0.03), 0 4px 16px rgba(16,30,55,0.04);
}
.topbar .user .avatar, .topbar-row .user .avatar {
  background: linear-gradient(140deg, var(--c-portal), var(--c-portal-2));
  box-shadow: 0 2px 8px rgba(16,30,55,0.18);
}
.badge-env {
  background: var(--c-portal-soft) !important; color: var(--c-portal) !important;
}

/* ---- Buttons: refined states + focus ring ---- */
.btn {
  border-radius: 9px; font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:hover { box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-ring); }
.btn-primary {
  background: linear-gradient(140deg, var(--c-accent), var(--c-accent-strong));
  border-color: var(--c-accent-strong);
}
.btn-primary:hover { background: linear-gradient(140deg, var(--c-accent-strong), var(--c-accent-strong)); box-shadow: var(--shadow-pop); }

/* ---- Cards & panels: rounded, hover lift ---- */
.card, .panel {
  border-radius: var(--r-lg);
  border-color: var(--c-border);
}
.card { transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast); }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.card.is-clickable, .card[role="button"] { cursor: pointer; }
.card-value { letter-spacing: -0.02em; }
.panel-header { background: linear-gradient(180deg, var(--c-surface-2), var(--c-surface)); }

/* ---- Tables: cleaner header, accent row hover ---- */
.table th { background: var(--c-surface-2); border-bottom: 1px solid var(--c-border-strong); }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--c-portal-soft); }
.data-table-row:hover { background: var(--c-portal-soft) !important; }

/* ---- Tabs / subnav: portal accent ---- */
.tab.active, .entity-tab.active, .subnav-tab.active {
  color: var(--c-portal); border-bottom-color: var(--c-portal);
}
.section-tab.active { background: var(--c-portal); border-color: var(--c-portal); }

/* ---- Forms: portal focus ring ---- */
.form-row input:focus, .form-row select:focus, .form-row textarea:focus,
.filters-bar .filter-input:focus, .filters-bar .filter-select:focus,
.login-card input:focus {
  outline: none !important;
  border-color: var(--c-portal) !important;
  box-shadow: var(--shadow-ring);
}

/* ---- Badges: softer, refined ---- */
.badge { border-radius: 999px; padding: 3px 9px; }

/* ---- Login: richer backdrop, animated accent, lift ---- */
.screen-login {
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(181,138,55,0.16), transparent 55%),
    linear-gradient(135deg, var(--c-accent) 0%, var(--c-accent-strong) 100%);
}
body.portal-client .screen-login { background: radial-gradient(900px 500px at 15% 10%, rgba(46,163,108,0.18), transparent 55%), linear-gradient(135deg, #0c3a28, #06241a); }
body.portal-broker .screen-login { background: radial-gradient(900px 500px at 15% 10%, rgba(207,154,62,0.22), transparent 55%), linear-gradient(135deg, #3a2c12, #241a09); }
.login-card { border-radius: var(--r-xl); box-shadow: var(--shadow-pop); border: 1px solid rgba(255,255,255,0.5); }
.login-card-accent { background: linear-gradient(90deg, var(--c-gold), #e3c884, var(--c-gold)); background-size: 200% 100%; animation: nova-shimmer 6s linear infinite; }
@keyframes nova-shimmer { 0% { background-position: 0% 0; } 100% { background-position: 200% 0; } }
.login-card button { border-radius: 10px; background: linear-gradient(140deg, var(--c-accent), var(--c-accent-strong)); transition: box-shadow var(--t-fast), transform var(--t-fast); }
.login-card button:hover { box-shadow: var(--shadow-pop); }
.login-card button:active { transform: translateY(1px); }

/* ---- Modals & drawers: rounder, deeper ---- */
.modal { border-radius: var(--r-lg); }
.drawer-panel { box-shadow: var(--shadow-pop); }

/* ---- Page titles ---- */
.page-title { letter-spacing: -0.025em; }

/* ---- Toast refinement ---- */
.toast { border-radius: 12px; box-shadow: var(--shadow-pop); }

/* ---- Subtle fade-in for workspace content ---- */
.workspace > * { animation: nova-fade-in .22s ease both; }
@keyframes nova-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .workspace > *, .login-card-accent { animation: none; }
  .card:hover { transform: none; }
}

/* ---- Dashboard hero: per-portal gradient + accent ---- */
.institutional-hero {
  background: linear-gradient(135deg, var(--c-surface) 0%, var(--c-portal-soft) 100%);
  border-left: 4px solid var(--c-portal);
  border-radius: var(--r-lg);
}
.institutional-hero-title { color: var(--c-portal); }
.institutional-hero-stat .n { color: var(--c-portal); }
.institutional-hero-chip { background: var(--c-surface); border-color: var(--c-border); }

/* ---- Command palette quick items: portal accent on hover ---- */
.command-palette-quick-item:hover { border-color: var(--c-portal); background: var(--c-portal-soft); }

/* ---- Hub sub-navigation pills (icon menu) coherence ---- */
.sidebar-hub-link .ico { color: inherit; }

/* ---- Links use portal accent ---- */
a { color: var(--c-portal); }
.crumbs-link:hover { color: var(--c-portal); }

/* ---- Dedicated form pages (drawer replacement) ---- */
.form-page { max-width: 960px; }
.form-page-foot .panel-body { padding: 14px 18px; }
