/* ============================================================
   KB VIEWER — Material Design 3 Professional UI v2.0
   cPanel × Windows Explorer × GitHub × Confluence aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons+Round');

/* ── Design Tokens ── */
:root {
  /* Arobit Brand — Navy Blue + Orange */
  --pri:          #1a3a6e;
  --pri-dark:     #0f2548;
  --pri-light:    #2952a3;
  --pri-tint:     #e8eef8;
  --accent:       #f97316;
  --accent-dark:  #ea6c09;
  --accent-tint:  #fff4ed;

  /* Surfaces */
  --bg:           #f5f7fa;
  --surface:      #ffffff;
  --surface-2:    #f9fafb;
  --surface-3:    #f3f4f6;
  --surface-4:    #eaecf0;

  /* Text */
  --text-1:       #0f1c35;
  --text-2:       #1e3054;
  --text-3:       #5a6e8c;
  --text-4:       #8fa0b8;
  --text-inv:     #ffffff;

  /* Borders */
  --border:       #dde3ef;
  --border-2:     #c8d1e5;

  /* Sidebar — dark navy */
  --sb-bg:        #0a1628;
  --sb-bg2:       #0f1e38;
  --sb-hover:     #152540;
  --sb-active:    #f97316;
  --sb-active-bg: rgba(249,115,22,.15);
  --sb-text:      #7a90b0;
  --sb-text-hi:   #d4dff0;
  --sb-head:      #3d5278;
  --sb-border:    #111f38;
  --sb-w:         248px;

  /* Toolbar — dark navy */
  --tb-h:         52px;
  --tb-bg:        #0f2040;
  --tb-border:    #1a3060;

  /* Status */
  --green:  #16a34a; --green-bg:  #dcfce7;
  --yellow: #d97706; --yellow-bg: #fef3c7;
  --red:    #dc2626; --red-bg:    #fee2e2;
  --blue:   #1d4ed8; --blue-bg:   #dbeafe;
  --purple: #7c3aed; --purple-bg: #ede9fe;
  --teal:   #0f766e; --teal-bg:   #ccfbf1;

  /* Radius */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-2xl: 20px; --r-pill: 999px;

  /* Shadow */
  --sh-1: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.08);
  --sh-2: 0 2px 6px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
  --sh-3: 0 4px 16px rgba(0,0,0,.1),  0 2px 6px rgba(0,0,0,.06);
  --sh-4: 0 8px 32px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
  --sh-modal: 0 20px 60px rgba(0,0,0,.2);

  /* Type */
  --font:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --fs:        13.5px;

  /* Motion */
  --ease: cubic-bezier(.4,0,.2,1);
  --t:    .15s;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overflow: hidden; font-size: var(--fs); -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--text-1); height: 100%; overflow: hidden; margin: 0; padding: 0; line-height: 1.5; }
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, textarea, select { font-family: var(--font); }
::selection { background: var(--pri-tint); color: var(--pri-dark); }

/* =====================================================
   APP SHELL — 3-zone grid
   ===================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  grid-template-rows: var(--tb-h) 1fr;
  height: 100vh;
  overflow: hidden;
}
.app-shell.collapsed { grid-template-columns: 48px 1fr; }
.app-shell.no-sidebar { grid-template-columns: 1fr; }
.app-shell.no-sidebar .main-content { grid-column: 1; }
.app-shell.no-sidebar .toolbar-brand { width: auto; min-width: 0; padding: 0 16px; border-right: none; background: transparent; }
.app-shell.no-sidebar .toolbar-collapse { display: none; }

/* =====================================================
   TOP TOOLBAR
   ===================================================== */
.top-toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 12px 0 0;
  background: var(--tb-bg);
  border-bottom: 1px solid var(--tb-border);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  z-index: 300;
  height: var(--tb-h);
  gap: 6px;
}

/* All toolbar children inherit light text on dark navy */
.top-toolbar .brand-name { color: #ffffff; }
.top-toolbar .brand-version { color: rgba(255,255,255,.5); }
.top-toolbar .tb-btn { color: rgba(255,255,255,.7); }
.top-toolbar .tb-btn:hover { background: rgba(255,255,255,.1); color: #ffffff; }
.top-toolbar .tb-theme-btn { color: rgba(255,255,255,.7); }
.top-toolbar .tb-theme-btn:hover { background: rgba(255,255,255,.1); color: #ffffff; }
.top-toolbar .tb-divider { background: rgba(255,255,255,.15); }
.top-toolbar .toolbar-search { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.15); color: #ffffff; }
.top-toolbar .toolbar-search::placeholder { color: rgba(255,255,255,.45); }
.top-toolbar .toolbar-search-ico { color: rgba(255,255,255,.5); }
.top-toolbar .toolbar-search:focus { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.35); }
.top-toolbar .tb-nav-btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.15); color: rgba(255,255,255,.85); }
.top-toolbar .tb-nav-btn:hover { background: rgba(249,115,22,.25); border-color: var(--accent); color: #ffffff; }
.top-toolbar .user-chip { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.15); color: #ffffff; }
.top-toolbar .user-chip:hover { background: rgba(255,255,255,.18); }
.top-toolbar .u-avatar { background: var(--accent); color: #fff; }
.top-toolbar .u-caret { color: rgba(255,255,255,.5); }
.top-toolbar .brand-icon { background: var(--accent); }

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 0;
  width: var(--sb-w);
  height: 100%;
  padding: 0 14px;
  background: transparent;
  border-right: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
  text-decoration: none;
}
.toolbar-brand:hover { text-decoration: none; }
.brand-icon {
  width: 30px; height: 30px;
  background: var(--pri);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px; flex-shrink: 0; margin-right: 10px;
  box-shadow: 0 2px 8px rgba(26,115,232,.4);
}
.brand-name {
  font-size: 15px; font-weight: 700;
  color: var(--text-inv); letter-spacing: -.3px;
}
.brand-version {
  font-size: 10px; color: var(--sb-text); margin-left: 6px;
  background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: var(--r-xs);
}

.toolbar-collapse {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); transition: background var(--t) var(--ease);
  flex-shrink: 0; margin-left: 4px;
}
.toolbar-collapse:hover { background: var(--surface-3); color: var(--text-1); }
.toolbar-collapse .material-icons-round { font-size: 20px; }

/* Search */
.toolbar-search-wrap {
  flex: 1; max-width: 520px; margin: 0 8px; position: relative;
}
.toolbar-search {
  width: 100%; height: 34px;
  background: var(--surface-3);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 0 36px 0 36px;
  font-size: 13px; color: var(--text-1); outline: none;
  transition: all var(--t) var(--ease);
}
.toolbar-search:focus {
  background: var(--surface);
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}
.toolbar-search::placeholder { color: var(--text-4); }
.toolbar-search-ico {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-4); font-size: 18px; pointer-events: none;
}
.search-results-drop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-4);
  max-height: 420px; overflow-y: auto;
  z-index: 1000; display: none;
}
.search-results-drop.show { display: block; }
.sr-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--t); text-decoration: none; color: inherit;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: var(--surface-2); }
.sr-icon { color: var(--pri); font-size: 18px; margin-top: 2px; flex-shrink: 0; }
.sr-name { font-weight: 600; font-size: 13px; }
.sr-path { font-size: 11px; color: var(--text-4); margin-top: 2px; }
.sr-excerpt { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }
.sr-excerpt mark { background: #fef9c3; color: var(--text-1); border-radius: 2px; padding: 0 2px; }

/* Toolbar right actions */
.toolbar-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.tb-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 20px;
  transition: background var(--t), color var(--t);
  position: relative;
}
.tb-btn:hover { background: var(--surface-3); color: var(--text-1); }
.tb-badge {
  position: absolute; top: 3px; right: 3px;
  min-width: 15px; height: 15px; font-size: 9px; font-weight: 700;
  background: var(--red); color: #fff; border-radius: var(--r-pill);
  padding: 0 3px; display: flex; align-items: center; justify-content: center;
}
.tb-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* User chip */
.user-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 10px 3px 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  cursor: pointer; transition: all var(--t);
  font-size: 13px; font-weight: 500; color: var(--text-1);
}
.user-chip:hover { border-color: var(--pri); box-shadow: var(--sh-1); }
.u-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pri), var(--pri-light));
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.u-caret { font-size: 16px; color: var(--text-4); }

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  grid-column: 1; grid-row: 2;
  background: var(--sb-bg);
  display: flex; flex-direction: column;
  overflow: hidden; border-right: 1px solid var(--sb-border);
  transition: width var(--t) var(--ease);
}

/* Sidebar nav item */
.sb-item {
  display: flex; align-items: center; gap: 9px;
  height: 34px; padding: 0 12px;
  color: var(--sb-text); font-size: 13px; font-weight: 400;
  border: none; background: none; width: 100%; cursor: pointer;
  border-radius: 0; transition: background var(--t), color var(--t);
  text-decoration: none; white-space: nowrap; overflow: hidden;
  position: relative;
}
.sb-item:hover { background: var(--sb-hover); color: var(--sb-text-hi); text-decoration: none; }
.sb-item.active { color: #fff; font-weight: 600; }
.sb-item.active::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--pri); border-radius: 0 2px 2px 0;
}
.sb-item.active .sb-ico { color: var(--pri-light); }
.sb-item .sb-ico { font-size: 17px; flex-shrink: 0; }
.sb-item .sb-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sb-item .sb-count {
  font-size: 10px; font-weight: 700; padding: 1px 5px;
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.6);
  border-radius: var(--r-pill); flex-shrink: 0;
}
.sb-item.active .sb-count { background: rgba(26,115,232,.3); color: #93c5fd; }

/* Sidebar section label */
.sb-label-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--sb-head);
}
.sb-label-row a { color: var(--sb-head); }
.sb-label-row a:hover { color: var(--sb-text); }

/* Sidebar divider */
.sb-div { height: 1px; background: var(--sb-border); margin: 4px 0; }

/* Sidebar scroll area */
.sb-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 20px;
}
.sb-scroll::-webkit-scrollbar { width: 3px; }
.sb-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.07); border-radius: 2px; }
.sb-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.15); }

/* Project tree in sidebar */
.sb-proj-head {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px 0 12px;
  color: var(--sb-text); font-size: 12.5px; font-weight: 600;
  border: none; background: none; width: 100%; cursor: pointer;
  transition: background var(--t); text-decoration: none;
}
.sb-proj-head:hover { background: var(--sb-hover); color: var(--sb-text-hi); }
.sb-proj-icon { font-size: 15px; color: #f59e0b; flex-shrink: 0; }
.sb-proj-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.sb-proj-chevron { font-size: 14px; color: var(--sb-head); transition: transform var(--t) var(--ease); flex-shrink: 0; }
.sb-proj-chevron.open { transform: rotate(90deg); }

.sb-branch-link {
  display: flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 10px 0 32px;
  color: var(--sb-text); font-size: 12px;
  border: none; background: none; width: 100%; cursor: pointer;
  transition: background var(--t), color var(--t);
  text-decoration: none; white-space: nowrap; overflow: hidden;
}
.sb-branch-link:hover { background: var(--sb-hover); color: var(--sb-text-hi); text-decoration: none; }
.sb-branch-link.active { color: #93c5fd; font-weight: 500; }
.sb-branch-link .material-icons-round { font-size: 13px; color: #4b5563; flex-shrink: 0; }
.sb-branch-link.active .material-icons-round { color: #60a5fa; }

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content {
  grid-column: 2; grid-row: 2;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg);
}

/* Content sub-toolbar (breadcrumb bar) */
.content-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px 0 16px; height: 44px; min-height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; overflow: hidden;
}
.breadcrumb {
  display: flex; align-items: center; gap: 0;
  font-size: 12.5px; color: var(--text-3); flex: 1;
  overflow: hidden; min-width: 0; flex-wrap: nowrap;
  white-space: nowrap;
}
.bc-home { color: var(--text-4); font-size: 17px; flex-shrink: 0; }
.bc-sep { color: var(--border-2); font-size: 16px; flex-shrink: 0; }
.bc-item { color: var(--pri); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; }
.bc-item.active { color: var(--text-2); font-weight: 500; max-width: 200px; }

.content-body { flex: 1; overflow: auto; }
.content-body::-webkit-scrollbar { width: 7px; height: 7px; }
.content-body::-webkit-scrollbar-track { background: var(--bg); }
.content-body::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
.content-body::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* =====================================================
   PAGE LAYOUT
   ===================================================== */
.page-wrap { padding: 20px 24px; }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--sh-1);
  transition: box-shadow var(--t);
}
.stat-card:hover { box-shadow: var(--sh-2); }
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-val { font-size: 22px; font-weight: 700; line-height: 1; color: var(--text-1); }
.stat-lbl { font-size: 11.5px; color: var(--text-4); margin-top: 3px; font-weight: 500; }

/* Section header */
.sec-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.sec-title { font-size: 15px; font-weight: 700; color: var(--text-1); letter-spacing: -.2px; }
.sec-sub { font-size: 12.5px; color: var(--text-4); margin-top: 2px; }

/* =====================================================
   PROJECT CARDS
   ===================================================== */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.proj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden; cursor: pointer;
  text-decoration: none; color: inherit; display: flex; flex-direction: column;
  transition: box-shadow var(--t), transform var(--t), border-color var(--t);
}
.proj-card:hover { box-shadow: var(--sh-3); transform: translateY(-2px); border-color: var(--pri); text-decoration: none; color: inherit; }
.proj-card-top {
  padding: 14px 16px 10px;
  display: flex; align-items: flex-start; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.proj-ava {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0; font-weight: 700;
}
.proj-card-name { font-size: 14px; font-weight: 700; color: var(--text-1); line-height: 1.3; }
.proj-card-desc { font-size: 12px; color: var(--text-4); margin-top: 2px; }
.proj-card-mid { padding: 10px 16px; flex: 1; }
.proj-card-stats { display: flex; gap: 14px; }
.proj-stat { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); }
.proj-stat .material-icons-round { font-size: 13px; }
.proj-card-bot {
  padding: 8px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.branch-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.branch-tag {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 1px 8px;
  font-size: 11px; color: var(--text-3); font-weight: 500;
}
.branch-tag .material-icons-round { font-size: 11px; }

/* =====================================================
   FILE TREE (sidebar injection)
   ===================================================== */
.tree-row {
  display: flex; align-items: center;
  height: 28px; padding-right: 8px;
  color: var(--text-1); font-size: 12.5px;
  cursor: pointer; transition: background var(--t);
  text-decoration: none; background: none; border: none; width: 100%;
  white-space: nowrap; overflow: hidden;
}
.tree-row:hover { background: var(--surface-3); text-decoration: none; }
.tree-row.active { background: var(--pri-tint); color: var(--pri); font-weight: 600; }
.tree-row.active .t-icon { color: var(--pri); }
.tree-toggle { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--text-4); flex-shrink: 0; transition: transform var(--t); }
.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.leaf { color: transparent; pointer-events: none; }
.t-icon { font-size: 15px; flex-shrink: 0; margin-right: 5px; }
.t-name { flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.tree-children { display: none; }
.tree-children.open { display: block; }

/* File type icon colors */
.ic-folder { color: #f59e0b; }
.ic-md     { color: #3b82f6; }
.ic-html   { color: #ef4444; }
.ic-php    { color: #8b5cf6; }
.ic-js     { color: #f59e0b; }
.ic-ts     { color: #06b6d4; }
.ic-css    { color: #06b6d4; }
.ic-json   { color: #10b981; }
.ic-yaml   { color: #8b5cf6; }
.ic-img    { color: #ec4899; }
.ic-pdf    { color: #ef4444; }
.ic-sql    { color: #14b8a6; }
.ic-vue    { color: #10b981; }
.ic-react  { color: #06b6d4; }
.ic-def    { color: #6b7280; }

/* Map old class names to new */
.icon-folder { color: #f59e0b; }
.icon-md     { color: #3b82f6; }
.icon-html   { color: #ef4444; }
.icon-php    { color: #8b5cf6; }
.icon-js     { color: #f59e0b; }
.icon-ts     { color: #06b6d4; }
.icon-css    { color: #06b6d4; }
.icon-json   { color: #10b981; }
.icon-yaml   { color: #8b5cf6; }
.icon-img    { color: #ec4899; }
.icon-pdf    { color: #ef4444; }
.icon-sql    { color: #14b8a6; }
.icon-vue    { color: #10b981; }
.icon-react  { color: #06b6d4; }
.icon-default{ color: #6b7280; }

/* =====================================================
   DATA TABLES
   ===================================================== */
.tbl-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-1);
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  background: var(--surface-2); padding: 9px 14px;
  text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: .7px; text-transform: uppercase; color: var(--text-3);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table tbody td {
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }
/* backward compat */
.data-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-1); }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn-md {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0 14px; height: 32px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600; letter-spacing: .1px;
  cursor: pointer; transition: all var(--t) var(--ease);
  white-space: nowrap; border: 1px solid transparent;
}
.btn-md .material-icons-round { font-size: 16px; }
.btn-primary { background: var(--pri); color: #fff; border-color: var(--pri); box-shadow: 0 1px 3px rgba(26,115,232,.3); }
.btn-primary:hover { background: var(--pri-dark); box-shadow: 0 2px 8px rgba(26,115,232,.4); }
.btn-secondary { background: var(--surface); color: var(--pri); border-color: var(--pri); }
.btn-secondary:hover { background: var(--pri-tint); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-icon {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 17px; transition: background var(--t), color var(--t);
  cursor: pointer; background: none; border: none;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text-1); }
.btn-icon.danger:hover { background: var(--red-bg); color: var(--red); }

/* =====================================================
   BADGES / CHIPS
   ===================================================== */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; letter-spacing: .2px;
}
.chip .material-icons-round { font-size: 12px; }
.chip-blue   { background: var(--blue-bg);   color: var(--blue); }
.chip-green  { background: var(--green-bg);  color: var(--green); }
.chip-red    { background: var(--red-bg);    color: var(--red); }
.chip-yellow { background: var(--yellow-bg); color: var(--yellow); }
.chip-purple { background: var(--purple-bg); color: var(--purple); }
.chip-teal   { background: var(--teal-bg);   color: var(--teal); }
.chip-gray   { background: var(--surface-3); color: var(--text-3); border: 1px solid var(--border); }

/* Role chips */
.role-badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; }
.role-admin     { background: var(--purple-bg); color: var(--purple); }
.role-editor    { background: var(--green-bg);  color: var(--green); }
.role-viewer    { background: var(--blue-bg);   color: var(--blue); }
.role-commenter { background: var(--yellow-bg); color: var(--yellow); }
.status-active   { background: var(--green-bg); color: var(--green); }
.status-inactive { background: var(--red-bg);   color: var(--red); }

/* Frontmatter badges */
.frontmatter-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600; }
.badge-approved  { background: var(--green-bg);  color: var(--green); }
.badge-draft     { background: var(--yellow-bg); color: var(--yellow); }
.badge-review    { background: var(--blue-bg);   color: var(--blue); }
.badge-baselined { background: var(--purple-bg); color: var(--purple); }
.badge-default   { background: var(--surface-3); color: var(--text-3); border: 1px solid var(--border); }

/* File ID chip */
.file-id-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 2px 7px;
  font-size: 10.5px; font-weight: 600; color: var(--text-3);
  font-family: var(--font-mono); cursor: pointer;
  transition: border-color var(--t), color var(--t);
}
.file-id-chip:hover { border-color: var(--pri); color: var(--pri); }
.view-count-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--text-4); }
.view-count-chip .material-icons-round { font-size: 14px; }

/* =====================================================
   FILE VIEWER
   ===================================================== */
.file-viewer { flex: 1; display: flex; flex-direction: column; background: var(--surface); overflow: hidden; }
.fv-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2); flex-shrink: 0; min-height: 40px;
}
.file-meta-bar {
  padding: 6px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-shrink: 0;
}

/* Markdown */
.md-body {
  padding: 28px 36px; max-width: 860px;
  line-height: 1.8; color: var(--text-1); flex: 1;
}
.md-body h1 { font-size: 24px; font-weight: 800; margin: 0 0 18px; color: #111827; border-bottom: 2px solid var(--border); padding-bottom: 10px; }
.md-body h2 { font-size: 18px; font-weight: 700; margin: 24px 0 10px; color: var(--text-1); border-bottom: 1px solid var(--border); padding-bottom: 7px; }
.md-body h3 { font-size: 15px; font-weight: 700; margin: 18px 0 7px; color: var(--text-2); }
.md-body h4 { font-size: 14px; font-weight: 600; margin: 14px 0 5px; }
.md-body p  { margin: 0 0 12px; }
.md-body ul, .md-body ol { margin: 0 0 12px 22px; }
.md-body li { margin-bottom: 4px; }
.md-body blockquote { margin: 14px 0; padding: 10px 14px; border-left: 3px solid var(--pri); background: var(--pri-tint); border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--pri-dark); }
.md-body code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-3); padding: 2px 5px; border-radius: var(--r-xs); color: #be123c; border: 1px solid var(--border); }
.md-body pre { background: #0f172a; border-radius: var(--r-md); padding: 14px 18px; overflow-x: auto; margin: 14px 0; border: 1px solid #1e293b; }
.md-body pre code { background: none; color: #e2e8f0; padding: 0; border: none; font-size: 12.5px; }
.md-body table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 13px; }
.md-body th { background: var(--surface-3); font-weight: 600; padding: 8px 12px; text-align: left; border: 1px solid var(--border); color: var(--text-2); }
.md-body td { padding: 7px 12px; border: 1px solid var(--border); }
.md-body tr:nth-child(even) td { background: var(--surface-2); }
.md-body img { border-radius: var(--r-md); box-shadow: var(--sh-3); margin: 10px 0; max-width: 100%; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.md-body a { color: var(--pri); }

/* Code viewer */
.code-viewer-wrap { flex: 1; overflow: auto; background: #0f172a; }
.code-viewer-wrap pre { margin: 0; padding: 18px 22px; font-family: var(--font-mono); font-size: 13px; line-height: 1.65; color: #e2e8f0; }

/* JSON */
.json-viewer { padding: 14px 18px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7; flex: 1; overflow: auto; background: #0f172a; color: #e2e8f0; }
.json-key { color: #93c5fd; }
.json-string { color: #86efac; }
.json-number { color: #fbbf24; }
.json-bool { color: #f9a8d4; }
.json-null { color: #94a3b8; }
.json-toggle { cursor: pointer; user-select: none; color: #64748b; }
.json-toggle:hover { color: #cbd5e1; }
.json-collapsed { display: none; }

/* Image viewer */
.image-viewer { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; background: #0f172a; }
.image-viewer img { max-width: 100%; max-height: 100%; border-radius: var(--r-md); box-shadow: var(--sh-4); }

/* PDF */
.pdf-viewer { flex: 1; }
.pdf-viewer embed { width: 100%; height: 100%; border: none; }

/* HTML iframe */
.html-preview-frame { flex: 1; border: none; width: 100%; background: #fff; }

/* =====================================================
   TABS
   ===================================================== */
.tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--surface); padding: 0 12px; flex-shrink: 0; gap: 0; }
.tab-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 0 14px; height: 40px;
  font-size: 13px; font-weight: 500; color: var(--text-3);
  border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--t);
}
.tab-btn .material-icons-round { font-size: 16px; }
.tab-btn:hover { color: var(--text-1); }
.tab-btn.active { color: var(--pri); border-bottom-color: var(--pri); font-weight: 600; }
/* backward compat */
.md-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.md-tab {
  padding: 0 16px; height: 40px; display: flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 500; color: var(--text-3);
  border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--t);
}
.md-tab .material-icons-round { font-size: 16px; }
.md-tab:hover { color: var(--text-1); }
.md-tab.active { color: var(--pri); border-bottom-color: var(--pri); font-weight: 600; }
.md-tab-content { display: none; }
.md-tab-content.active { display: flex; flex-direction: column; flex: 1; overflow-y: auto; overflow-x: hidden; }

/* =====================================================
   FORMS
   ===================================================== */
.md-field { margin-bottom: 16px; }
.md-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 5px; letter-spacing: .1px; }
.md-input {
  width: 100%; height: 36px;
  border: 1px solid var(--border-2); border-radius: var(--r-sm);
  padding: 0 10px; font-size: 13.5px; color: var(--text-1);
  background: var(--surface); outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.md-input:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(26,115,232,.1); }
.md-input.error { border-color: var(--red); }
.md-textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; }
.md-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7280' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; padding-right: 28px; }
.md-hint  { font-size: 11px; color: var(--text-4); margin-top: 3px; }
.md-error { font-size: 11px; color: var(--red); margin-top: 3px; }

/* =====================================================
   MODALS
   ===================================================== */
.kb-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: none; align-items: center; justify-content: center;
  z-index: 2000; padding: 20px; backdrop-filter: blur(2px);
}
.kb-modal.open { display: flex; animation: bdin var(--t) var(--ease); }
@keyframes bdin { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--sh-modal);
  width: 100%; max-width: 520px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: mdin .18s var(--ease);
  border: 1px solid var(--border);
}
@keyframes mdin { from { opacity: 0; transform: translateY(-12px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 700; flex: 1; color: var(--text-1); }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 10px 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  background: var(--surface-2);
}

/* =====================================================
   DROPDOWNS
   ===================================================== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 5px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-4);
  min-width: 178px; z-index: 1000; display: none; overflow: hidden;
  padding: 4px 0;
}
.dropdown-menu.open { display: block; animation: dropin .13s var(--ease); }
@keyframes dropin { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.dropdown-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 13px; font-size: 13px; color: var(--text-1);
  cursor: pointer; transition: background var(--t);
  border: none; background: none; width: 100%; text-align: left; text-decoration: none;
}
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text-1); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: var(--red-bg); }
.dropdown-item .material-icons-round { font-size: 17px; color: var(--text-4); }
.dropdown-item.danger .material-icons-round { color: var(--red); }
.dropdown-sep { height: 1px; background: var(--border); margin: 3px 0; }

/* =====================================================
   COMMENTS
   ===================================================== */
.comment-item { display: flex; gap: 10px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; margin-bottom: 0; }
.comment-avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg, var(--pri), var(--pri-light)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.comment-content { flex: 1; min-width: 0; }
.comment-header { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; flex-wrap: wrap; }
.comment-author { font-size: 13px; font-weight: 600; color: var(--text-1); }
.comment-time { font-size: 11px; color: var(--text-4); }
.comment-actions { margin-left: auto; display: flex; gap: 2px; }
.comment-text { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.comment-thread { margin-top: 10px; padding-left: 14px; border-left: 2px solid var(--border); }
.comment-input { width: 100%; border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 8px 12px; font-size: 13px; resize: none; outline: none; transition: border-color var(--t); min-height: 56px; }
.comment-input:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(26,115,232,.08); }

/* =====================================================
   GIT
   ===================================================== */
.git-commit-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--t); }
.git-commit-item:hover { background: var(--surface-2); }
.git-hash { font-family: var(--font-mono); font-size: 11px; color: var(--pri); background: var(--pri-tint); padding: 2px 6px; border-radius: var(--r-xs); white-space: nowrap; flex-shrink: 0; height: fit-content; }
.git-message { font-size: 13px; font-weight: 500; }
.git-meta { font-size: 11px; color: var(--text-4); margin-top: 2px; }
.diff-viewer { background: #0f172a; padding: 14px; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; overflow-x: auto; border-radius: var(--r-md); border: 1px solid #1e293b; }
.diff-add { color: #86efac; background: rgba(134,239,172,.08); display: block; }
.diff-remove { color: #fca5a5; background: rgba(252,165,165,.08); display: block; }
.diff-meta { color: #64748b; }

/* =====================================================
   EDITOR
   ===================================================== */
.editor-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 5px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-shrink: 0; }
.editor-toolbar-sep { width: 1px; height: 18px; background: var(--border-2); margin: 0 2px; }
.editor-panes { flex: 1; display: flex; overflow: hidden; }
.editor-code { flex: 1; overflow: auto; font-family: var(--font-mono); font-size: 13px; border: none; outline: none; resize: none; padding: 14px; background: #0f172a; color: #e2e8f0; line-height: 1.65; }
.editor-preview { flex: 1; overflow: auto; padding: 20px 28px; border-left: 1px solid var(--border); }

/* =====================================================
   EMPTY / LOADING STATES
   ===================================================== */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px 20px; color: var(--text-4); text-align: center; flex: 1; }
.empty-state .material-icons-round { font-size: 52px; margin-bottom: 14px; color: var(--border-2); }
.empty-state h3 { font-size: 15px; font-weight: 700; color: var(--text-3); margin-bottom: 7px; }
.empty-state p { font-size: 13px; max-width: 280px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: skel 1.4s infinite; border-radius: var(--r-xs); }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =====================================================
   SNACKBAR
   ===================================================== */
.snackbar-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 7px; align-items: center; pointer-events: none; }
.snackbar { display: flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: var(--r-pill); background: #1f2937; color: #fff; font-size: 13.5px; font-weight: 500; box-shadow: var(--sh-4); pointer-events: all; animation: snkin .2s var(--ease); min-width: 180px; max-width: 440px; }
.snackbar.success { background: var(--green); }
.snackbar.error   { background: var(--red); }
.snackbar.warning { background: var(--yellow); }
@keyframes snkin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* =====================================================
   TOOLTIP
   ===================================================== */
[data-tooltip] { position: relative; }
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; font-size: 11.5px; font-weight: 500; padding: 3px 8px; border-radius: var(--r-sm); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity var(--t); z-index: 1000; }
[data-tooltip]:hover::after { opacity: 1; }

/* =====================================================
   INFO PANEL (in admin, file info, etc.)
   ===================================================== */
.info-panel { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--r-md); padding: 11px 14px; font-size: 12.5px; color: var(--blue); }
.info-panel strong { font-weight: 600; }
.info-panel code { background: rgba(29,78,216,.08); padding: 1px 5px; border-radius: var(--r-xs); font-family: var(--font-mono); font-size: 11.5px; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1024px) {
  :root { --sb-w: 220px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .md-body { padding: 20px 22px; }
}
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 0 1fr; }
  .sidebar { position: fixed; left: -260px; top: 0; height: 100%; transition: left var(--t); z-index: 500; width: var(--sb-w) !important; }
  .sidebar.open { left: 0; }
  .main-content { grid-column: 1 / -1; }
  .toolbar-brand { display: none; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .proj-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .page-wrap { padding: 14px; }
  .toolbar-search-wrap { max-width: 160px; }
}

/* =====================================================
   UTILITIES
   ===================================================== */
.d-flex  { display: flex; }
.d-none  { display: none !important; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1  { flex: 1; }
.gap-4   { gap: 4px; }
.gap-8   { gap: 8px; }
.gap-12  { gap: 12px; }
.gap-16  { gap: 16px; }
.text-muted { color: var(--text-4); }
.text-sm    { font-size: 12px; }
.fw-600  { font-weight: 600; }
.fw-700  { font-weight: 700; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-0  { margin-bottom: 0; }
.w-100 { width: 100%; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.surface { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }

/* =====================================================
   BACKWARD COMPAT — old class names still used in PHP
   ===================================================== */
.page-content  { padding: 20px 24px; }
.page-header   { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.page-title    { font-size: 16px; font-weight: 700; color: var(--text-1); letter-spacing: -.2px; }
.page-subtitle { font-size: 12.5px; color: var(--text-4); margin-top: 2px; }

/* Old project card classes */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px,1fr)); gap: 14px; margin-bottom: 28px; }
.project-card  {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-1); overflow: hidden; cursor: pointer;
  text-decoration: none; color: inherit; display: flex; flex-direction: column;
  transition: box-shadow var(--t), transform var(--t), border-color var(--t);
}
.project-card:hover { box-shadow: var(--sh-3); transform: translateY(-2px); border-color: var(--pri); text-decoration: none; color: inherit; }
.project-card-header { padding: 14px 16px 10px; display: flex; align-items: flex-start; gap: 12px; border-bottom: 1px solid var(--border); }
.project-card-body   { padding: 10px 16px; flex: 1; }
.project-card-footer { padding: 8px 16px; background: var(--surface-2); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.project-card-title  { font-size: 14px; font-weight: 700; color: var(--text-1); }
.project-card-desc   { font-size: 12px; color: var(--text-4); margin-top: 2px; }
.project-icon  { width: 38px; height: 38px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.project-stat-row { display: flex; gap: 14px; }
.project-stat  { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); }
.project-stat .material-icons-round { font-size: 13px; }
.project-branches { display: flex; gap: 5px; flex-wrap: wrap; }
.branch-chip   { display: inline-flex; align-items: center; gap: 3px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 1px 8px; font-size: 11px; color: var(--text-3); }
.branch-chip .material-icons-round { font-size: 11px; }

/* Old breadcrumb classes */
.breadcrumb-item     { color: var(--pri); font-size: 12.5px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb-item.active { color: var(--text-2); font-weight: 500; }
.breadcrumb-sep      { font-size: 16px; color: var(--border-2); }

/* Old sidebar tree classes */
.tree-item { display: flex; align-items: center; height: 28px; padding-right: 8px; color: var(--text-1); font-size: 12.5px; cursor: pointer; transition: background var(--t); text-decoration: none; background: none; border: none; width: 100%; white-space: nowrap; overflow: hidden; }
.tree-item:hover { background: var(--surface-3); text-decoration: none; }
.tree-item.active { background: var(--pri-tint); color: var(--pri); font-weight: 600; }
.tree-icon  { font-size: 15px; flex-shrink: 0; margin-right: 5px; }
.tree-name  { flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.tree-toggle { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--text-4); flex-shrink: 0; transition: transform var(--t); }
.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.empty { color: transparent; pointer-events: none; }
.branch-file-tree .tree-children { display: none; }
.branch-file-tree .tree-children.open { display: block; }

/* Old actions-cell */
.actions-cell { display: flex; align-items: center; gap: 2px; }

/* Old user-avatar (sidebar) */
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--pri), var(--pri-light)); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Old comment-form */
.comment-form { display: flex; gap: 10px; margin-bottom: 12px; }
.comment-edited { font-size: 11px; color: var(--text-4); font-style: italic; }

/* File viewer wrapper when inside content-body */
.content-body .file-viewer { height: 100%; }

/* Old info-bg / info */
.info-bg { background: #eff6ff; }


/* =====================================================
   VISUAL OVERHAUL — Override Bootstrap, make it POP
   ===================================================== */

/* Force Inter font everywhere */
body, input, select, textarea, button { font-family: 'Inter', -apple-system, sans-serif !important; }

/* Stat cards — colored accent bar on left */
.stat-card {
  border-left: 3px solid var(--pri) !important;
  padding: 16px 18px !important;
  background: var(--surface) !important;
  border-radius: 0 var(--r-lg) var(--r-lg) 0 !important;
  transition: transform .15s, box-shadow .15s !important;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--sh-3) !important; }
.stat-card:nth-child(1) { border-left-color: #1a73e8 !important; }
.stat-card:nth-child(2) { border-left-color: #059669 !important; }
.stat-card:nth-child(3) { border-left-color: #7c3aed !important; }
.stat-card:nth-child(4) { border-left-color: #d97706 !important; }
.stat-val { font-size: 26px !important; font-weight: 800 !important; letter-spacing: -1px; }
.stat-lbl { font-size: 12px !important; font-weight: 600 !important; text-transform: uppercase; letter-spacing: .5px; }

/* Sidebar — stronger dark */
.sidebar { background: #0d1117 !important; border-right: 1px solid #21262d !important; }
.sb-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.05) !important; }
.sb-item { height: 36px !important; }
.sb-item:hover { background: rgba(255,255,255,.06) !important; }
.sb-item.active { background: rgba(26,115,232,.2) !important; }
.sb-item.active::before { background: #1a73e8 !important; }
.sb-label-row { color: #484f58 !important; font-size: 11px !important; letter-spacing: 1.2px !important; }
.sb-proj-head:hover { background: rgba(255,255,255,.06) !important; }
.sb-div { background: #21262d !important; }

/* Top toolbar */
.top-toolbar { box-shadow: 0 1px 0 var(--border) !important; }
.toolbar-brand { background: #0d1117 !important; border-right: 1px solid #21262d !important; }
.toolbar-search { background: #f6f8fa !important; border: 1px solid #d0d7de !important; border-radius: 6px !important; }
.toolbar-search:focus { background: #fff !important; border-color: #0969da !important; box-shadow: 0 0 0 3px rgba(9,105,218,.12) !important; }
.user-chip { border-radius: 6px !important; border-color: #d0d7de !important; }
.tb-btn { border-radius: 6px !important; color: #57606a !important; }
.tb-btn:hover { background: #f6f8fa !important; color: #24292f !important; }

/* Project cards — GitHub-style */
.proj-card, .project-card {
  border-radius: 6px !important;
  border: 1px solid #d0d7de !important;
  box-shadow: 0 1px 3px rgba(31,35,40,.04) !important;
}
.proj-card:hover, .project-card:hover {
  border-color: #0969da !important;
  box-shadow: 0 3px 12px rgba(9,105,218,.1) !important;
  transform: none !important;
}
.proj-card-top { border-bottom: 1px solid #f6f8fa !important; }
.proj-card-bot { background: #f6f8fa !important; border-top: 1px solid #eaeef2 !important; }

/* Data table — tighter, professional */
.data-table thead th {
  background: #f6f8fa !important;
  border-bottom: 1px solid #d0d7de !important;
  color: #57606a !important;
  font-size: 11px !important;
  padding: 8px 14px !important;
  font-weight: 700 !important;
  letter-spacing: .5px !important;
  text-transform: uppercase !important;
}
.data-table tbody td { padding: 8px 14px !important; border-bottom: 1px solid #eaeef2 !important; }
.data-table tbody tr:hover td { background: #f6f8fa !important; }
.tbl-wrap, .data-table-wrap { border-radius: 6px !important; border: 1px solid #d0d7de !important; overflow: hidden; }

/* Breadcrumb bar — styles defined in main content-toolbar block above */
.bc-item, .breadcrumb-item { font-size: 12.5px; color: var(--pri); }
.bc-item.active, .breadcrumb-item.active { color: var(--text-1); font-weight: 600; }

/* Buttons */
.btn-primary { background: #1f883d !important; border-color: rgba(31,35,40,.15) !important; box-shadow: 0 1px 0 rgba(31,35,40,.1) !important; }
.btn-primary:hover { background: #1a7f37 !important; }
.btn-md.btn-primary { background: #1a73e8 !important; }
.btn-md.btn-primary:hover { background: #1557b0 !important; }
.btn-secondary { background: #f6f8fa !important; color: #24292f !important; border-color: #d0d7de !important; }
.btn-secondary:hover { background: #f3f4f6 !important; border-color: #c9d1d9 !important; }

/* Section title */
.sec-title { font-size: 16px !important; font-weight: 700 !important; color: #24292f !important; }
.sec-sub { color: #57606a !important; font-size: 12.5px !important; }

/* Empty state */
.empty-state { background: #f6f8fa !important; border: 1px dashed #d0d7de !important; border-radius: 6px !important; }
.empty-state .material-icons-round { color: #8c959f !important; }
.empty-state h3 { color: #24292f !important; }

/* Modal */
.modal-card { border-radius: 12px !important; border: 1px solid #d0d7de !important; }
.modal-header { background: #f6f8fa !important; border-bottom: 1px solid #d0d7de !important; }
.modal-footer { background: #f6f8fa !important; }

/* Chips/badges */
.chip-blue { background: #ddf4ff !important; color: #0969da !important; }
.role-admin { background: #fbefff !important; color: #8250df !important; }
.role-editor { background: #dafbe1 !important; color: #1a7f37 !important; }
.role-viewer { background: #ddf4ff !important; color: #0969da !important; }

/* =====================================================
   MODAL FIX — override Bootstrap conflicts
   ===================================================== */
.kb-modal {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(0,0,0,.45) !important;
  z-index: 2000 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
}
.kb-modal.open {
  display: flex !important;
}
.kb-modal .modal-card {
  background: #ffffff !important;
  border-radius: 12px !important;
  box-shadow: 0 20px 60px rgba(0,0,0,.25) !important;
  width: 100% !important;
  max-width: 520px !important;
  max-height: 88vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  border: 1px solid #d0d7de !important;
  position: relative !important;
  z-index: 2001 !important;
}
.modal-header {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 14px 18px !important;
  border-bottom: 1px solid #e5e7eb !important;
  background: #f6f8fa !important;
  flex-shrink: 0 !important;
}
.modal-title {
  font-size: 15px !important;
  font-weight: 700 !important;
  flex: 1 !important;
  color: #24292f !important;
}
.modal-body {
  padding: 18px !important;
  overflow-y: auto !important;
  flex: 1 !important;
  background: #ffffff !important;
}
.modal-footer {
  padding: 10px 18px !important;
  border-top: 1px solid #e5e7eb !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
  background: #f6f8fa !important;
  flex-shrink: 0 !important;
}
/* Ensure form inputs inside modals are visible */
.modal-body .md-input,
.modal-body .md-textarea,
.modal-body .md-select {
  background: #ffffff !important;
  border: 1px solid #d0d7de !important;
  color: #24292f !important;
}
.modal-body .md-label {
  color: #57606a !important;
}
.modal-body .md-hint {
  color: #6e7781 !important;
}
/* Info panel inside modal */
.modal-body > div[style*="background:#eff6ff"],
.modal-body > div[style*="background: #eff6ff"] {
  border-radius: 6px !important;
  font-size: 12.5px !important;
}

/* ── Form utilities ─────────────────────────────── */
.form-group { margin-bottom: 0; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.form-control {
  display: block; width: 100%; height: 36px;
  padding: 0 10px; font-size: 13.5px; font-family: var(--font);
  color: var(--text-1); background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-md); outline: none; transition: border-color .15s;
}
.form-control:focus { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
textarea.form-control { height: auto; padding: 8px 10px; resize: vertical; }
select.form-control { appearance: none; cursor: pointer; }
.form-control::placeholder { color: var(--text-4); }

/* ── Alerts ─────────────────────────────────────── */
.alert-success {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--r-md);
  background: #d1fae5; color: #065f46; font-size: 13px; border: 1px solid #a7f3d0;
}
.alert-error {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--r-md);
  background: #fee2e2; color: #991b1b; font-size: 13px; border: 1px solid #fca5a5;
}
.alert-info {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--r-md);
  background: #dbeafe; color: #1e40af; font-size: 13px; border: 1px solid #93c5fd;
}

/* ======

/* ============================================================
   CPANEL FILE MANAGER SHELL — v3.0
   ============================================================ */
.cpfm-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100%;   /* fills main-content which is already below toolbar */
  overflow: hidden;
}
.cpfm-tree-panel {
  position: relative;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 140px;
  max-width: 480px;
  overflow: hidden;
}
.cpfm-tree-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cpfm-tree-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.cpfm-tree-scroll::-webkit-scrollbar { width: 4px; }
.cpfm-tree-scroll::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
.cpfm-tree-node { display: flex; flex-direction: column; }
.cpfm-tree-row {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px 4px 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-2);
  border-radius: 0;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}
.cpfm-tree-row:hover { background: var(--surface-3); color: var(--text-1); }
.cpfm-tree-row.active { background: var(--pri-tint); color: var(--pri); font-weight: 600; }
.cpfm-tree-arrow { font-size: 14px !important; flex-shrink: 0; color: var(--text-4); transition: transform .15s; }
.cpfm-tree-ico { font-size: 15px !important; flex-shrink: 0; color: #f59e0b; }
.cpfm-tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cpfm-tree-children { padding-left: 14px; }
.cpfm-tree-loading,.cpfm-tree-empty { padding: 6px 14px; font-size: 11.5px; color: var(--text-4); }
.cpfm-resizer {
  position: absolute; right: 0; top: 0; bottom: 0; width: 4px;
  cursor: col-resize; z-index: 10;
  transition: background .1s;
}
.cpfm-resizer:hover { background: var(--pri); }

/* RIGHT panel */
.cpfm-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  height: 100%;        /* fill grid cell */
  background: var(--bg);
}
/* Anonymous wrapper div that holds md-tabs + md-tab-content panels */
.cpfm-main > div:not([class]) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
/* The active tab content scrolls vertically */
.cpfm-main .md-tab-content.active {
  overflow-y: auto !important;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}
.cpfm-main .fm-table-wrap {
  overflow-y: auto !important;
  flex: 1;
  min-height: 0;
}
.cpfm-main .md-tab-content { overflow-y: auto !important; flex: 1; min-height: 0; }
.cpfm-main .fm-table-wrap { flex: 1; overflow: auto; min-height: 0; }

/* ============================================================
   DARK MODE — v3.0
   Applied via: html[data-theme="dark"]
   ============================================================ */
html[data-theme="dark"] {
  --pri:          #4a7fd4;
  --pri-dark:     #3a6abf;
  --pri-light:    #6b9ee8;
  --pri-tint:     rgba(74,127,212,.15);
  --accent:       #fb923c;
  --accent-tint:  rgba(251,146,60,.12);

  --bg:           #0f1117;
  --surface:      #1a1d27;
  --surface-2:    #1e2130;
  --surface-3:    #242838;
  --surface-4:    #2a2f42;

  --text-1:       #e2e8f0;
  --text-2:       #cbd5e1;
  --text-3:       #8892a4;
  --text-4:       #5a6478;
  --text-inv:     #0f1117;

  --border:       #2a2f42;
  --border-2:     #343a52;

  --sb-bg:        #0d1017;
  --sb-bg2:       #111520;
  --sb-hover:     #1a2030;
  --sb-active:    #4d8ef0;
  --sb-active-bg: rgba(77,142,240,.18);
  --sb-text:      #6b7a95;
  --sb-text-hi:   #c8d0e0;
  --sb-head:      #4a5470;
  --sb-border:    #1a1f30;

  --tb-bg:        #13161f;
  --tb-border:    #1e2333;

  --sh-1: 0 1px 3px rgba(0,0,0,.4);
  --sh-2: 0 2px 8px rgba(0,0,0,.5);
  --sh-3: 0 4px 20px rgba(0,0,0,.6);
  --sh-4: 0 8px 40px rgba(0,0,0,.7);
  --sh-modal: 0 24px 80px rgba(0,0,0,.8);

  --green-bg:  rgba(22,163,74,.15);
  --yellow-bg: rgba(217,119,6,.15);
  --red-bg:    rgba(220,38,38,.15);
  --blue-bg:   rgba(29,78,216,.15);
  --purple-bg: rgba(124,58,237,.15);
  --teal-bg:   rgba(15,118,110,.15);
}

/* Dark mode body */
html[data-theme="dark"] body { background: var(--bg); color: var(--text-1); }

/* Dark toolbar */
/* Dark mode toolbar — deeper navy */
html[data-theme="dark"] .top-toolbar { background: #060e1c; border-bottom-color: #0d1a30; }

/* Dark sidebar */
html[data-theme="dark"] .sidebar { background: var(--sb-bg); border-right-color: var(--sb-border); }
html[data-theme="dark"] .sb-item { color: var(--sb-text); }
html[data-theme="dark"] .sb-item:hover { background: var(--sb-hover); color: var(--sb-text-hi); }
html[data-theme="dark"] .sb-item.active { background: var(--sb-active-bg); color: var(--sb-active); }
html[data-theme="dark"] .sb-proj-head { color: var(--sb-text-hi); }
html[data-theme="dark"] .sb-proj-head:hover { background: var(--sb-hover); }
html[data-theme="dark"] .sb-branch-link { color: var(--sb-text); }
html[data-theme="dark"] .sb-branch-link:hover { background: var(--sb-hover); color: var(--sb-text-hi); }
html[data-theme="dark"] .sb-branch-link.active { background: var(--sb-active-bg); color: var(--sb-active); }
html[data-theme="dark"] .sb-div { border-top-color: var(--sb-border); }

/* Dark cPanel file manager */
html[data-theme="dark"] .cpfm-shell { background: var(--bg); }
html[data-theme="dark"] .cpfm-tree-panel { background: var(--surface); border-right-color: var(--border); }
html[data-theme="dark"] .cpfm-tree-head { background: var(--surface-2); border-bottom-color: var(--border); color: var(--text-3); }
html[data-theme="dark"] .cpfm-tree-row { color: var(--text-2); }
html[data-theme="dark"] .cpfm-tree-row:hover { background: var(--surface-3); color: var(--text-1); }
html[data-theme="dark"] .cpfm-tree-row.active { background: var(--pri-tint); color: var(--pri); }
html[data-theme="dark"] .cpfm-resizer { background: transparent; }
html[data-theme="dark"] .cpfm-resizer:hover { background: var(--border); }

/* Dark file listing */
html[data-theme="dark"] .fm-table thead th { background: var(--surface-2); color: var(--text-3); border-bottom-color: var(--border); }
html[data-theme="dark"] .fm-table tbody tr:hover { background: var(--surface-3); }
html[data-theme="dark"] .fm-table td { border-bottom-color: var(--border); color: var(--text-2); }
html[data-theme="dark"] .fm-table .file-name-link { color: var(--text-1); }
html[data-theme="dark"] .fm-table .file-name-link:hover { color: var(--pri); }

/* Dark content toolbar */
html[data-theme="dark"] /* content-toolbar dark handled by main dark block */
html[data-theme="dark"] .breadcrumb-item { color: var(--text-3); }
html[data-theme="dark"] .breadcrumb-item.active { color: var(--text-1); }
html[data-theme="dark"] .breadcrumb-sep { color: var(--text-4); }

/* Dark tabs */
html[data-theme="dark"] .md-tab-bar { background: var(--surface-2); border-bottom-color: var(--border); }
html[data-theme="dark"] .md-tab { color: var(--text-3); }
html[data-theme="dark"] .md-tab:hover { color: var(--text-1); }
html[data-theme="dark"] .md-tab.active { color: var(--pri); border-bottom-color: var(--pri); background: var(--surface); }
html[data-theme="dark"] .md-tab-content { background: var(--surface); }
html[data-theme="dark"] .md-body { color: var(--text-1); }
html[data-theme="dark"] .md-body h1,html[data-theme="dark"] .md-body h2,html[data-theme="dark"] .md-body h3 { color: var(--text-1); border-color: var(--border); }
html[data-theme="dark"] .md-body code { background: var(--surface-3); color: #f97316; border-color: var(--border); }
html[data-theme="dark"] .md-body pre { background: var(--surface-3); border-color: var(--border); }
html[data-theme="dark"] .md-body blockquote { border-left-color: var(--pri); background: var(--pri-tint); color: var(--text-2); }
html[data-theme="dark"] .md-body table thead { background: var(--surface-3); }
html[data-theme="dark"] .md-body table td,html[data-theme="dark"] .md-body table th { border-color: var(--border); }
html[data-theme="dark"] .md-body a { color: var(--pri-light); }

/* Dark dropdown */
html[data-theme="dark"] .dropdown-menu { background: var(--surface-2); border-color: var(--border); box-shadow: var(--sh-4); }
html[data-theme="dark"] .dropdown-item { color: var(--text-2); }
html[data-theme="dark"] .dropdown-item:hover { background: var(--surface-3); color: var(--text-1); }
html[data-theme="dark"] .dropdown-sep { border-top-color: var(--border); }

/* Dark cards (index.php) */
html[data-theme="dark"] .proj-card { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .proj-card:hover { border-color: var(--pri); box-shadow: var(--sh-3); }

/* Dark modals */
html[data-theme="dark"] .kb-modal-box { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .kb-modal-head { background: var(--surface-2); border-bottom-color: var(--border); }
html[data-theme="dark"] .md-input { background: var(--surface-3); border-color: var(--border); color: var(--text-1); }
html[data-theme="dark"] .md-input:focus { border-color: var(--pri); }
html[data-theme="dark"] .md-label { color: var(--text-3); }

/* Dark editor */
html[data-theme="dark"] .editor-toolbar { background: var(--surface-2); border-bottom-color: var(--border); }
html[data-theme="dark"] .editor-toolbar-sep { background: var(--border); }

/* Theme toggle button */
.tb-theme-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-pill);
  color: var(--text-3); transition: background var(--t) var(--ease), color var(--t) var(--ease);
  cursor: pointer; border: none; background: none;
}
.tb-theme-btn:hover { background: var(--surface-3); color: var(--text-1); }
.tb-theme-btn .icon-dark { display: none; }
.tb-theme-btn .icon-light { display: block; }
html[data-theme="dark"] .tb-theme-btn .icon-dark { display: block; }
html[data-theme="dark"] .tb-theme-btn .icon-light { display: none; }

/* Projects nav button in toolbar */
.tb-nav-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 0 10px; height: 34px; border-radius: var(--r-md);
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  border: 1px solid var(--border); background: var(--surface-2);
  cursor: pointer; transition: all var(--t) var(--ease);
  white-space: nowrap;
}
.tb-nav-btn:hover { border-color: var(--pri); color: var(--pri); background: var(--pri-tint); }
html[data-theme="dark"] .tb-nav-btn { background: var(--surface-3); border-color: var(--border); color: var(--text-2); }
html[data-theme="dark"] .tb-nav-btn:hover { border-color: var(--pri); color: var(--pri); background: var(--pri-tint); }

/* ── MODAL (generic) ── */
.kb-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.kb-modal-overlay.open { opacity: 1; pointer-events: all; }
.kb-modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-modal);
  width: min(520px, 94vw); display: flex; flex-direction: column;
  transform: translateY(12px); transition: transform .2s;
}
.kb-modal-overlay.open .kb-modal-box { transform: translateY(0); }
.kb-modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; background: var(--surface-2);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.kb-modal-head h3 { font-size: 15px; font-weight: 600; flex: 1; margin: 0; color: var(--text-1); }
.kb-modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.kb-modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.kb-form-row { display: flex; flex-direction: column; gap: 5px; }
.kb-form-row label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.kb-form-row input, .kb-form-row textarea, .kb-form-row select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 13.5px; background: var(--surface-2); color: var(--text-1);
  transition: border-color var(--t); outline: none;
}
.kb-form-row input:focus, .kb-form-row textarea:focus { border-color: var(--pri); }
html[data-theme="dark"] .kb-form-row input, html[data-theme="dark"] .kb-form-row textarea { background: var(--surface-3); border-color: var(--border); color: var(--text-1); }
html[data-theme="dark"] .kb-form-row input:focus { border-color: var(--pri); }
.kb-form-hint { font-size: 11px; color: var(--text-4); margin-top: 2px; }

/* UX Improvements — tighter toolbar */
.top-toolbar { gap: 6px; }
.toolbar-search-wrap { max-width: 320px; }


/* ── Arobit Brand Accent Buttons ── */
.btn-md.btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent-dark) !important;
  color: #fff !important;
}
.btn-md.btn-primary:hover {
  background: var(--accent-dark) !important;
}

/* Active nav states — orange accent */
.cpfm-tree-row.active { background: rgba(249,115,22,.12); color: var(--accent); font-weight: 600; }
.sb-branch-link.active { background: var(--sb-active-bg); color: var(--sb-active); }
html[data-theme="dark"] .cpfm-tree-row.active { background: rgba(249,115,22,.15); color: #fb923c; }

/* Proj card hover — orange accent border */
.proj-card:hover { border-color: var(--accent) !important; box-shadow: 0 4px 20px rgba(249,115,22,.15) !important; }

/* Tab active — orange underline */
.md-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* File id chip */
.file-id-chip { background: var(--pri-tint); color: var(--pri); }

/* Breadcrumb links */
.breadcrumb-item { color: var(--pri); }
.breadcrumb-item.active { color: var(--text-1); }

/* ============================================================
   FILE MANAGER — Directory Listing  v3.0
   ============================================================ */

/* Toolbar above table */
.fm-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; min-height: 42px;
}
.fm-path-bar {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-3);
  flex: 1; overflow: hidden; white-space: nowrap;
}
.fm-crumb {
  color: var(--pri); font-weight: 500; font-size: 12px;
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex-shrink: 1;
}
.fm-crumb:hover { text-decoration: underline; }
.fm-crumb.active { color: var(--text-1); font-weight: 600; }
.fm-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.fm-count {
  font-size: 11.5px; color: var(--text-4);
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: var(--r-pill);
}
.fm-action-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: var(--r-md);
  font-size: 12px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); transition: all var(--t) var(--ease);
}
.fm-action-btn:hover { border-color: var(--pri); color: var(--pri); background: var(--pri-tint); }
.fm-action-btn.primary { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
.fm-action-btn.primary:hover { background: var(--accent-dark); }
.fm-action-btn .material-icons-round { font-size: 15px; }

/* Table */
.fm-table-wrap { flex: 1; overflow-y: auto; overflow-x: hidden; }
.fm-table-wrap::-webkit-scrollbar { width: 5px; }
.fm-table-wrap::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
.fm-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.fm-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--text-3);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  text-align: left; white-space: nowrap;
}
.fm-th-name  { width: 45%; }
.fm-th-type  { width: 80px; }
.fm-th-size  { width: 80px; }
.fm-th-date  { width: 160px; }
.fm-th-actions { width: 90px; }

.fm-row { cursor: pointer; transition: background var(--t) var(--ease); }
.fm-row:hover { background: var(--surface-3); }
.fm-row td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.fm-row-parent { cursor: default; }
.fm-row-parent:hover { background: transparent; }

/* Name cell */
.fm-name-cell {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: inherit;
}
.fm-name-cell:hover { text-decoration: none; }
.fm-icon-wrap {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.fm-icon-dir  { background: rgba(249,115,22,.1); }
.fm-icon-file { background: var(--surface-3); }
.fm-icon-up   { background: var(--surface-3); }
.fm-icon-wrap .material-icons-round { font-size: 17px; }
.fm-name-text { font-size: 13px; color: var(--text-1); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-name-dir  { color: var(--text-1); font-weight: 600; }
.fm-name-text:hover { color: var(--pri); }

/* Type badge */
.fm-type-badge {
  display: inline-block; padding: 1px 6px; border-radius: var(--r-xs);
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  background: var(--surface-3); color: var(--text-3);
  border: 1px solid var(--border);
}
.fm-size  { font-size: 12px; color: var(--text-3); }
.fm-date  { font-size: 11.5px; color: var(--text-4); white-space: nowrap; }
.fm-row-actions { display: flex; align-items: center; gap: 2px; }
.fm-row-actions .btn-icon { width: 28px; height: 28px; opacity: 0; transition: opacity .1s; }
.fm-row:hover .fm-row-actions .btn-icon { opacity: 1; }

/* Dark mode file listing */
html[data-theme="dark"] .fm-toolbar { background: var(--surface-2); border-bottom-color: var(--border); }
html[data-theme="dark"] .fm-table thead th { background: var(--surface-2); border-bottom-color: var(--border); color: var(--text-4); }
html[data-theme="dark"] .fm-table .fm-row:hover { background: var(--surface-3); }
html[data-theme="dark"] .fm-table .fm-row td { border-bottom-color: var(--border); }
html[data-theme="dark"] .fm-name-text { color: var(--text-1); }
html[data-theme="dark"] .fm-icon-file { background: var(--surface-4); }
html[data-theme="dark"] .fm-type-badge { background: var(--surface-4); border-color: var(--border); color: var(--text-4); }
html[data-theme="dark"] .fm-action-btn { background: var(--surface-3); border-color: var(--border); color: var(--text-2); }
html[data-theme="dark"] .fm-action-btn:hover { border-color: var(--pri); color: var(--pri); background: var(--pri-tint); }

/* ── File listing cell fixes ── */
.fm-td-type  { width: 72px;  padding: 7px 10px 7px 8px !important; white-space: nowrap; }
.fm-td-size  { width: 80px;  padding: 7px 10px !important; white-space: nowrap; color: var(--text-3); font-size: 12px; }
.fm-td-date  { width: 150px; padding: 7px 10px !important; white-space: nowrap; color: var(--text-4); font-size: 12px; }
.fm-td-name  { padding: 6px 10px !important; }
.fm-td-actions { width: 96px; padding: 4px 8px !important; }

.fm-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .05em;
  white-space: nowrap;
}
.fm-badge-dir  { background: rgba(249,115,22,.12); color: var(--accent); }
.fm-badge-file { background: var(--surface-3); color: var(--text-3); border: 1px solid var(--border); }

.fm-row-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  color: var(--text-3); transition: all var(--t) var(--ease);
  opacity: 0;
}
.fm-row:hover .fm-row-btn { opacity: 1; }
.fm-row-btn:hover { background: var(--surface-3); color: var(--pri); text-decoration: none; }
.fm-row-btn .material-icons-round { font-size: 16px; }

.fm-date-time { color: var(--text-4); }

/* fm-toolbar dark */
html[data-theme="dark"] .fm-toolbar { background: var(--surface-2); border-color: var(--border); }
html[data-theme="dark"] .fm-badge-file { background: var(--surface-4); border-color: var(--border-2); color: var(--text-4); }
html[data-theme="dark"] .fm-row-btn:hover { background: var(--surface-4); color: var(--pri-light); }

/* Whiter content areas */
.cpfm-main { background: #ffffff; }
.fm-table-wrap { background: #ffffff; }
.fm-table tbody { background: #ffffff; }
.main-content { background: #f5f7fa; }
.md-tab-content { background: #ffffff; }

/* Hide redundant path bar — breadcrumb in content-toolbar is enough */
.fm-path-bar { display: none; }

/* MD content scrollbar */
.md-tab-content::-webkit-scrollbar { width: 6px; }
.md-tab-content::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
.md-tab-content::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
