﻿* { box-sizing: border-box; }
:root {
  --bg: #0f172a;
  --surface: #111827;
  --panel: #0b1220;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --brand: #60a5fa;
  --accent: #22d3ee;
  --border: #1f2937;
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: linear-gradient(180deg, var(--bg), #050a14);
  overflow: hidden; /* prevent page scroll; inner panes will scroll */
}

.app { display: grid; grid-template-columns: 260px 1fr; height: 100vh; overflow: hidden; }

.sidebar {
  background: linear-gradient(180deg, #0a1222, #060b18);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  height: 100vh; /* fixed to viewport height */
}
.sidebar .brand {
  font-weight: 700;
  color: white;
  letter-spacing: .2px;
  margin: 6px 8px 14px 8px;
}
.sidebar nav { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidebar .bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar .nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  transition: background .2s, color .2s;
}
.sidebar .nav-item a:hover { background: #0f1a30; color: white; }
.sidebar .nav-item.active a { background: #0f1a30; color: var(--accent); }
/* Sidebar nav icons */
.sidebar .nav-item .nav-icon { width: 18px; height: 18px; flex: 0 0 18px; opacity: 0.9; filter: brightness(0) invert(1); }
.sidebar .nav-item a:hover .nav-icon, .sidebar .nav-item.active a .nav-icon { opacity: 1; }

.content {
  padding: 24px 28px;
}
.content h1 {
  margin-top: 0;
  font-size: 22px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  padding: 16px;
  border-radius: 12px;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.table th { color: var(--muted); font-weight: 600; }

.links { list-style: none; padding: 0; }
.links li { margin: 8px 0; }
.links a { color: var(--brand); text-decoration: none; }
.links a:hover { text-decoration: underline; }


/* Modern buttons */
.btn { appearance: none; border: 1px solid var(--border); background: #0b1326; color: var(--text); padding: 8px 12px; border-radius: 10px; cursor: pointer; transition: background .2s, color .2s, border-color .2s, transform .05s, box-shadow .2s; font-weight: 600; letter-spacing: .2px; }
.btn:hover { background: #101a33; border-color: #2a364d; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #2563eb, #1d4ed8); border-color: #1e40af; color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,0.25); }
.btn-primary:hover { background: linear-gradient(180deg, #1d4ed8, #1e40af); }
.btn-secondary { background: #0b1326; border-color: #2a364d; color: var(--text); }
.btn-outline { background: transparent; border-color: #2a364d; color: var(--text); }
.btn-danger { background: linear-gradient(180deg, #dc2626, #b91c1c); border-color: #991b1b; color: #fff; }
.btn-danger:hover { background: linear-gradient(180deg, #b91c1c, #991b1b); }
.nav-logout { display:flex; align-items:center; width:100%; border:0; background:transparent; color:inherit; font:inherit; cursor:pointer; padding:0; text-align:left; }

/* Form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* Avatar editor */
.avatar-editor { position: relative; width: 168px; height: 168px; border-radius: 50%; overflow: visible; border: 1px solid var(--border); background: #0b1326; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02); }
.avatar-editor img { width: 100%; height: 100%; object-fit: cover; display: none; border-radius: 50%; }
.avatar-editor .avatar-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #9fb3d1; font-size: 36px; letter-spacing: 1px; border-radius: 50%; }
.avatar-editor .avatar-edit-btn { position: absolute; right: 6px; bottom: 6px; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: rgba(255,255,255,0.7); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 6px; cursor: pointer; transition: transform .15s, background .2s, border-color .2s; z-index: 3; }
.avatar-editor .avatar-edit-btn:hover { background: rgba(255,255,255,0.85); border-color: #2a364d; transform: translateY(-1px); }
.avatar-editor .avatar-edit-btn img { width: 20px; height: 20px; filter: none; display: block; }

/* User form layout: avatar left, vertical divider, fields right */
.user-form-layout { display: grid; grid-template-columns: 208px 1px minmax(0, 1fr); column-gap: 20px; align-items: start; }
.user-form-layout .v-sep { width: 1px; background: var(--border); min-height: 100%; }
.stack-fields { display: flex; flex-direction: column; gap: 12px; }
.stack-fields label { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.stack-fields input, .stack-fields select { width: 100%; }
@media (max-width: 640px) {
  .user-form-layout { grid-template-columns: 1fr; row-gap: 16px; }
  .user-form-layout .v-sep { display: none; }
}


/* Modal readability tweaks: darker, slightly bluish headings and labels on white background */
.modal-card { color: #0f172a; }
.modal-header h3 { color: #1e3a8a; }
.modal-card .stack-fields label { color: #1f2a44; font-weight: 600; }

/* User tiles grid */
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 12px; }
.user-card { position: relative; background: #ffffff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 14px 16px; box-shadow: 0 4px 12px rgba(15,23,42,0.06); transition: transform .12s ease, box-shadow .2s ease, border-color .2s; }
.user-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,0.12); border-color: #cbd5e1; }
.user-card-main { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; background: radial-gradient(120px 80px at 30% 30%, #ffb476, #f97316); display: flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,0.06); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03); }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-avatar .init { font-weight: 800; color: #1f2937; font-size: 18px; letter-spacing: .5px; background: rgba(255,255,255,0.82); width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.user-info { min-width: 0; }
.user-name { font-weight: 700; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* Edit icon on tile */
.tile-edit-btn { position: absolute; right: 10px; bottom: 10px; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: rgba(255,255,255,0.7); display: flex; align-items: center; justify-content: center; padding: 4px; cursor: pointer; transition: transform .15s, background .2s, border-color .2s; }
.tile-edit-btn:hover { background: rgba(255,255,255,0.85); border-color: #2a364d; transform: translateY(-1px); }
.tile-edit-btn img { width: 18px; height: 18px; filter: none; display: block; }


/* Light theme for right-side workspace (pages) */
.content {
  padding: 24px 28px; /* keep existing padding */
  background: #f8fafc; /* light background */
  color: #0f172a; /* dark text for readability */
}
.content h1, .content h2, .content h3, .content h4 {
  color: #0f172a;
}

/* Cards inside content */
.content .card {
  background: #ffffff;
  border: 1px solid #e5e7eb; /* light border */
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* Tables inside content */
.content .table { background: transparent; }
.content .table th, .content .table td { border-bottom: 1px solid #e5e7eb; }
.content .table th { color: #475569; }

/* Links inside content */
.content a { color: #2563eb; }
.content a:hover { color: #1d4ed8; }

/* Buttons inside content: lighter defaults; keep .btn-primary as-is */
.content .btn {
  background: #ffffff;
  border-color: #e5e7eb;
  color: #0f172a;
}
.content .btn:hover { background: #f3f4f6; border-color: #cbd5e1; }
.content .btn-secondary { background: #ffffff; border-color: #e5e7eb; color: #0f172a; }
.content .btn-outline { background: transparent; border-color: #cbd5e1; color: #1f2937; }

/* Form elements inside content */
.content input[type="text"],
.content input[type="number"],
.content input[type="email"],
.content input[type="password"],
.content select,
.content textarea {
  appearance: none;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
}
.content input:focus,
.content select:focus,
.content textarea:focus {
  outline: none;
  border-color: #93c5fd; /* light blue */
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.35);
}

/* Subtle separators and muted text inside content */
.content .muted { color: #64748b; }
.content .sep { height: 1px; background: #e5e7eb; }


/* Sidebar collapse styles */
.app.sidebar-collapsed { grid-template-columns: 72px 1fr; }
.sidebar .brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar .sidebar-toggle { appearance: none; background: transparent; border: 1px solid var(--border); color: var(--text); width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.sidebar .sidebar-toggle:hover { background: #0f1a30; }
.sidebar .toggle-icon { width: 18px; height: 18px; filter: brightness(0) invert(1); }

.app.sidebar-collapsed .sidebar { padding-left: 8px; padding-right: 8px; }
.app.sidebar-collapsed .sidebar .brand-text { display: none; }
.app.sidebar-collapsed .sidebar .nav-label { display: none; }
.app.sidebar-collapsed .sidebar .nav-item a { justify-content: center; gap: 0; }

/* Tooltips for collapsed state */
.app.sidebar-collapsed .sidebar .nav-item a { position: relative; }
.app.sidebar-collapsed .sidebar .nav-item a::after {
  content: none; /* do not create tooltip element unless hovered to avoid scrollbars */
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  background: #111827;
  color: #e5e7eb;
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  margin-left: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  z-index: 2000;
}
.app.sidebar-collapsed .sidebar .nav-item a:hover::after {
  content: attr(title);
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}


/* Sidebar independent scroll for nav list; keep Settings pinned at bottom */
.sidebar nav { min-height: 0; }
.sidebar .nav-top { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* Workspace scroll independent of sidebar */
.content { height: 100vh; overflow: auto; min-width: 0; }


/* Project issues list inside project cards */
.project-issues { margin-top: 10px; }
.project-issues .section-title { font-weight: 700; font-size: 13px; color: #334155; margin-bottom: 6px; }
.issue-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.issue-list.small li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: #0f172a; }
.prio { display:inline-flex; align-items:center; justify-content:center; padding: 2px 8px; height: 22px; border-radius: 999px; font-size: 12px; font-weight: 700; color:#0f172a; background:#e5e7eb; border:1px solid #cbd5e1; line-height: 1; white-space: nowrap; }
.prio-5 { background:#fecaca; border-color:#fca5a5; }
.prio-4 { background:#fde68a; border-color:#fcd34d; }
.prio-3 { background:#bae6fd; border-color:#93c5fd; }
.prio-2 { background:#e9d5ff; border-color:#d8b4fe; }
.prio-1 { background:#e5e7eb; border-color:#cbd5e1; }
.issue-title { font-weight: 600; }
.issue-meta { color: #64748b; }


/* Markdown Editor */
.content .md-editor { display:flex; flex-direction:column; gap:6px; }
.content .md-editor .md-label { font-weight: 600; color: #1f2a44; }
.content .md-editor .md-toolbar { display:flex; flex-wrap:wrap; gap:6px; }
.content .md-editor .md-btn { appearance:none; background:#ffffff; border:1px solid #e5e7eb; border-radius:8px; padding:4px 8px; cursor:pointer; font-weight:600; color:#0f172a; }
.content .md-editor .md-btn:hover { background:#f3f4f6; }
.content .md-editor .md-split { display:grid; grid-template-columns: calc(50% - 5px) calc(50% - 5px); gap:10px; align-items: stretch; width: 100%; }
.content .md-editor textarea { width:100%; resize:vertical; height:auto; }
.content .md-editor .md-preview { background:#fafafa; border:1px dashed #e5e7eb; border-radius:8px; padding:8px 10px; color:#334155; font-size: 13px; line-height:1.5; min-height: 42px; overflow:auto; }
.content .md-editor .md-preview code { background: #e2e8f0; padding: 1px 4px; border-radius: 4px; }
.content .md-editor .md-preview .md-h1,
.content .md-editor .md-preview .md-h2,
.content .md-editor .md-preview .md-h3,
.content .md-editor .md-preview .md-h4,
.content .md-editor .md-preview .md-h5,
.content .md-editor .md-preview .md-h6 { display:block; font-weight:700; color:#0f172a; margin: 6px 0 4px; }
.content .md-editor .md-preview .md-h1 { font-size: 18px; }
.content .md-editor .md-preview .md-h2 { font-size: 16px; }
.content .md-editor .md-preview .md-h3 { font-size: 15px; }
.content .md-editor .md-preview .md-h4 { font-size: 14px; }
.content .md-editor .md-preview .md-h5 { font-size: 13px; }
.content .md-editor .md-preview .md-h6 { font-size: 12px; font-weight:600; }

/* PWA and mobile companion shell */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.mobile-topbar { display:none; }
.offline-page { display:grid; place-items:center; min-height:100dvh; padding:24px; overflow:auto; }
.offline-card { width:min(100%, 440px); padding:28px; border-radius:18px; background:#fff; color:#0f172a; box-shadow:0 18px 44px rgba(2,6,23,.35); text-align:center; }
.offline-card h1 { margin:0 0 10px; }
.offline-card p { margin:0; color:#475569; line-height:1.5; }
.offline-mark { font-size:42px; margin-bottom:8px; }
.offline-banner { position:fixed; left:50%; bottom:calc(14px + env(safe-area-inset-bottom)); transform:translateX(-50%); z-index:3000; width:min(calc(100% - 28px), 580px); padding:10px 14px; border-radius:10px; background:#7c2d12; color:#fff; box-shadow:0 8px 28px rgba(15,23,42,.28); font-size:14px; text-align:center; }
.mobile-issue-sheet { position:fixed; z-index:2500; inset:0; display:flex; align-items:flex-end; }
.mobile-issue-sheet-backdrop { position:absolute; inset:0; background:rgba(2,6,23,.52); }
.mobile-issue-sheet-card { position:relative; width:100%; max-height:min(78dvh, 620px); overflow:auto; padding:10px 16px calc(16px + env(safe-area-inset-bottom)); border-radius:20px 20px 0 0; background:#fff; color:#0f172a; box-shadow:0 -16px 42px rgba(2,6,23,.32); }
.mobile-issue-sheet-grip { width:42px; height:4px; margin:0 auto 12px; border-radius:99px; background:#cbd5e1; }
.mobile-issue-sheet-card h2 { margin:0; font-size:18px; line-height:1.35; }
.mobile-issue-sheet-meta { margin:8px 0 14px; color:#64748b; font-size:13px; }
.mobile-issue-sheet-actions { display:grid; gap:8px; margin-bottom:12px; }
.mobile-issue-sheet-actions .btn, .mobile-issue-sheet-close { min-height:44px; text-align:left; }

@media (max-width: 900px) {
  html, body { min-height:100%; height:auto; }
  body { overflow:auto; background:#f8fafc; }
  body.mobile-nav-open { overflow:hidden; }
  .app { display:block; height:auto; min-height:100dvh; overflow:visible; }
  .mobile-topbar { position:fixed; inset:0 0 auto 0; z-index:1300; min-height:56px; padding:calc(8px + env(safe-area-inset-top)) 12px 8px; display:flex; align-items:center; gap:10px; color:#fff; background:linear-gradient(90deg,#0a1222,#111827); border-bottom:1px solid var(--border); box-shadow:0 3px 16px rgba(15,23,42,.2); }
  .mobile-menu-toggle, .mobile-pwa-action { min-height:40px; border:1px solid #334155; border-radius:9px; background:#101a33; color:#fff; font:inherit; font-weight:650; cursor:pointer; }
  .mobile-menu-toggle { width:42px; padding:0; font-size:21px; }
  .mobile-brand { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:750; }
  .mobile-topbar-actions { display:flex; gap:6px; margin-left:auto; }
  .mobile-pwa-action { padding:0 9px; font-size:12px; }
  .sidebar { position:fixed; z-index:1200; inset:0 auto 0 0; width:min(86vw, 340px); height:100dvh; padding-top:calc(16px + env(safe-area-inset-top)); transform:translateX(-105%); transition:transform .2s ease; box-shadow:20px 0 40px rgba(2,6,23,.34); }
  .app.mobile-nav-open .sidebar { transform:translateX(0); }
  .app.mobile-nav-open::after { content:''; position:fixed; z-index:1150; inset:0; background:rgba(2,6,23,.48); }
  .sidebar .nav-item a, .nav-logout { min-height:44px; }
  .sidebar-toggle { display:none !important; }
  .content { min-height:100dvh; height:auto; overflow:visible; padding:calc(72px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
  .content h1 { font-size:22px; }
  .content h2 { font-size:18px; }
  .cards { grid-template-columns:1fr; gap:12px; }
  .content .cards { margin-top:12px; }
  .form-grid, .grid-2, .grid-3, .csp-inline-002, .csp-inline-003, .csp-inline-063, .csp-inline-066, .csp-inline-113, .csp-inline-125, .csp-inline-172, .csp-inline-177 { grid-template-columns:1fr !important; }
  .csp-inline-028, .csp-inline-049, .csp-inline-106 { align-items:stretch; flex-direction:column; }
  .csp-inline-030, .csp-inline-049 > div:last-child, .csp-inline-086, .csp-inline-087, .csp-inline-133, .csp-inline-143, .csp-inline-159, .csp-inline-161, .csp-inline-175, .csp-inline-176 { flex-wrap:wrap; }
  .csp-inline-030 .btn, .csp-inline-086 .btn, .csp-inline-143 .btn, .csp-inline-175 .btn, .csp-inline-176 .btn { min-height:44px; }
  .csp-inline-055 { grid-template-columns:repeat(2,1fr); }
  .project-grid { grid-template-columns:1fr !important; gap:14px; }
  .project-grid .user-card { aspect-ratio:auto !important; min-height:220px; padding:16px !important; }
  .user-grid, #users-list .user-grid { grid-template-columns:1fr !important; }
  .cards-scroll, .csp-inline-116 { max-height:none; overflow:visible; padding-right:0; }
  .doc-cards, .csp-inline-117, .csp-inline-148 { grid-template-columns:1fr; }
  .csp-inline-032, .csp-inline-046 { display:flex; overflow-x:auto; scroll-snap-type:x mandatory; padding-bottom:8px; margin-inline:-2px; }
  .csp-inline-032 > .bl-col, .csp-inline-046 > .kan-col { flex:0 0 min(84vw, 360px); scroll-snap-align:start; }
  .csp-inline-036 { min-height:56px; }
  .issue-card { min-height:44px; }
  .modal { overflow-y:auto; padding:calc(8px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom)); }
  .modal-card { width:100% !important; max-width:640px; min-height:0; max-height:none; margin:0 auto !important; padding:14px; }
  .modal-header { position:sticky; top:0; z-index:2; background:#fff; }
  .content .md-editor .md-split { grid-template-columns:1fr; }
  .toolbar, .csp-inline-064 { align-items:stretch; flex-wrap:wrap; }
  .toolbar .btn { min-width:44px; min-height:44px; }
  .csp-inline-065 { width:100%; margin-left:0; }
  .node-library { max-height:160px; overflow:auto; }
  .csp-inline-067 { min-height:58dvh; height:58dvh; }
  #diagramCanvas { touch-action:none; }
  canvas { max-width:100%; }
  .page-header, .csp-inline-106, .csp-inline-107 { align-items:flex-start; }
  .csp-inline-107 { flex-wrap:wrap; }
  .table-responsive, .csp-inline-073 { overflow:visible; }
  .table-responsive .table, .content .table:not(.mini-table) { min-width:0 !important; width:100%; }
  .table-responsive .table thead, .content .table:not(.mini-table) thead { display:none; }
  .table-responsive .table, .table-responsive .table tbody, .table-responsive .table tr, .table-responsive .table td, .content .table:not(.mini-table), .content .table:not(.mini-table) tbody, .content .table:not(.mini-table) tr, .content .table:not(.mini-table) td { display:block; width:100%; border:0; }
  .table-responsive .table tr, .content .table:not(.mini-table) tr { margin:0 0 10px; padding:10px 12px; border:1px solid #e5e7eb; border-radius:10px; background:#fff; box-shadow:0 1px 2px rgba(15,23,42,.04); }
  .table-responsive .table td, .content .table:not(.mini-table) td { display:grid; grid-template-columns:minmax(96px, 38%) 1fr; gap:8px; padding:6px 0; border-bottom:1px solid #eef2f7; text-align:left !important; }
  .table-responsive .table td:last-child, .content .table:not(.mini-table) td:last-child { border-bottom:0; }
  .table-responsive .table td::before, .content .table:not(.mini-table) td::before { content:attr(data-mobile-label); color:#64748b; font-size:12px; font-weight:700; }
  .table-responsive .table td[data-mobile-label='']::before, .content .table:not(.mini-table) td[data-mobile-label='']::before { display:none; }
}

@media (max-width: 420px) {
  .content { padding-inline:12px; }
  .mobile-brand { max-width:140px; font-size:14px; }
  .csp-inline-055 { grid-template-columns:1fr; }
  .user-form-layout { padding:0; }
  .avatar-editor { width:132px; height:132px; }
}
