/* =============================================
   NavDocs - Main Stylesheet
   ============================================= */

/* CSS Custom Properties */
:root {
  --color-bg: #f4f5f7;
  --color-white: #ffffff;
  --color-sidebar-bg: #1a1b1e;
  --color-sidebar-hover: rgba(255,255,255,0.04);
  --color-sidebar-active: #252629;
  --color-sidebar-text: #bfc2c8;
  --color-sidebar-muted: #484c55;
  --color-topbar-bg: #111214;
  --color-topbar-text: #c8cad0;
  --color-brand: #4a8fd4;
  --color-link: #4b7bbe;
  --color-link-hover: #3a6090;
  --color-border: #dde0e8;
  --color-border-light: #eaecf2;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-text-subtle: #9ca3af;
  --color-primary: #4b7bbe;
  --color-primary-hover: #3a6090;
  --color-danger: #dc3545;
  --color-danger-hover: #b02a37;
  --color-warning: #e67e22;
  --color-success: #27ae60;
  --color-muted-bg: #f8f9fb;
  --color-table-head: #f0f2f7;
  --color-table-row-hover: #f5f7fc;
  --color-table-border: #e2e5ed;
  --sidebar-width: 192px;
  --topbar-height: 44px;
  --radius: 4px;
  --radius-sm: 3px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 2px 8px rgba(0,0,0,.10);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --transition: all 0.15s ease;
}

[data-theme="dark"] {
  --color-bg: #111827;
  --color-white: #1e2535;
  --color-sidebar-bg: #16171a;
  --color-border: #2d3748;
  --color-border-light: #252f40;
  --color-text: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-muted-bg: #1a2233;
  --color-table-head: #1a2233;
  --color-table-border: #2d3748;
  --color-table-row-hover: #1e2d42;
  --color-topbar-bg: #0e0f11;
  --color-link: #7fb3e8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 13px; }
body { font-family: var(--font); color: var(--color-text); background: var(--color-bg); line-height: 1.5; }
a { color: var(--color-link); text-decoration: none; }
a:hover { color: var(--color-link-hover); text-decoration: underline; }

/* ---- LAYOUT ---- */
.app-body { overflow-x: hidden; }
.app-layout { display: flex; min-height: calc(100vh - var(--topbar-height)); }
.main-content { flex: 1; padding: 20px 24px; overflow-x: auto; min-width: 0; margin-top: var(--topbar-height); }
.main-content-full { padding: 24px 32px; }

/* ---- TOPBAR ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-height);
  background: var(--color-topbar-bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.topbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.topbar-brand {
  display: flex;
  align-items: center;
  width: clamp(128px, 16vw, 208px);
  height: calc(var(--topbar-height) - 12px);
  flex: 0 0 auto;
  text-decoration: none;
}
.topbar-brand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-nav { display: flex; align-items: center; gap: 2px; min-width: 0; }
.topbar-link {
  color: var(--color-topbar-text); font-size: 12px; padding: 5px 10px; border-radius: var(--radius);
  text-decoration: none; transition: var(--transition);
}
.topbar-link:hover, .topbar-link.active { background: rgba(255,255,255,0.1); color: #fff; text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-search { display: flex; align-items: center; }
.mobile-search-toggle { display: none; font-size: 16px; }

/* Mobile full-width search bar - position:fixed below topbar, animated slide-down */
.mobile-search-bar {
  background: var(--color-topbar-bg, #1e293b);
  border-bottom: 1px solid rgba(255,255,255,0.10);
  padding: 8px 12px;
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  z-index: 99;
  box-shadow: 0 4px 12px rgba(0,0,0,.28);
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.15s ease;
}
.mobile-search-bar.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.mobile-search-form { display: flex; align-items: center; gap: 6px; width: 100%; }
.mobile-search-input {
  flex: 1; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18);
  color: #fff; border-radius: var(--radius); padding: 7px 12px; font-size: 14px;
  outline: none; width: 100%;
}
.mobile-search-input::placeholder { color: rgba(255,255,255,0.45); }
.mobile-search-input:focus { background: rgba(255,255,255,0.15); border-color: var(--color-brand); }
.mobile-search-clear {
  background: none; border: none; color: rgba(255,255,255,0.45); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 2px 4px; flex-shrink: 0;
  display: none; transition: color 0.12s ease;
}
.mobile-search-clear:hover { color: rgba(255,255,255,0.85); }
.mobile-search-clear.visible { display: block; }
.mobile-search-submit {
  background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer;
  font-size: 16px; padding: 4px 6px; flex-shrink: 0;
}
.topbar-search-input {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; border-radius: var(--radius); padding: 4px 10px; font-size: 12px;
  width: 200px; outline: none;
}
.topbar-search-input::placeholder { color: rgba(255,255,255,0.4); }
.topbar-search-input:focus { background: rgba(255,255,255,0.15); border-color: var(--color-brand); }
.topbar-icon-btn {
  background: none; border: none; color: var(--color-topbar-text);
  cursor: pointer; padding: 5px 8px; border-radius: var(--radius);
  font-size: 13px; transition: var(--transition);
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.user-btn { width: 28px; height: 28px; border-radius: 50%; background: var(--color-brand); color: #fff; font-weight: 600; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.topbar-user-menu { position: relative; }
.user-dropdown {
  display: none; position: absolute; right: 0; top: 34px;
  background: var(--color-white); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 160px; z-index: 999;
  padding: 8px 0;
}
.topbar-user-menu:hover .user-dropdown { display: block; }
.user-dropdown-name { padding: 6px 14px 2px; font-weight: 600; font-size: 12px; color: var(--color-text); }
.user-dropdown-role { padding: 0 14px 6px; font-size: 11px; color: var(--color-text-muted); }
.user-dropdown hr { border: none; border-top: 1px solid var(--color-border-light); margin: 4px 0; }
.user-dropdown-item { display: block; padding: 6px 14px; font-size: 12px; color: var(--color-text-muted); text-decoration: none; }
.user-dropdown-item:hover { background: var(--color-muted-bg); color: var(--color-primary); }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  border-right: 1px solid rgba(0,0,0,0.2);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.main-content { margin-left: var(--sidebar-width); }

.sidebar-broker {
  padding: 10px 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-broker-back {
  font-size: 10px; color: var(--color-sidebar-muted); text-decoration: none;
  display: inline-flex; align-items: center; gap: 3px; margin-bottom: 5px;
  letter-spacing: 0.01em;
}
.sidebar-broker-back:hover { color: var(--color-sidebar-text); text-decoration: none; }
.sidebar-broker-name {
  font-size: 11.5px; font-weight: 600; color: #e4e5e8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.sidebar-broker-logo {
  display: block; max-width: 100%; max-height: 36px; width: auto;
  object-fit: contain; border-radius: 4px; margin-top: 2px;
  filter: brightness(1.05);
}

.sidebar-nav { padding: 4px 0 20px; }
.sidebar-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--color-sidebar-muted); padding: 13px 10px 3px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; font-size: 11.5px; color: var(--color-sidebar-text);
  text-decoration: none; transition: background 0.1s ease, color 0.1s ease;
  line-height: 1.35; white-space: nowrap; overflow: hidden;
}
.sidebar-item:hover {
  background: var(--color-sidebar-hover); color: #d8dadf; text-decoration: none;
}
.sidebar-item.active {
  background: var(--color-sidebar-active); color: #e8eaee;
}
.sidebar-item.active .sidebar-icon { opacity: 1; }
.sidebar-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; flex-shrink: 0; opacity: 0.65;
}
.sidebar-icon svg {
  width: 14px; height: 14px;
  stroke: currentColor; stroke-width: 1.75; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.sidebar-item.active .sidebar-icon,
.sidebar-item:hover .sidebar-icon { opacity: 0.9; }
.sidebar-badge {
  margin-left: auto; flex-shrink: 0;
  font-size: 10px; font-variant-numeric: tabular-nums;
  color: var(--color-sidebar-muted);
  min-width: 16px; text-align: right;
}

/* ---- FLASH MESSAGES ---- */
.flash-container { margin-bottom: 14px; }
.flash {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px; border-radius: var(--radius); font-size: 12px;
  margin-bottom: 6px; border: 1px solid transparent;
}
.flash-success { background: #d4edda; border-color: #c3e6cb; color: #155724; }
.flash-danger, .flash-error { background: #f8d7da; border-color: #f5c6cb; color: #721c24; }
.flash-warning { background: #fff3cd; border-color: #ffeeba; color: #856404; }
.flash-info { background: #d1ecf1; border-color: #bee5eb; color: #0c5460; }
.flash-close { background: none; border: none; cursor: pointer; font-size: 16px; color: inherit; opacity: 0.6; padding: 0; }
.flash-close:hover { opacity: 1; }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border-light);
}
.page-title { font-size: 20px; font-weight: 600; color: var(--color-text); line-height: 1.2; }
.page-subtitle { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---- BREADCRUMBS ---- */
.breadcrumbs { display: flex; align-items: center; gap: 4px; font-size: 11.5px; margin-bottom: 12px; }
.breadcrumbs-inline { font-size: 11.5px; color: var(--color-text-muted); }
.breadcrumbs-inline a { color: var(--color-text-muted); }
.breadcrumb-link { color: var(--color-link); }
.breadcrumb-sep { color: var(--color-text-subtle); }
.breadcrumb-current { color: var(--color-text-muted); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px 12px; border-radius: var(--radius);
  font-size: 12px; font-weight: 500; border: 1px solid transparent;
  cursor: pointer; transition: var(--transition); text-decoration: none;
  gap: 5px; line-height: 1.4; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: #fff; }
.btn-secondary { background: var(--color-white); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-muted-bg); color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-hover); color: #fff; }
.btn-warning { background: var(--color-warning); color: #fff; border-color: var(--color-warning); }
.btn-link { background: none; border: none; color: var(--color-link); padding: 5px 6px; }
.btn-sm { padding: 4px 10px; font-size: 11.5px; }
.btn-xs { padding: 2px 7px; font-size: 11px; border-radius: 3px; }
.btn-block { width: 100%; justify-content: center; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11.5px; font-weight: 500; color: var(--color-text); margin-bottom: 4px; }
.form-control {
  display: block; width: 100%; padding: 6px 9px;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  font-size: 12.5px; color: var(--color-text); background: var(--color-white);
  outline: none; transition: var(--transition); font-family: var(--font);
  line-height: 1.4;
}
.form-control:focus { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(75,123,190,0.15); }
.form-control::placeholder { color: var(--color-text-subtle); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-control-color { padding: 2px 4px; height: 34px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }
.form-group-grow { flex: 2 !important; }
.form-group-icon { flex: 0 0 80px !important; min-width: 80px !important; }
.form-group-color { flex: 0 0 80px !important; min-width: 80px !important; }
.form-check-group { display: flex; flex-direction: column; }
.form-check { display: flex; align-items: center; gap: 6px; }
.form-check-input { width: 14px; height: 14px; }
.form-check-label { font-size: 12px; }
.form-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--color-text-muted); margin: 20px 0 10px; padding-bottom: 5px; border-bottom: 1px solid var(--color-border-light); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--color-border-light); }
.required { color: var(--color-danger); }
.form-card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow-sm); }
.input-title { font-size: 17px !important; font-weight: 600 !important; }

/* ---- TABLES ---- */
.table-card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table thead tr { background: var(--color-table-head); }
.data-table th {
  padding: 8px 12px; text-align: left; font-size: 11px;
  font-weight: 600; color: var(--color-text-muted); border-bottom: 1px solid var(--color-table-border);
  white-space: nowrap; text-transform: uppercase; letter-spacing: 0.04em;
}
.data-table td { padding: 7px 12px; border-bottom: 1px solid var(--color-border-light); vertical-align: middle; color: var(--color-text); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--color-table-row-hover); }
.td-bold { font-weight: 500; }
.td-mono { font-family: var(--font-mono); font-size: 11.5px; }
.td-empty { text-align: center; color: var(--color-text-muted); padding: 20px; }
.td-actions { display: flex; gap: 5px; align-items: center; flex-wrap: nowrap; }
.td-actions { white-space: nowrap; }
.row-inactive { opacity: 0.6; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 10px; font-size: 10.5px; font-weight: 600;
  white-space: nowrap; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-xs { font-size: 9.5px; padding: 1px 5px; border-radius: 8px; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-muted { background: #e8eaf0; color: #555; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-role-admin { background: #e2d9ff; color: #5a3dbd; }
.badge-role-read_write { background: #d1ecf1; color: #0c5460; }
.badge-role-read_only { background: #e8eaf0; color: #555; }
.badge-status-active { background: #d4edda; color: #155724; }
.badge-status-inactive { background: #fff3cd; color: #856404; }
.badge-status-retired, .badge-status-decommissioned { background: #f8d7da; color: #721c24; }
.badge-status-pending { background: #d1ecf1; color: #0c5460; }
.badge-doc-published { background: #d4edda; color: #155724; }
.badge-doc-draft { background: #fff3cd; color: #856404; }
.badge-doc-archived { background: #e8eaf0; color: #555; }

/* ---- TOOLBAR ---- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-form { display: flex; align-items: center; gap: 8px; }
.toolbar-search { width: 260px; }
.import-panel { background: var(--color-muted-bg); border: 1px solid var(--color-border); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.btn-group-more { display: flex; gap: 6px; }

/* ---- DASHBOARD ---- */
.dashboard-page { padding-top: 4px; }
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.dashboard-title { font-size: 22px; font-weight: 600; }
.broker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.broker-card {
  background: var(--color-white); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column;
  gap: 0; text-decoration: none; color: var(--color-text);
  transition: var(--transition); box-shadow: var(--shadow-sm);
}
.broker-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow); transform: translateY(-1px); text-decoration: none; color: var(--color-text); }
.broker-bubble { width: 44px; height: 44px; border-radius: 10px; border: 1px solid; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.broker-icon { font-size: 24px; }
.broker-card-name { font-size: 14px; font-weight: 600; margin-top: 8px; }
.broker-card-desc { font-size: 11.5px; color: var(--color-text-muted); margin-top: 4px; line-height: 1.4; }
.broker-card-tuckins { margin-top: 7px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.broker-card-tuckins li { font-size: 11px; color: var(--color-text-muted); display: flex; align-items: baseline; gap: 5px; }
.broker-card-tuckins li::before { content: '·'; color: var(--color-text-subtle); flex-shrink: 0; }
.broker-card-onsite { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.broker-card-onsite-row { font-size: 10.5px; color: var(--color-text-muted); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.broker-card-onsite-more { font-size: 10px; color: var(--color-text-subtle); font-style: italic; }
.broker-card-stats { display: flex; gap: 10px; font-size: 11px; color: var(--color-text-muted); margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--color-border-light); }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }
.empty-icon { font-size: 36px; margin-bottom: 10px; }

/* ---- DETAIL LAYOUT ---- */
.detail-layout { display: flex; gap: 20px; }
.detail-main { flex: 1; min-width: 0; }
.detail-rail { width: 240px; flex-shrink: 0; }
.detail-section { margin-bottom: 20px; background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.detail-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--color-text-muted); margin-bottom: 10px; }
.detail-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tuckin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 900px) {
  .tuckin-grid { grid-template-columns: 1fr; }
}
.tuckin-grid .detail-section { margin-bottom: 0; }
.tuckin-overview-section { border-top: 2px solid var(--color-primary); }
.tuckin-overview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tuckin-overview-header .detail-section-title { margin-bottom: 0; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.field-item { display: flex; flex-direction: column; gap: 2px; }
.field-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
.notes-block { font-size: 12.5px; white-space: pre-wrap; color: var(--color-text); background: var(--color-muted-bg); padding: 10px; border-radius: var(--radius); }
.mono { font-family: var(--font-mono); font-size: 12px; }

/* ---- RIGHT RAIL ---- */
.rail-section { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.rail-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--color-text-muted); margin-bottom: 10px; }
.rail-field { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 7px; gap: 8px; }
.rail-label { font-size: 11px; color: var(--color-text-muted); flex-shrink: 0; }
.rail-value { font-size: 11.5px; text-align: right; word-break: break-all; }
.rail-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.rail-stat { text-align: center; }
.rail-stat a { font-size: 16px; font-weight: 700; display: block; color: var(--color-primary); }
.rail-stat span { font-size: 10px; color: var(--color-text-muted); display: block; }
.onsite-entry { padding: 4px 0; }
.onsite-name { font-size: 12.5px; font-weight: 600; color: var(--color-text); }
.onsite-role { font-size: 11.5px; color: var(--color-text-muted); margin-top: 1px; }
.onsite-location { font-size: 11.5px; color: var(--color-text-muted); margin-top: 1px; }
.onsite-location a { color: var(--color-primary); text-decoration: none; }
.onsite-location a:hover { text-decoration: underline; }
.onsite-divider { border: none; border-top: 1px solid var(--color-border); margin: 6px 0; }
.rail-actions { margin-top: 12px; }
.rail-related-item { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; }
.rail-badge { font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 5px; border-radius: 3px; background: var(--color-primary); color: #fff; flex-shrink: 0; }
.rail-related-label { color: var(--color-text-secondary); font-size: 12px; word-break: break-word; }
.rail-empty { font-size: 11px; color: var(--color-text-muted); margin: 0; font-style: italic; }
.rail-meta-row { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 5px; color: var(--color-text-muted); }
.rail-meta-row span:last-child { color: var(--color-text-primary); font-weight: 500; }

/* ---- REVISIONS ---- */
.revision-item { padding: 6px 0; border-bottom: 1px solid var(--color-border-light); }
.revision-item:last-child { border-bottom: none; }
.revision-ver { font-weight: 600; font-size: 11px; color: var(--color-primary); }
.revision-meta, .revision-date { font-size: 10.5px; color: var(--color-text-muted); }

/* ---- ADMIN ---- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 20px; }
.admin-card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow-sm); }
.admin-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.admin-card-header h3 { font-size: 14px; font-weight: 600; }
.admin-card-actions { margin-top: 12px; }

/* ---- SECTION CARD ---- */
.section-card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.section-card-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--color-border-light); }
.section-card-header h3 { font-size: 13px; font-weight: 600; }
.link-muted { font-size: 11.5px; color: var(--color-text-muted); }
.mt-6 { margin-top: 20px; }
.mt-4 { margin-top: 14px; }

/* ---- LOGIN (split panel) ---- */
.login-body {
  background: #0c0d10;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
}

.login-split {
  display: flex;
  width: 860px;
  min-height: 540px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
}

/* Left branding panel */
.login-panel-left {
  flex: 0 0 360px;
  background: #111214;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 44px 40px 32px;
  overflow: hidden;
}
.login-panel-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
.login-panel-glow {
  position: absolute;
  top: -80px;
  left: -60px;
  /* width: 340px; */
  width: 450px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(75,123,190,0.22) 0%, transparent 70%);
  pointer-events: none;
}
.login-panel-content {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.login-logomark {
  width: min(280px, 100%);
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 24px;
}
.login-logomark img {
  width: 100%;
  height: auto;
  max-height: 66px;
  object-fit: contain;
  object-position: left center;
}
.login-brand-name {
  font-size: 22px;
  font-weight: 700;
  color: #e8eaee;
  letter-spacing: 0.2px;
  margin-bottom: 6px;
}
.login-brand-tagline {
  font-size: 12px;
  color: #5a6070;
  margin-bottom: 36px;
  line-height: 1.4;
}
.login-feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #7a8090;
  line-height: 1.3;
}
.login-feature-list svg {
  flex-shrink: 0;
  color: #4b7bbe;
  opacity: 0.9;
}
.login-panel-footer {
  position: relative;
  font-size: 10px;
  color: #333840;
  margin-top: 32px;
  letter-spacing: 0.3px;
}

/* Right form panel */
.login-panel-right {
  flex: 1;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 44px;
}
.login-form-wrap {
  width: 100%;
  max-width: 320px;
}
.login-form-header {
  margin-bottom: 28px;
}
.login-welcome {
  font-size: 22px;
  font-weight: 700;
  color: #111214;
  margin-bottom: 5px;
}
.login-welcome-sub {
  font-size: 13px;
  color: #7a8494;
}

/* Form fields */
.lf-group {
  margin-bottom: 18px;
}
.lf-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 7px;
  letter-spacing: 0.1px;
}
.lf-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.lf-icon {
  position: absolute;
  left: 12px;
  color: #9ca3af;
  pointer-events: none;
  flex-shrink: 0;
}
.lf-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  font-size: 13px;
  font-family: var(--font);
  color: #111214;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  box-sizing: border-box;
}
.lf-input:focus {
  border-color: #4b7bbe;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(75,123,190,0.12);
}
.lf-input::placeholder { color: #c1c8d4; }
.lf-pw-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color 0.15s;
}
.lf-pw-toggle:hover { color: #4b7bbe; }

/* Remember me */
.lf-remember {
  margin-bottom: 22px;
}
.lf-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: #5a6370;
  user-select: none;
}
.lf-check-input {
  display: none;
}
.lf-check-box {
  width: 16px;
  height: 16px;
  border: 1.5px solid #d1d5db;
  border-radius: 4px;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.lf-check-input:checked + .lf-check-box {
  background: #4b7bbe;
  border-color: #4b7bbe;
}
.lf-check-input:checked + .lf-check-box::after {
  content: '';
  display: block;
  width: 8px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

/* Submit */
.lf-submit {
  width: 100%;
  padding: 11px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  color: #fff;
  background: linear-gradient(135deg, #4b7bbe 0%, #3a6090 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.2px;
  transition: opacity 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 2px 12px rgba(75,123,190,0.35);
}
.lf-submit:hover {
  opacity: 0.92;
  box-shadow: 0 4px 18px rgba(75,123,190,0.5);
  transform: translateY(-1px);
}
.lf-submit:active { transform: translateY(0); opacity: 1; }

/* Demo hint */
.login-demo-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 24px;
  padding: 12px 14px;
  background: #f4f5f7;
  border-radius: 8px;
  border: 1px solid #e9eaec;
}
.login-demo-badge {
  flex-shrink: 0;
  background: #e8f0fb;
  color: #4b7bbe;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  margin-top: 1px;
}
.login-demo-accounts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.login-demo-accounts span {
  font-size: 11px;
  color: #6b7280;
  font-family: 'SFMono-Regular', Consolas, monospace;
}

/* Responsive: stack on small screens */
@media (max-width: 680px) {
  .login-split { flex-direction: column; width: 94vw; min-height: unset; }
  .login-panel-left { flex: none; padding: 32px 28px 24px; }
  .login-feature-list { display: none; }
  .login-panel-right { padding: 32px 28px; }
}

/* ---- RICH CONTENT ---- */
.rich-content { font-size: 13px; line-height: 1.65; background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px 20px; min-height: 80px; box-shadow: var(--shadow-sm); }
.rich-content h1 { font-size: 20px; font-weight: 700; margin: 20px 0 10px; border-bottom: 1px solid var(--color-border-light); padding-bottom: 6px; }
.rich-content h2 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; }
.rich-content h3 { font-size: 13.5px; font-weight: 600; margin: 12px 0 6px; }
.rich-content p { margin-bottom: 10px; }
.rich-content ul, .rich-content ol { margin-left: 20px; margin-bottom: 10px; }
.rich-content li { margin-bottom: 3px; }
.rich-content blockquote { border-left: 3px solid var(--color-primary); padding-left: 12px; color: var(--color-text-muted); font-style: italic; margin: 10px 0; }
.rich-content pre { background: #1e2535; color: #e2e8f0; padding: 12px; border-radius: var(--radius); overflow-x: auto; margin-bottom: 10px; font-family: var(--font-mono); font-size: 11.5px; }
.rich-content code { background: #f0f1f5; padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); font-size: 11.5px; }
.rich-content pre code { background: none; padding: 0; }
.rich-content table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.rich-content th { background: var(--color-table-head); padding: 7px 10px; text-align: left; font-size: 11px; font-weight: 600; border: 1px solid var(--color-table-border); }
.rich-content td { padding: 6px 10px; border: 1px solid var(--color-table-border); }
.rich-content a { color: var(--color-link); }
.rich-content img { max-width: 100%; border-radius: var(--radius); }

/* ---- EDITOR ---- */
.editor-layout { display: flex; gap: 18px; align-items: flex-start; }
.editor-main { flex: 1; min-width: 0; }
.editor-rail { width: 240px; flex-shrink: 0; }
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 5px 8px; background: var(--color-muted-bg);
  border: 1px solid var(--color-border); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.editor-toolbar-btn {
  background: none; border: 1px solid transparent; border-radius: 3px;
  cursor: pointer; padding: 3px 7px; font-size: 12px; color: var(--color-text-muted);
  transition: var(--transition);
}
.editor-toolbar-btn:hover { background: var(--color-white); border-color: var(--color-border); color: var(--color-text); }
.editor-toolbar-btn.active { background: var(--color-white); border-color: var(--color-border); color: var(--color-primary); }
.richtext-editor {
  background: var(--color-white); border: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 14px 16px; outline: none; overflow-y: auto;
  font-size: 13px; line-height: 1.65; color: var(--color-text);
}
.richtext-editor:focus { border-color: var(--color-primary); }
.richtext-editor h1, .richtext-editor h2, .richtext-editor h3 { margin-top: 14px; margin-bottom: 6px; }
.richtext-editor p { margin-bottom: 8px; }
.richtext-editor ul, .richtext-editor ol { margin-left: 20px; margin-bottom: 8px; }
.richtext-editor code { background: #f0f1f5; padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); font-size: 11.5px; }
.richtext-editor pre { background: #1e2535; color: #e2e8f0; padding: 12px; border-radius: var(--radius); margin-bottom: 8px; font-family: var(--font-mono); font-size: 11.5px; }
.richtext-editor table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.richtext-editor th, .richtext-editor td { border: 1px solid var(--color-border); padding: 5px 8px; }
.richtext-editor th { background: var(--color-table-head); }

/* ---- DOCUMENTS ---- */
.doc-layout { display: flex; gap: 16px; }
.doc-tree { width: 200px; flex-shrink: 0; }
.doc-tree-header { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--color-text-muted); padding: 6px 10px 4px; }
.doc-tree-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px; font-size: 12px; color: var(--color-text-muted);
  border-radius: var(--radius); text-decoration: none; transition: var(--transition);
}
.doc-tree-item:hover { background: var(--color-muted-bg); color: var(--color-text); text-decoration: none; }
.doc-tree-item.active { background: #e9f0fb; color: var(--color-primary); font-weight: 500; }
.doc-tree-child { padding-left: 22px; }
.doc-tree-count { font-size: 10px; background: var(--color-border-light); padding: 0 5px; border-radius: 8px; }
.doc-main { flex: 1; min-width: 0; }
.folder-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.folder-card {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--color-white); border: 1px solid var(--color-border);
  border-radius: var(--radius); font-size: 12.5px; color: var(--color-text);
  text-decoration: none; transition: var(--transition);
}
.folder-card:hover { border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; }
.folder-count { font-size: 10px; color: var(--color-text-muted); margin-left: 4px; }
.doc-summary { font-size: 13px; color: var(--color-text-muted); padding: 10px 14px; background: var(--color-muted-bg); border-left: 3px solid var(--color-primary); border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 14px; }

/* ---- ATTACHMENTS ---- */
.attachment-list { display: flex; flex-direction: column; gap: 6px; }
.attachment-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--color-muted-bg); border-radius: var(--radius); border: 1px solid var(--color-border-light); }
.attachment-icon { font-size: 16px; flex-shrink: 0; }
.attachment-info { flex: 1; }
.attachment-name { font-size: 12px; font-weight: 500; }
.attachment-meta { font-size: 10.5px; color: var(--color-text-muted); }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- RELATED ITEMS ---- */
.related-list { display: flex; flex-direction: column; gap: 5px; }
.related-item { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 0; }
.related-item-reverse { opacity: 0.7; }
.related-badge { background: #e0eeff; color: var(--color-primary); padding: 1px 6px; border-radius: 4px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; }
.related-label { color: var(--color-text-muted); font-size: 11px; }

/* ---- SEARCH RESULTS ---- */
.search-results { display: flex; flex-direction: column; gap: 12px; }
.search-result-company {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.search-result-company-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.search-result-company-name { font-size: 13px; font-weight: 700; color: var(--color-text); }
.search-result-company-count { font-size: 11px; color: var(--color-text-muted); }
.search-result { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px 16px; }
.search-result:hover { border-color: var(--color-primary); }
.search-result-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.search-result-summary { font-size: 12px; color: var(--color-text-muted); margin-bottom: 5px; }
.search-result-summary b { color: var(--color-text); font-weight: 700; }
.search-result-meta { font-size: 11px; color: var(--color-text-subtle); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 20px; }
.page-info { font-size: 12px; color: var(--color-text-muted); }

/* ---- MISC ---- */
.text-muted { color: var(--color-text-muted); }
.text-muted-sm { font-size: 11.5px; color: var(--color-text-muted); }
.text-sm { font-size: 12px; }
.text-primary { color: var(--color-text-primary); }
.link-external { font-size: 11px; }
.mt-6 { margin-top: 22px; }

/* ---- HAMBURGER BUTTON ---- */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: var(--radius);
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.1); }
.hamburger-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--color-topbar-text);
  border-radius: 1px;
  transition: all 0.2s ease;
}

/* ---- MOBILE SIDEBAR BACKDROP ---- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 49;
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.active { display: block; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  /* Show hamburger on broker pages only */
  .hamburger-btn { display: flex; }
  .topbar { padding: 0 10px; }
  .topbar-left { gap: 10px; }
  .topbar-brand { width: clamp(104px, 32vw, 150px); height: calc(var(--topbar-height) - 16px); }
  /* Hide topbar nav only on broker (has-sidebar) pages - preserved on dashboard/admin */
  .has-sidebar .topbar-nav { display: none; }

  /* Sidebar becomes a fixed overlay */
  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: 220px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 200;
    box-shadow: 3px 0 16px rgba(0,0,0,0.35);
  }
  .sidebar.open { transform: translateX(0); }

  /* Main content full-width */
  .main-content { margin-left: 0; }

  /* Hamburger → X when open */
  body.sidebar-open .hamburger-bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  body.sidebar-open .hamburger-bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  body.sidebar-open .hamburger-bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* Stack detail/editor layouts */
  .detail-layout, .editor-layout { flex-direction: column; }
  .detail-rail, .editor-rail { width: 100%; }
}

/* ---- SITE PHOTOS ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.photo-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.photo-card-img-link { display: block; }
.photo-card-img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  background: var(--color-muted-bg);
  transition: opacity 0.15s ease;
}
.photo-card-img-link:hover .photo-card-img { opacity: 0.88; }
.photo-card-body {
  padding: 8px 10px 10px;
  flex: 1;
}
.photo-card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.photo-card-meta {
  font-size: 10.5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.photo-label-display {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}
.photo-label-display .photo-card-label { margin-bottom: 0; }
.btn-label-edit {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.photo-card:hover .btn-label-edit { opacity: 1; }
@media (hover: none) { .btn-label-edit { opacity: 0.6; } }
.form-control-sm {
  padding: 3px 7px;
  font-size: 12px;
  height: auto;
}

@media (max-width: 640px) {
  /* Replace topbar search input with icon toggle on mobile */
  .topbar-search { display: none; }
  .mobile-search-toggle { display: inline-flex; }
  .topbar-left { gap: 8px; }
  .topbar-brand { width: clamp(92px, 35vw, 132px); }
  .topbar-right { gap: 4px; }

  .form-row { flex-direction: column; }
  .page-header { flex-direction: column; gap: 10px; }
  .page-actions { width: 100%; }
  .doc-layout { flex-direction: column; }
  .doc-tree { width: 100%; }
  .main-content { padding: 14px 12px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}

/* ---- Inline-edit Modal ---- */
.inline-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.inline-modal-overlay.active {
  display: flex;
}
.inline-modal {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 24px 28px 20px;
  width: 100%;
  max-width: 640px;
  margin: 16px;
}
.inline-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.inline-modal-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.inline-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}
.inline-modal-close:hover { color: var(--color-text); background: var(--color-bg); }
