/* ==========================================================================
   03. SOURCE: navigation-v2.css
   ========================================================================== */
/* TDH Visual System Upgrade, Phase 2
   Global navigation, application bar, profile/meta area, responsive drawer,
   manual theme selection and consistent page context. */

:root { --tdh-rail-width: 252px; --tdh-rail-mini-width: 76px; --tdh-appbar-height: 58px; }

/* Manual theme overrides. Auto remains the default. */
html[data-theme="light"] {
  color-scheme: light;
  --tdh-bg:#f5f3f7;--tdh-surface:#fff;--tdh-surface-subtle:#faf9fb;--tdh-surface-muted:#f2eff4;--tdh-surface-raised:#fff;
  --tdh-line:#e3dde6;--tdh-line-strong:#cec4d2;--tdh-text:#2d2331;--tdh-text-secondary:#665b6b;--tdh-text-muted:#817686;--tdh-text-faint:#9e94a2;
  --tdh-accent:#8b1ca4;--tdh-accent-hover:#721389;--tdh-accent-soft:#f1e3f4;--tdh-accent-contrast:#fff;
  --tdh-success-bg:#edf8f2;--tdh-warning-bg:#fff7e8;--tdh-danger-bg:#fff0f3;--tdh-info-bg:#eff5fc;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --tdh-bg:#121016;--tdh-surface:#1b171f;--tdh-surface-subtle:#211c25;--tdh-surface-muted:#2a232f;--tdh-surface-raised:#211b25;
  --tdh-line:#3a303f;--tdh-line-strong:#514357;--tdh-text:#f2edf4;--tdh-text-secondary:#c9becd;--tdh-text-muted:#a99daf;--tdh-text-faint:#867a8b;
  --tdh-accent:#c956de;--tdh-accent-hover:#d974e8;--tdh-accent-soft:#3a2340;--tdh-accent-contrast:#fff;
  --tdh-success-bg:#18372d;--tdh-warning-bg:#3b2c16;--tdh-danger-bg:#42202a;--tdh-info-bg:#1d2e43;
}
html[data-theme="light"] body, html[data-theme="dark"] body { background:var(--tdh-bg)!important;color:var(--tdh-text)!important; }
html[data-theme="dark"] .page,html[data-theme="dark"] .main{color:var(--tdh-text)}
html[data-theme="dark"] .panel,html[data-theme="dark"] .card,html[data-theme="dark"] .shortcut,html[data-theme="dark"] .worklist-card,
html[data-theme="dark"] .task,html[data-theme="dark"] .backlogrow,html[data-theme="dark"] .planning-backlog,html[data-theme="dark"] .plan-week,
html[data-theme="dark"] .adm-card,html[data-theme="dark"] .adm-mapping,html[data-theme="dark"] .dbt-table-frame{background:var(--tdh-surface)!important;color:var(--tdh-text)!important}

/* Canonical application rail */
.top {
  width:var(--tdh-rail-width)!important;
  padding:16px 12px 12px!important;
  background:linear-gradient(180deg,#25042f 0%,#3c0750 48%,#210329 100%)!important;
  border-right:1px solid rgba(255,255,255,.08)!important;
  box-shadow:8px 0 30px rgba(30,3,38,.08)!important;
}
.topin { gap:0!important; min-height:0!important; }
.hub-logo { min-height:58px; padding:5px 7px!important; margin-bottom:10px; }
.hub-logo img { width:44px!important;height:44px!important;border-radius:12px!important; }
.hub-logo small { font-size:8px!important;letter-spacing:.17em!important; }
.hub-logo strong { font-size:15px!important;line-height:1.1; }
.hub-logo em { margin-top:2px;color:#cdb8d2!important;font-size:8px!important; }
.rail-toggle { top:76px!important;right:-15px!important;width:31px!important;height:31px!important;border:1px solid #e2d8e5!important;background:#fff!important;box-shadow:0 7px 20px rgba(45,7,54,.22)!important; }

.nav {
  display:block!important;
  flex:1 1 auto!important;
  min-height:0!important;
  padding:0 3px 8px!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  border:0!important;
  border-radius:0!important;
  background:transparent!important;
}
.tdh-nav-group { display:grid;gap:3px;margin:0 0 13px; }
.tdh-nav-group-label { display:block;padding:0 10px 5px;color:#a98faf;font-size:8px;font-weight:900;letter-spacing:.13em;text-transform:uppercase; }
.nav button {
  position:relative;
  width:100%;min-height:40px!important;padding:7px 9px!important;
  border:1px solid transparent!important;border-radius:10px!important;
  color:#dfd0e3!important;background:transparent!important;
  font-size:11px!important;font-weight:720!important;
  transition:background var(--tdh-transition),color var(--tdh-transition),border-color var(--tdh-transition),transform var(--tdh-transition)!important;
}
.nav button:hover { background:rgba(255,255,255,.08)!important;color:#fff!important;transform:translateX(1px); }
.nav button.active { border-color:rgba(255,255,255,.16)!important;background:linear-gradient(135deg,#8c20c8,#ad27de)!important;color:#fff!important;box-shadow:0 7px 18px rgba(103,10,139,.28)!important; }
.nav-icon { width:27px!important;height:27px!important;flex:0 0 27px!important;border-radius:8px!important;background:rgba(255,255,255,.08)!important;color:#e9ddef!important;font-size:14px!important; }
.nav button.active .nav-icon { background:rgba(255,255,255,.18)!important;color:#fff!important; }
.nav-label { overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }

/* Canonical bottom system area */
.v30-system-stack {
  order:8!important;display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;gap:7px!important;
  width:100%!important;margin:8px 0 0!important;padding:9px 3px 0!important;border-top:1px solid rgba(255,255,255,.1)!important;
}
#v30LogButton { grid-column:1/-1!important;min-height:38px!important;border:1px solid rgba(255,255,255,.13)!important;background:rgba(255,255,255,.055)!important;color:#e6d8ea!important;border-radius:10px!important; }
#v30LogButton:hover { background:rgba(255,255,255,.1)!important;color:#fff!important; }
.v30-meta { display:grid!important;grid-template-columns:auto minmax(0,1fr)!important;gap:7px!important;min-width:0; }
#v30VersionSlot { display:flex;align-items:center; }
.version-badge { display:grid!important;place-items:center!important;min-width:55px!important;height:38px!important;margin:0!important;padding:0 9px!important;border:1px solid rgba(255,255,255,.13)!important;border-radius:10px!important;background:rgba(255,255,255,.055)!important;color:#eadff0!important;font-size:9px!important; }
#v30RoleButton { min-width:0!important;min-height:38px!important;padding:4px 7px!important;border:1px solid rgba(255,255,255,.13)!important;border-radius:10px!important;background:rgba(255,255,255,.055)!important;color:#fff!important; }
.tdh-profile-icon { display:grid!important;place-items:center!important;width:27px!important;height:27px!important;border-radius:8px!important;background:#a828dc!important;color:#fff!important;font-size:8px!important;font-weight:900!important; }
.v30-role-copy { min-width:0;text-align:left; }
.v30-role-copy b,.v30-role-copy small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.v30-role-copy b{font-size:9px}.v30-role-copy small{margin-top:1px;color:#baa8c0;font-size:7px}
.connected { display:none!important; }

/* App bar and common page context */
.tdh-appbar {
  position:fixed;z-index:24;top:0;left:var(--tdh-rail-width);right:0;height:var(--tdh-appbar-height);
  display:flex;align-items:center;justify-content:space-between;gap:16px;padding:0 28px;
  border-bottom:1px solid var(--tdh-line);background:color-mix(in srgb,var(--tdh-surface) 90%,transparent);backdrop-filter:blur(15px) saturate(1.15);
  transition:left .25s ease;
}
.tdh-appbar-left,.tdh-appbar-actions{display:flex;align-items:center;gap:9px}.tdh-mobile-menu{display:none;width:38px;height:38px;padding:0!important}.tdh-context{display:flex;align-items:center;gap:9px;min-width:0}.tdh-context-icon{display:grid;place-items:center;width:32px;height:32px;border-radius:10px;background:var(--tdh-accent-soft);color:var(--tdh-accent);font-size:15px;font-weight:900}.tdh-context-copy{min-width:0}.tdh-context-copy small,.tdh-context-copy b{display:block}.tdh-context-copy small{color:var(--tdh-text-muted);font-size:8px;font-weight:900;letter-spacing:.08em;text-transform:uppercase}.tdh-context-copy b{overflow:hidden;color:var(--tdh-text);font-size:12px;text-overflow:ellipsis;white-space:nowrap}.tdh-appbar-separator{width:1px;height:24px;background:var(--tdh-line)}
.tdh-theme-control{display:flex;align-items:center;padding:3px;border:1px solid var(--tdh-line);border-radius:10px;background:var(--tdh-surface-subtle)}.tdh-theme-control button{display:grid;place-items:center;width:31px;height:31px;padding:0;border:0;border-radius:7px;background:transparent;color:var(--tdh-text-muted);font-size:13px;cursor:pointer}.tdh-theme-control button:hover{color:var(--tdh-text);background:var(--tdh-surface-muted)}.tdh-theme-control button.active{background:var(--tdh-surface);color:var(--tdh-accent);box-shadow:var(--tdh-shadow-xs)}
.tdh-app-profile{display:flex;align-items:center;gap:7px;max-width:190px;height:38px;padding:4px 8px;border:1px solid var(--tdh-line);border-radius:10px;background:var(--tdh-surface);color:var(--tdh-text);cursor:pointer}.tdh-app-profile>span:first-child{display:grid;place-items:center;width:27px;height:27px;border-radius:8px;background:var(--tdh-accent);color:#fff;font-size:8px;font-weight:900}.tdh-app-profile>span:last-child{min-width:0;overflow:hidden;font-size:9px;font-weight:800;text-overflow:ellipsis;white-space:nowrap}
.page { padding-top:var(--tdh-appbar-height)!important;margin-left:var(--tdh-rail-width)!important; }

/* Collapsed rail */
html.rail-collapsed .top{width:var(--tdh-rail-mini-width)!important}
html.rail-collapsed .page{margin-left:var(--tdh-rail-mini-width)!important}
html.rail-collapsed .tdh-appbar{left:var(--tdh-rail-mini-width)!important}
html.rail-collapsed .tdh-nav-group-label{display:none!important}
html.rail-collapsed .tdh-nav-group{gap:4px;margin-bottom:10px}
html.rail-collapsed .nav button{justify-content:center!important}
html.rail-collapsed .v30-system-stack{grid-template-columns:1fr!important}
html.rail-collapsed #v30LogButton{grid-column:auto!important;width:42px!important;justify-self:center!important}
html.rail-collapsed #v30LogButton>span:not(.nav-icon){display:none!important}
html.rail-collapsed .v30-meta{grid-template-columns:1fr!important}
html.rail-collapsed #v30VersionSlot{justify-content:center}
html.rail-collapsed .version-badge{display:none!important}
html.rail-collapsed #v30RoleButton{width:42px!important;justify-self:center!important;padding:5px!important}

/* Responsive drawer */
.tdh-nav-scrim{position:fixed;z-index:28;inset:0;display:none;border:0;background:rgba(25,6,31,.55);backdrop-filter:blur(4px)}
@media(max-width:900px){
  :root{--tdh-appbar-height:56px}
  .top{position:fixed!important;z-index:31!important;inset:0 auto 0 0!important;width:min(292px,86vw)!important;min-height:100vh!important;padding:14px 12px!important;transform:translateX(-105%);transition:transform .22s ease!important}
  html.tdh-mobile-nav-open .top{transform:translateX(0)}
  html.tdh-mobile-nav-open .tdh-nav-scrim{display:block}
  .topin{height:100%!important}.nav{display:block!important;max-height:none!important;overflow-y:auto!important;overflow-x:hidden!important}
  .tdh-appbar{left:0!important;padding:0 15px}.tdh-mobile-menu{display:grid!important;place-items:center!important}.tdh-appbar-separator{display:none}.tdh-app-profile{max-width:43px}.tdh-app-profile>span:last-child{display:none}
  .page,html.rail-collapsed .page{margin-left:0!important}.rail-toggle{display:none!important}
  .v30-system-stack{display:grid!important}.tdh-nav-group-label{display:block!important}.nav button{justify-content:flex-start!important}
}
@media(max-width:560px){.tdh-appbar{padding:0 10px}.tdh-context-copy small{display:none}.tdh-context-copy b{max-width:140px}.tdh-theme-control button{width:29px}.tdh-appbar-actions{gap:6px}}
.tdh-nav-group[hidden]{display:none!important}

/* TDH v53.1 navigation refinement */
.tdh-appbar-product{display:inline-flex;align-items:center;min-height:30px;padding:0 9px;border:1px solid var(--tdh-line);border-radius:999px;background:var(--tdh-surface-subtle);color:var(--tdh-text-muted);font-size:8px;font-weight:850;letter-spacing:.04em}
.tdh-nav-group{display:grid!important;grid-template-rows:auto 1fr;gap:3px!important;overflow:hidden;transition:grid-template-rows .18s ease,margin .18s ease}
.tdh-nav-group-toggle{display:flex!important;align-items:center!important;justify-content:space-between!important;width:100%!important;min-height:28px!important;padding:2px 9px!important;border:0!important;border-radius:7px!important;background:transparent!important;color:#bca8c2!important;box-shadow:none!important;font-size:8px!important;font-weight:900!important;letter-spacing:.12em!important;text-transform:uppercase!important;cursor:pointer!important}
.tdh-nav-group-toggle:hover{background:rgba(255,255,255,.055)!important;color:#fff!important;transform:none!important}
.tdh-nav-group-toggle i{font-size:12px;font-style:normal;transition:transform .18s ease}
.tdh-nav-group.collapsed{grid-template-rows:auto 0fr;margin-bottom:7px!important}
.tdh-nav-group.collapsed>button[data-page]{display:none!important}
.tdh-nav-group.collapsed .tdh-nav-group-toggle i{transform:rotate(-90deg)}
.tdh-sidebar-appearance{order:7;width:100%;margin-top:auto;padding:9px 3px 0;border-top:1px solid rgba(255,255,255,.1)}
.tdh-sidebar-appearance-label{display:block;margin:0 7px 6px;color:#aa94b0;font-size:7px;font-weight:900;letter-spacing:.13em;text-transform:uppercase}
.tdh-sidebar-appearance .tdh-theme-control{display:grid;grid-template-columns:repeat(3,1fr);gap:3px;padding:3px;border:1px solid rgba(255,255,255,.12);border-radius:10px;background:rgba(255,255,255,.05)}
.tdh-sidebar-appearance .tdh-theme-control button{display:grid;grid-template-rows:17px auto;place-items:center;width:auto;height:43px;padding:3px 2px;border:0;border-radius:7px;background:transparent;color:#bfaec4;cursor:pointer}
.tdh-sidebar-appearance .tdh-theme-control button span{font-size:12px;line-height:1}
.tdh-sidebar-appearance .tdh-theme-control button em{font-size:7px;font-style:normal;font-weight:750}
.tdh-sidebar-appearance .tdh-theme-control button:hover{background:rgba(255,255,255,.08);color:#fff}
.tdh-sidebar-appearance .tdh-theme-control button.active{background:#fff;color:#741587;box-shadow:0 4px 12px rgba(18,1,23,.2)}
.rail-toggle{top:78px!important;right:10px!important;display:grid!important;place-items:center!important;width:30px!important;height:30px!important;padding:0!important;border:1px solid rgba(255,255,255,.14)!important;border-radius:9px!important;background:rgba(255,255,255,.09)!important;color:#fff!important;box-shadow:none!important;font-size:0!important;transition:background .15s ease,transform .2s ease!important}
.rail-toggle:hover{background:rgba(255,255,255,.17)!important}
.rail-toggle span{display:block;font-size:22px;line-height:1;transform:translateY(-1px)}
html.rail-collapsed .rail-toggle{right:22px!important;transform:rotate(180deg)!important}
html.rail-collapsed .tdh-nav-group-toggle{display:none!important}
html.rail-collapsed .tdh-nav-group.collapsed>button[data-page]{display:flex!important}
html.rail-collapsed .tdh-sidebar-appearance-label,html.rail-collapsed .tdh-sidebar-appearance .tdh-theme-control button em{display:none!important}
html.rail-collapsed .tdh-sidebar-appearance{padding-inline:0}
html.rail-collapsed .tdh-sidebar-appearance .tdh-theme-control{grid-template-columns:1fr;width:42px;margin:auto}
html.rail-collapsed .tdh-sidebar-appearance .tdh-theme-control button{height:31px;grid-template-rows:1fr}
html.rail-collapsed .tdh-sidebar-appearance .tdh-theme-control button:not(.active){display:none}
@media(max-width:900px){.tdh-nav-group-toggle{display:flex!important}.tdh-sidebar-appearance{margin-top:8px}.rail-toggle{display:none!important}.tdh-appbar-product{display:none}}

/* TDH v53.2 - structurally correct collapsible navigation and bottom controls */
.tdh-nav-group{display:block!important;overflow:visible!important;margin:0 0 10px!important}
.tdh-nav-group-items{display:grid;gap:3px;min-height:0;overflow:hidden}
.tdh-nav-group-items[hidden]{display:none!important}
.tdh-nav-group.collapsed .tdh-nav-group-items{display:none!important}
.tdh-nav-group-toggle{margin-bottom:3px!important}
.topin{display:flex!important;flex-direction:column!important;height:100%!important;min-height:0!important}
.nav{flex:1 1 auto!important;min-height:120px!important;margin-bottom:7px!important}
.tdh-sidebar-appearance{order:6!important;flex:0 0 auto!important;margin-top:0!important}
.v30-system-stack{order:7!important;flex:0 0 auto!important;margin-top:6px!important}
#v30LogButton{grid-column:1!important;min-width:0!important;overflow:hidden!important}
#v30LogButton>span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.v30-meta{grid-column:2!important;display:flex!important;gap:6px!important;min-width:0!important}
#v30VersionSlot{flex:0 0 auto!important}.version-badge{min-width:51px!important;width:auto!important}
#v30RoleButton{flex:1 1 auto!important;min-width:0!important;max-width:100%!important}
html.rail-collapsed .tdh-nav-group-items{display:grid!important}
html.rail-collapsed .tdh-nav-group{margin-bottom:6px!important}
html.rail-collapsed .v30-system-stack{grid-template-columns:1fr!important}
html.rail-collapsed .v30-meta{grid-column:1!important;display:grid!important;grid-template-columns:1fr!important}
html.rail-collapsed #v30VersionSlot{display:none!important}
@media(max-width:900px){.tdh-nav-group-items[hidden]{display:none!important}.tdh-nav-group.collapsed .tdh-nav-group-items{display:none!important}.topin{height:100%!important}}
