/* ============================================
   MAP-RCS — Page Styles (Dashboard + All)
   ============================================ */

/* ---- Dashboard Layout ---- */
.app-layout { display: flex; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom, 0px); }

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar); border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 50;
  backdrop-filter: blur(20px);
  overflow: hidden;
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
}
.sidebar-header {
  padding: var(--space-lg); display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border-color); min-height: var(--header-height);
  flex-shrink: 0;
}
.sidebar-logo {
  display: flex; align-items: center; cursor: pointer;
  overflow: hidden; flex: 1; min-width: 0;
}
.sidebar-logo .logo-rcs--sm { height: 34px; max-width: 150px; }
.sidebar-nav {
  flex: 1; padding: var(--space-md); overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-section-label {
  margin: 14px 8px 6px;
}
.sidebar-section-label span {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-muted);
}

/* Nav icons — flat outline, no tile background (docs/BRAND-GUIDELINES.md) */
.nav-tile {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}
.nav-tile svg, .nav-icon { display: block; flex-shrink: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  border-radius: var(--radius-md); color: var(--text-secondary);
  font-size: var(--font-sm); font-weight: 500; cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  position: relative; border: 1px solid transparent;
  background: none; text-align: left; font-family: inherit;
}
.nav-item:hover {
  background: rgba(var(--slate-gray-rgb), 0.06);
  color: var(--text-primary);
}
.nav-item:hover .nav-tile {
  color: var(--primary);
}
.nav-item.active {
  background: rgba(var(--brand-rgb), 0.08);
  color: var(--nav-accent-text, var(--primary));
  border-color: transparent;
}
.nav-item.active .nav-tile {
  color: var(--nav-accent-text, var(--primary));
}
.nav-group.active > .nav-group-trigger .nav-tile {
  color: var(--primary);
}
.nav-label {
  flex: 1; min-width: 0;
  line-height: 1.35;
  white-space: normal;
  font-size: calc(var(--font-sm) - 0.5px);
}
.nav-pill {
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px;
  padding: 2px 6px; border-radius: var(--radius-full);
  background: rgba(var(--trust-blue-rgb), 0.08); color: var(--trust-blue);
  border: 1px solid rgba(var(--trust-blue-rgb), 0.18);
  flex-shrink: 0;
}
.nav-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}
.nav-group.open .nav-chevron { transform: rotate(180deg); }

.nav-group-trigger { margin-bottom: 0; }
.nav-sublist {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.28s cubic-bezier(0.4,0,0.2,1), opacity var(--transition-base);
  padding-left: 4px;
}
.nav-group.open .nav-sublist {
  max-height: 320px; opacity: 1; margin-bottom: 4px;
}
.nav-sub { padding: 6px 10px 6px 14px; font-size: calc(var(--font-sm) - 1px); }
.nav-sub .nav-label { font-size: calc(var(--font-sm) - 1px); }
.nav-sub .nav-tile { width: 28px !important; height: 28px !important; }

.sidebar-footer {
  padding: 12px 10px; border-top: 1px solid var(--border-color);
  background: var(--bg-glass); flex-shrink: 0;
  position: relative; z-index: 2;
}
.sidebar-user {
  position: relative; display: block;
}
.sidebar-user-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: var(--radius-md); cursor: pointer;
  border: none; background: none; color: inherit; font: inherit; text-align: left;
}
.sidebar-user-trigger:hover { background: rgba(255,255,255,0.05); }
.sidebar-user .dropdown-menu {
  top: auto; bottom: calc(100% + 8px); left: 0; right: 0; min-width: 0;
}
.sidebar-user-meta {
  flex: 1; min-width: 0; overflow: hidden;
}
.sidebar-user-name {
  font-size: var(--font-sm); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px; color: var(--text-secondary); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Sidebar collapse toggle */
.sidebar-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: var(--bg-glass); color: var(--text-primary); }

.sidebar.collapsed {
  width: 60px;
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-group-content { display: none; }
.sidebar.collapsed .nav-tile { justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar-logo { display: none; }

.main-area.sidebar-collapsed {
  margin-left: 60px;
}

/* Role banner dismiss */
.role-banner-dismiss {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  padding: 0 8px;
  opacity: 0.6;
}
.role-banner-dismiss:hover { opacity: 1; }

@media (max-width: 767px) {
  .sidebar-collapse-btn { display: none; }
  .sidebar.collapsed { width: var(--sidebar-width); }
  .main-area.sidebar-collapsed { margin-left: 0; }
}

/* ---- Main Content ---- */
.main-area {
  flex: 1; margin-left: var(--sidebar-width); min-height: 100vh;
  display: flex; flex-direction: column;
}
/* Practitioner shell overrides legacy sidebar margin */
.app-shell .main-area.shell-main-area {
  margin-left: var(--shell-rail-width, 72px);
}
.app-shell.app-shell--nav-open .main-area.shell-main-area {
  margin-left: calc(var(--shell-rail-width, 72px) + var(--shell-nav-drawer-width, 260px));
}
.main-content { flex: 1; padding: var(--space-md) var(--space-lg); max-width: 1440px; width: 100%; min-width: 0; }
.app-shell .main-content { max-width: min(1440px, 100%); }
.main-header {
  height: var(--header-height); padding: 0 var(--space-xl); display: flex;
  align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-color);
  background: rgba(10,14,39,0.8); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 40;
}
.header-left { display: flex; align-items: center; gap: var(--space-md); }
.header-actions { display: flex; align-items: center; gap: 8px; }
/* Header icon buttons — flat icons, light hover ring on control */
.header-btn {
  position: relative;
  overflow: visible;
}
.header-btn.btn-ghost::after {
  display: none;
}
.header-btn.btn-ghost:hover,
.header-btn.btn-ghost:focus-visible {
  background: rgba(var(--slate-gray-rgb), 0.08);
  border: none;
  box-shadow: none;
  color: var(--text-primary);
}
[data-theme="light"] .header-btn.btn-ghost:hover,
[data-theme="light"] .header-btn.btn-ghost:focus-visible {
  background: rgba(0, 0, 0, 0.05);
}
.sidebar .btn-ghost.btn-icon,
.shell-rail .btn-ghost.btn-icon {
  overflow: visible;
}
.sidebar .btn-ghost.btn-icon:hover,
.sidebar .btn-ghost.btn-icon:focus-visible,
.shell-rail .btn-ghost.btn-icon:hover,
.shell-rail .btn-ghost.btn-icon:focus-visible {
  background: rgba(var(--slate-gray-rgb), 0.08);
  border: none;
  box-shadow: none;
}
.header-btn-notif {
  position: relative;
  overflow: visible;
}
.header-btn-notif .icon,
.header-btn-notif svg {
  position: relative;
  z-index: 0;
}
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  transform: translate(42%, -42%);
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  background: var(--danger);
  color: white;
  border-radius: var(--radius-full);
  font-size: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--bg-primary);
  pointer-events: none;
  box-sizing: border-box;
  line-height: 1;
  z-index: 2;
  letter-spacing: -0.02em;
}
.notif-badge--wide {
  padding: 0 2px;
  font-size: 7px;
}
/* App footer */
.app-footer {
  padding: var(--space-md) var(--space-xl);
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-color);
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--font-xs); color: var(--text-muted);
}
.header-title { font-size: var(--font-xl); font-weight: 700; }
.header-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: var(--font-sm); color: var(--text-muted); }
.header-breadcrumb .sep { opacity: 0.3; }
.header-right { display: flex; align-items: center; gap: var(--space-md); }
.header-search {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  background: var(--bg-glass); border: 1px solid var(--border-color);
  border-radius: var(--radius-full); color: var(--text-muted); font-size: var(--font-sm);
  cursor: pointer; transition: all var(--transition-fast); min-width: 200px;
}
.header-search:hover { border-color: var(--primary-light); }
.header-search kbd {
  margin-left: auto; padding: 2px 6px; background: rgba(255,255,255,0.08);
  border-radius: 4px; font-size: 10px; font-family: var(--font-family);
}
.notification-bell { position: relative; }
.notification-bell .dot {
  position: absolute; top: -2px; right: -2px; width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%; border: 2px solid var(--bg-primary);
}

/* ---- Page Content ---- */
.page-content { padding: var(--space-md) var(--space-lg); max-width: 1440px; }
.page-header { margin-bottom: var(--space-md); }
.page-title { font-size: var(--font-3xl); font-weight: 800; margin-bottom: 4px; font-family: var(--font-display); }
.page-desc { color: var(--text-muted); font-size: var(--font-sm); }

/* ---- Dashboard Stats Grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); margin-bottom: var(--space-md); }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: var(--space-lg); position: relative; overflow: hidden;
  transition: all var(--transition-base);
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--brand-gradient);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow-sm); }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: var(--space-md);
}
.stat-icon.purple { background: rgba(var(--brand-rgb),0.15); color: var(--primary-light); }
.stat-icon.cyan { background: rgba(var(--trust-blue-rgb), 0.15); color: var(--info); }
.stat-icon.green { background: rgba(46,133,85,0.15); color: var(--success); }
.stat-icon.orange { background: rgba(var(--brand-rgb), 0.15); color: var(--accent-orange); }
.stat-icon.red { background: rgba(185,28,28,0.15); color: var(--danger); }
.stat-value { font-size: var(--font-3xl); font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: var(--font-sm); color: var(--text-muted); font-family: var(--font-display); font-weight: 600; }
.stat-change { display: inline-flex; align-items: center; gap: 4px; font-size: var(--font-xs); font-weight: 600; margin-top: 8px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ---- Legacy Dashboard Grid (fixed-ratio presets; prefer components.css .dashboard-grid with inline --grid-cols) ---- */
.legacy-dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-md); margin-bottom: var(--space-md); }
.legacy-dashboard-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-md); margin-bottom: var(--space-md); }
.dashboard-full { margin-bottom: var(--space-md); }

/* ---- Chart Container ---- */
.chart-container { min-height: 250px; position: relative; display: flex; align-items: center; justify-content: center; }

/* ---- Compliance Table Page ---- */
.compliance-filters { display: flex; gap: var(--space-md); margin-bottom: var(--space-lg); flex-wrap: wrap; align-items: center; }
.filter-select {
  padding: 8px 14px; background: var(--bg-glass); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); color: var(--text-secondary); font-size: var(--font-sm);
  cursor: pointer; appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23ffffff60' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.filter-select option { background: var(--bg-secondary); }
.compliance-item {
  display: grid; grid-template-columns: 40px 2fr 1fr 1fr 120px 100px; align-items: center; gap: var(--space-md);
  padding: var(--space-md); border-bottom: 1px solid var(--border-color); transition: background var(--transition-fast);
}
.compliance-item:hover { background: rgba(255,255,255,0.02); }

/* ---- Library ---- */
.library-grid { display: grid; grid-template-columns: 300px 1fr; gap: var(--space-xl); }
.tree-node { padding: 8px 12px; cursor: pointer; border-radius: var(--radius-sm); transition: all var(--transition-fast); font-size: var(--font-sm); }
.tree-node:hover { background: rgba(var(--brand-rgb),0.1); }
.tree-node.active { background: rgba(var(--brand-rgb),0.15); color: var(--primary-light); }
.tree-children { padding-left: 20px; border-left: 1px solid var(--border-color); margin-left: 12px; }

/* ---- Sidebar Nav Groups ---- */
.nav-group { border-radius: var(--radius-md); }
.nav-group + .sidebar-section-label { margin-top: 4px; }

/* lib-tab alias for Pustaka tab buttons */
.lib-tab { display: flex; align-items: center; }


/* ---- AI Chat ---- */
.ai-chat-layout { display: grid; grid-template-columns: 1fr 340px; gap: var(--space-xl); height: calc(100vh - var(--header-height) - 2 * var(--space-xl)); }
.chat-container { display: flex; flex-direction: column; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-glow-sm); }
.chat-messages { flex: 1; overflow-y: auto; padding: var(--space-2xl) var(--space-xl); display: flex; flex-direction: column; gap: var(--space-xl); scroll-behavior: smooth; }
.chat-msg {
  display: flex; gap: 16px; max-width: 85%; animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg .msg-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.chat-msg.ai .msg-avatar { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; }
.chat-msg.user .msg-avatar { background: var(--bg-glass); border: 1px solid var(--border-color); }
.msg-bubble {
  font-size: 14.5px;
  line-height: 1.7; color: var(--text-primary);
}
/* User Bubble (Solid, modern look like ChatGPT/Claude) */
.chat-msg.user .msg-bubble { 
  background: var(--bg-card); border: 1px solid var(--border-color);
  padding: 14px 20px; border-radius: 20px; border-top-right-radius: 4px;
}
/* AI Bubble (Frameless, clean typography like Claude/Gemini) */
.chat-msg.ai .msg-bubble { 
  background: transparent; padding: 4px 0; max-width: 100%;
}

/* Markdown Typographic Rules for AI Bubble */
.markdown-body { font-family: var(--font-family); color: var(--text-primary); }
.markdown-body p { margin-bottom: 1em; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body strong { font-weight: 700; color: var(--text-primary); }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  font-weight: 700; margin-top: 1.5em; margin-bottom: 0.5em; color: var(--text-primary); line-height: 1.3;
}
.markdown-body h3 { font-size: 1.15em; }
.markdown-body ul, .markdown-body ol { margin-bottom: 1em; padding-left: 1.5em; }
.markdown-body li { margin-bottom: 0.4em; }
.markdown-body code { background: rgba(var(--brand-rgb),0.1); color: var(--primary-light); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 0.9em; }

.chat-input-area { padding: var(--space-lg); background: var(--bg-card); display: flex; gap: var(--space-md); align-items: flex-end; position: relative; border-top: 1px solid var(--border-color); }
.chat-input {
  flex: 1; padding: 16px 20px; background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: 24px; color: var(--text-primary); font-size: var(--font-sm); resize: none;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); transition: all 0.2s; max-height: 120px;
}
.chat-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(var(--brand-rgb),0.15); }
.chat-send-btn {
  width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--text-primary); color: var(--bg-primary); font-size: 20px;
  transition: transform var(--transition-fast), background 0.2s; flex-shrink: 0;
  margin-bottom: 2px;
}
.chat-send-btn:hover { transform: scale(1.05); background: var(--primary-light); color: white; }

/* ---- AI Sidebar ---- */
.ai-sidebar { display: flex; flex-direction: column; gap: var(--space-md); }
.ai-feature-card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: var(--space-md); cursor: pointer; transition: all var(--transition-fast);
}
.ai-feature-card:hover { border-color: var(--primary-light); transform: translateY(-2px); }
.ai-feature-icon { font-size: 24px; margin-bottom: 8px; }
.ai-feature-title { font-size: var(--font-sm); font-weight: 600; margin-bottom: 4px; }
.ai-feature-desc { font-size: var(--font-xs); color: var(--text-muted); }

/* ---- Notification List ---- */
.notif-item {
  display: flex; gap: var(--space-md); padding: var(--space-md); border-bottom: 1px solid var(--border-color);
  cursor: pointer; transition: background var(--transition-fast);
}
.notif-item:hover { background: rgba(255,255,255,0.02); }
.notif-item.unread { background: rgba(var(--brand-rgb),0.05); }
.notif-item.unread::before {
  content: ''; width: 4px; background: var(--primary); border-radius: 2px; flex-shrink: 0;
}
.notif-icon {
  width: auto; height: auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  background: none; border: none; border-radius: 0;
}
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: var(--font-sm); font-weight: 600; margin-bottom: 2px; }
.notif-desc { font-size: var(--font-xs); color: var(--text-muted); }
.notif-time { font-size: var(--font-xs); color: var(--text-muted); white-space: nowrap; }

/* ---- Search Page ---- */
.search-hero { text-align: center; padding: var(--space-3xl) 0; }
.search-bar-lg {
  max-width: 700px; margin: var(--space-xl) auto 0; display: flex; gap: var(--space-sm);
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-xl);
  padding: 8px; transition: border-color var(--transition-fast);
}
.search-bar-lg:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--brand-rgb),0.2); }
.search-bar-lg input { flex: 1; padding: 12px 20px; background: transparent; border: none; color: var(--text-primary); font-size: var(--font-lg); }
.search-bar-lg input::placeholder { color: var(--text-muted); }

/* ---- Reports ---- */
.report-card { cursor: pointer; }
.report-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-glow-sm); }
.report-preview { height: 160px; background: var(--bg-glass); border-radius: var(--radius-md); margin-bottom: var(--space-md); display: flex; align-items: center; justify-content: center; font-size: 48px; opacity: 0.3; }

/* ---- Admin ---- */
.admin-grid { display: grid; grid-template-columns: 240px 1fr; gap: var(--space-xl); }
.admin-nav .nav-item { margin-bottom: 4px; }
.admin-section { animation: fadeIn 0.3s ease; }

/* ---- Responsive ---- */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .legacy-dashboard-grid { grid-template-columns: 1fr; }
  .legacy-dashboard-grid-3 { grid-template-columns: 1fr 1fr; }
  .ai-chat-layout { grid-template-columns: 1fr; }
  .ai-sidebar { display: none; }
  .library-grid { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); position: fixed; z-index: 999; width: var(--sidebar-width); }
  .sidebar.open { transform: translateX(0); }
  /* Sidebar drawer overlay — blocks interaction with main content when drawer is open */
  .sidebar.open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: -1;
    pointer-events: auto;
    animation: fadeIn 0.2s ease;
  }
  [data-theme="light"] .sidebar.open::before {
    background: rgba(0, 0, 0, 0.25);
  }
  /* Prevent interaction with main content when sidebar drawer is open */
  .sidebar.open ~ .main-area {
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .nav-group.open .nav-sublist { max-height: 320px; opacity: 1; display: block; }
  .main-area,
  .app-shell .main-area.shell-main-area,
  .app-shell.app-shell--nav-open .main-area.shell-main-area {
    margin-left: 0 !important;
  }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-xs); }
  .stat-card { padding: var(--space-sm); }
  .main-content { padding: var(--space-sm) var(--space-md); }
  .page-content { padding: var(--space-sm) var(--space-md); }
  .page-desc { max-width: 100%; }
  .page-header { margin-bottom: var(--space-sm); }
  .compliance-item { grid-template-columns: 1fr; }
}
/* Breadcrumbs */
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-lg); font-size: var(--font-xs); color: var(--text-muted); }
.bc-sep { opacity: 0.4; user-select: none; }
.bc-link { color: var(--text-muted); text-decoration: none; transition: color var(--transition-fast); }
.bc-link:hover { color: var(--primary-light); text-decoration: underline; }
.bc-item.active { color: var(--text-secondary); font-weight: 600; }
@media (max-width: 767px) {
  .breadcrumbs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .breadcrumbs::-webkit-scrollbar { display: none; }
}

@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height, 56px);
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    z-index: 60;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  
  .bottom-nav a,
  .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 8px;
    border: none;
    background: none;
    cursor: pointer;
  }
  
  .bottom-nav a.active,
  .bottom-nav button.active {
    color: var(--accent-primary);
  }
  
  .main-content {
    padding-bottom: calc(var(--bottom-nav-height, 56px) + env(safe-area-inset-bottom, 0px) + var(--space-md));
  }
}
/* Nav group labels */
.nav-group { margin-bottom: var(--space-md); }
.nav-group-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); padding: 0 12px; margin-bottom: 4px; }
/* Stat trend */
.stat-trend { display: inline-flex; align-items: center; gap: 4px; font-size: var(--font-xs); font-weight: 600; margin-top: 8px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ---- Settings Page ---- */
.settings-layout { display: grid; grid-template-columns: 240px 1fr; gap: var(--space-xl); }
.settings-nav-item {
  padding: 10px 12px; border-radius: var(--radius-md); font-size: var(--font-sm);
  color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; gap: 10px;
  transition: all var(--transition-fast); margin-bottom: 4px;
}
.settings-nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.settings-nav-item.active { background: rgba(var(--brand-rgb),0.1); color: var(--primary-light); font-weight: 600; }
.settings-division-form__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
}
.settings-division-empty {
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-sm);
}
@media (max-width: 768px) {
  .settings-division-form__grid { grid-template-columns: 1fr; }
}
.deploy-options { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); margin-bottom: var(--space-xl); }
.deploy-option {
  padding: var(--space-md); border: 2px solid var(--border-color); border-radius: var(--radius-md);
  cursor: pointer; transition: all var(--transition-fast); background: var(--bg-card);
}
.deploy-option:hover { border-color: rgba(var(--brand-rgb),0.5); }
.deploy-option.selected { border-color: var(--primary); background: rgba(var(--brand-rgb),0.05); }
.deploy-radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--text-muted); position: relative; }
.deploy-radio.checked { border-color: var(--primary); }
.deploy-radio.checked::after { content: ''; position: absolute; top: 4px; left: 4px; width: 8px; height: 8px; background: var(--primary); border-radius: 50%; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--border-color); transition: .4s; border-radius: 24px; }
.toggle-slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .toggle-slider { background-color: var(--primary); }
input:checked + .toggle-slider:before { transform: translateX(20px); }
@media (max-width: 768px) {
  .settings-layout { grid-template-columns: 1fr; }
  .deploy-options { grid-template-columns: 1fr; }
}


/* ---- AI Assistant full-page (workspace) ---- */
.ai-chat-layout.ai-chat-layout--workspace {
  --ai-chat-column: min(760px, 100%);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.ai-chat-canvas {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(var(--brand-rgb), 0.06), transparent 55%),
    var(--bg-primary);
}

.ai-chat-page-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: min(100%, 920px);
  max-width: 920px;
  margin: 0 auto;
  padding: 0 12px 16px;
}

.ai-chat-page-panel .fcp-header-wrapper {
  flex-shrink: 0;
}

.ai-chat-page-panel .fcp-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.ai-chat-page-panel .fcp-messages {
  flex: 1;
  min-height: 0;
  width: min(100%, var(--ai-chat-column));
  max-width: var(--ai-chat-column);
  margin: 0 auto;
  padding: 8px 4px 24px;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.ai-chat-page-panel .fcp-history {
  width: min(100%, var(--ai-chat-column));
  max-width: var(--ai-chat-column);
  margin: 0 auto;
}

.ai-chat-page-panel .chat-msg,
.ai-chat-page-panel .msg-bubble,
.ai-chat-page-panel .markdown-body {
  max-width: 100%;
  overflow-x: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ai-chat-page-compose {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
  padding: 8px 0 4px;
  background: linear-gradient(to top, var(--bg-primary) 70%, transparent);
}

.ai-chat-page-panel .markdown-body pre,
.ai-chat-page-panel .markdown-body table {
  max-width: 100%;
  overflow-x: auto;
}

.ai-chat-page-panel .fcp-followup {
  width: min(100%, var(--ai-chat-column));
  max-width: var(--ai-chat-column);
  margin: 0 auto;
  padding: 0 4px 12px;
}
