:root {
  --bg: #070b19;
  --bg-2: #0b1023;
  --bg-surface: rgba(26, 31, 63, 0.96);
  --bg-secondary: rgba(15, 18, 40, 0.88);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f5f7ff;
  --text-secondary: #9aa5d1;
  --panel: rgba(20, 24, 48, 0.88);
  --panel-2: rgba(31, 37, 69, 0.82);
  --card: linear-gradient(180deg, rgba(26,31,63,.96), rgba(17,20,41,.96));
  --stroke: rgba(255,255,255,.08);
  --text: #f5f7ff;
  --muted: #9aa5d1;
  --primary: #7b3ff2;
  --primary-2: #5d7cff;
  --cyan: #3fd4ff;
  --green: #12d48e;
  --yellow: #f5c84c;
  --red: #ff5d8f;
  --shadow: 0 18px 55px rgba(15, 14, 45, .45);
  --radius: 22px;
  --radius-sm: 14px;
  --sidebar-width: 260px;
}
html[data-theme="light"] {
  --bg: #f3f6ff;
  --bg-2: #e8eeff;
  --bg-surface: rgba(255, 255, 255, 0.98);
  --bg-secondary: rgba(241, 245, 255, 0.88);
  --border-color: rgba(88, 103, 160, 0.16);
  --text-primary: #18233f;
  --text-secondary: #5f6d95;
  --panel: rgba(255,255,255,.88);
  --panel-2: rgba(255,255,255,.95);
  --card: linear-gradient(180deg, rgba(255,255,255,.98), rgba(241,245,255,.98));
  --stroke: rgba(88,103,160,.16);
  --text: #18233f;
  --muted: #5f6d95;
  --shadow: 0 18px 55px rgba(114,127,177,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color: var(--text); background: radial-gradient(circle at top left, rgba(114,57,255,.25), transparent 28%), radial-gradient(circle at top right, rgba(74,125,255,.18), transparent 24%), linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none; opacity: .35;
}
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; position: relative; }
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 10;
  padding: 22px 16px; border-right: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(8,11,25,.95), rgba(10,12,28,.86));
  backdrop-filter: blur(16px);
  display: flex; flex-direction: column; justify-content: space-between;
}
html[data-theme="light"] .sidebar { background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(243,246,255,.96)); }
.brand { display:flex; align-items:center; gap:12px; padding:10px 12px 20px; }
.brand img { width: 118px; height: auto; }
.profile-card {
  background: linear-gradient(180deg, rgba(24,28,54,.95), rgba(16,19,37,.95)); border:1px solid var(--stroke);
  border-radius: 18px; padding: 14px; display:flex; gap:12px; align-items:center; box-shadow: var(--shadow);
}
html[data-theme="light"] .profile-card { background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(243,246,255,.98)); }
.avatar { width:48px; height:48px; border-radius:16px; object-fit:cover; border:1px solid rgba(255,255,255,.12); }
.avatar.small { width: 38px; height: 38px; border-radius: 12px; }
.profile-info strong { display:block; font-size: 15px; }
.profile-info span { font-size: 12px; color: var(--muted); display:block; }
.role-pill { display:inline-flex; margin-top:6px; padding:4px 8px; border-radius:999px; font-size:11px; letter-spacing:.04em; text-transform:uppercase; border:1px solid var(--stroke); color:var(--muted); }
.nav-group { margin-top: 18px; display:flex; flex-direction:column; gap:6px; }
.nav-link {
  display:flex; align-items:center; gap:12px; padding: 13px 14px; border-radius: 16px; color:#c8d1ff;
  transition: .25s ease; position: relative; overflow: hidden;
}
html[data-theme="light"] .nav-link { color: #32436f; }
.nav-link:hover, .nav-link.active { background: linear-gradient(90deg, rgba(108,64,255,.22), rgba(59,89,255,.18)); color: white; transform: translateX(4px); }
html[data-theme="light"] .nav-link:hover, html[data-theme="light"] .nav-link.active { color: #18233f; }
.nav-link::after { content:""; position:absolute; inset:0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); transform:translateX(-100%); transition: .6s ease; }
.nav-link:hover::after { transform:translateX(100%); }
.nav-icon { width:18px; opacity:.9; text-align:center; }
.sidebar-footer { width: 100%; }
.upgrade {
  width:100%; border:none; border-radius:16px; padding:14px 18px; color:white; cursor:pointer;
  background: linear-gradient(90deg, var(--primary-2), var(--primary)); box-shadow: 0 12px 25px rgba(93,124,255,.28);
}
.main { padding: 22px; }
.topbar { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom: 20px; position: relative; z-index: 40; flex-wrap: wrap; }
.page-title h1 { margin:0; font-size: 26px; }
.page-title p { margin:6px 0 0; color: var(--muted); }
.top-actions { display:flex; align-items:center; gap:12px; position:relative; flex-wrap:wrap; justify-content:flex-end; }
.search {
  background: rgba(255,255,255,.04); border:1px solid var(--stroke); color:var(--text); height:46px; min-width:240px;
  border-radius: 16px; padding: 0 16px;
}
.workspace-badge { padding:10px 14px; border-radius:999px; border:1px solid var(--stroke); color:var(--muted); background: rgba(255,255,255,.04); white-space:nowrap; }
.icon-btn, .btn {
  border:none; cursor:pointer; border-radius: 16px; padding: 12px 16px; color:var(--text);
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); transition: .25s ease;
}
.btn:hover, .icon-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(0,0,0,.22); }
.btn-primary { background: linear-gradient(90deg, var(--primary-2), var(--primary)); color: #fff; }
.btn-success { background: linear-gradient(90deg, #05b980, #0fd8a4); color:#fff; }
.btn-warning { background: linear-gradient(90deg, #dc8d00, #f5c84c); color:#221400; }
.btn-danger { background: linear-gradient(90deg, #ff4a79, #ff6b9b); color:#fff; }
.hero {
  padding: 22px 24px; border-radius: 28px; background: linear-gradient(90deg, #5f4bff, #ac2bff 52%, #6d32ff);
  box-shadow: 0 22px 44px rgba(92, 53, 255, .24); position:relative; overflow:hidden; margin-bottom:18px; min-height: 0;
}
.hero::after {
  content:""; position:absolute; inset:-20% -10% auto auto; width:240px; height:240px; border-radius:50%;
  background: radial-gradient(circle, rgba(255,255,255,.25), transparent 60%); filter: blur(10px);
}
.hero .eyebrow { letter-spacing: .16em; text-transform: uppercase; font-size:12px; opacity:.72; font-weight: 700; }
.hero h2 { font-size: clamp(30px, 4vw, 42px); margin: 8px 0 6px; line-height: 1.05; }
.hero p { margin:0; max-width: 760px; color: rgba(255,255,255,.86); line-height: 1.55; }
.hero-actions { display:flex; gap:12px; margin-top: 16px; flex-wrap:wrap; }
.hero-actions .btn { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.2); box-shadow: 0 12px 28px rgba(27, 13, 89, .18); color:#fff; }
.hero-actions .btn.btn-primary { background: linear-gradient(90deg, #eff3ff, #d8e4ff); color: #33207d; border-color: rgba(255,255,255,.55); font-weight: 700; }
.hero .ghost { background: rgba(255,255,255,.12); }
.grid { display:grid; gap:18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  position:relative; overflow:hidden;
}
.card::before { content:""; position:absolute; inset:auto -80px -80px auto; width:180px; height:180px; border-radius:50%; background: radial-gradient(circle, rgba(115,91,255,.12), transparent 62%); }
.card h3, .card h4 { margin:0 0 14px; }
.metric .label { color:var(--muted); font-size:13px; }
.metric .value { font-size: 42px; font-weight: 800; margin: 10px 0 4px; }
.metric .delta { font-size: 13px; color:#97ffd6; }
.section-header { display:flex; justify-content:space-between; align-items:center; gap:12px; margin: 6px 0 10px; }
.section-header p { color: var(--muted); margin: 4px 0 0; }
.quick-actions { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:12px; }
.quick-action {
  padding:16px; border-radius: 18px; background: linear-gradient(90deg, rgba(119,68,255,.13), rgba(57,86,255,.14)); border:1px solid var(--stroke);
  transition: .25s ease; display:flex; align-items:center; gap:10px;
}
.quick-action:hover { transform: translateY(-3px) scale(1.01); }
.table-wrap { overflow:auto; }
table { width:100%; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid rgba(255,255,255,.06); text-align:left; }
th { color:var(--muted); font-weight: 600; font-size: 13px; }
td { color: var(--text); font-size: 14px; }
.badge { display:inline-flex; padding: 7px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.success { background: rgba(18,212,142,.14); color: #7ff0c0; }
.badge.warning { background: rgba(245,200,76,.14); color: #ffd97f; }
.badge.danger { background: rgba(255,93,143,.14); color: #ff9ebd; }
.badge.info { background: rgba(63,212,255,.14); color: #92e8ff; }
.stack { display:flex; flex-direction:column; gap:16px; }
.kanban { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:16px; }
.column { background: rgba(255,255,255,.03); border:1px solid var(--stroke); border-radius: 20px; padding:14px; min-height: 240px; }
.column h4 { display:flex; justify-content:space-between; align-items:center; }
.task {
  background: linear-gradient(180deg, rgba(31,36,68,.95), rgba(19,23,42,.96)); border:1px solid rgba(255,255,255,.07); border-radius: 16px;
  padding: 14px; margin-top:12px; cursor:grab; transition: .2s ease;
}
html[data-theme="light"] .task { background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(244,247,255,.98)); }
.task:hover { transform: translateY(-2px); }
.chart-placeholder, .video-placeholder {
  height: 240px; border-radius: 18px; border:1px dashed rgba(255,255,255,.12); display:flex; align-items:center; justify-content:center; color:var(--muted);
  background: linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.01));
}
.chart-bars { display:flex; align-items:flex-end; gap:10px; height:180px; padding: 16px 0; }
.chart-bars span { flex:1; border-radius: 999px 999px 12px 12px; background: linear-gradient(180deg, #60d2ff, #6b47ff); box-shadow: 0 8px 18px rgba(89,83,255,.22); }
.footer-help {
  margin-top: 20px; border: 1px solid var(--stroke); border-radius: 20px; padding: 18px 20px; display:flex; align-items:center; justify-content:space-between; gap:12px;
  background: linear-gradient(90deg, rgba(76,84,147,.14), rgba(126,63,242,.14));
}
.footer-help p { margin:0; color: var(--muted); }
.profile-menu {
  position:absolute; top:60px; right:0; width: 260px; background: var(--panel-2); border:1px solid var(--stroke);
  border-radius: 18px; padding: 10px; display:none; box-shadow: var(--shadow); z-index: 60;
}
.profile-menu.open { display:block; animation: rise .18s ease; }
.profile-menu a, .profile-menu button { width:100%; text-align:left; background:transparent; border:none; color:var(--text); display:block; padding:12px 14px; border-radius: 12px; cursor:pointer; }
.profile-menu a:hover, .profile-menu button:hover { background: rgba(255,255,255,.06); }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,20,.7); backdrop-filter: blur(8px); display:none; align-items:center; justify-content:center; padding:20px; z-index:200;
}
.modal-backdrop.open { display:flex; }
.modal {
  width:min(760px, 100%); background: linear-gradient(180deg, rgba(17,21,41,.98), rgba(10,12,28,.98)); border:1px solid var(--stroke); border-radius: 24px; padding: 22px;
  box-shadow: var(--shadow); max-height: 88vh; overflow:auto;
}
html[data-theme="light"] .modal { background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(243,246,255,.98)); }
.modal header { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom: 12px; }
.form-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:14px; }
.form-group { display:flex; flex-direction:column; gap:8px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size:13px; color:var(--muted); }
input, select, textarea {
  background: rgba(255,255,255,.045); border:1px solid rgba(255,255,255,.09); border-radius: 14px; color:var(--text); padding: 12px 14px; outline:none;
}
textarea { min-height: 110px; resize: vertical; }
.modal footer { display:flex; justify-content:flex-end; gap:10px; margin-top: 18px; }
.list { display:flex; flex-direction:column; gap:10px; }
.list-item { padding:14px; border-radius: 16px; border:1px solid var(--stroke); background: rgba(255,255,255,.03); display:flex; justify-content:space-between; gap:12px; align-items:center; }
.pill-tabs { display:flex; flex-wrap:wrap; gap:10px; margin-bottom: 18px; }
.pill-tab { padding: 10px 14px; border-radius: 999px; background: rgba(255,255,255,.05); border:1px solid var(--stroke); color:var(--text); }
.pill-tab.active { background: linear-gradient(90deg, rgba(123,63,242,.34), rgba(93,124,255,.24)); }
.empty { padding: 24px; text-align:center; color: var(--muted); border:1px dashed rgba(255,255,255,.1); border-radius: 18px; }
@keyframes rise { from { opacity:0; transform: translateY(10px) scale(.98);} to { opacity:1; transform: translateY(0) scale(1);} }

/* Hamburger Menu */
.hamburger-btn {
  display: none;
  flex-direction: column;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 100;
}
.hamburger-btn span {
  width: 24px;
  height: 2.5px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger-btn.active span:nth-child(1) { transform: rotate(45deg) translate(8px, 8px); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(7px, -7px); }

/* Responsive - Tablet */
@media (max-width: 1200px) {
  .grid-4, .quick-actions, .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Responsive - Large Mobile & Tablet */
@media screen and (max-width: 900px) {
  :root { --sidebar-width: 100%; }
  
  .app-shell { 
    display: grid !important;
    grid-template-columns: 1fr !important;
    min-height: 100vh;
  }
  
  .sidebar { 
    position: fixed !important;
    left: -100% !important;
    top: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    transition: left 0.3s ease !important;
    z-index: 99 !important;
    border-right: none !important;
    border-bottom: none !important;
    overflow-y: auto !important;
    padding: 16px !important;
    padding-top: 80px !important;
  }
  
  .sidebar.active { 
    left: 0 !important; 
  }
  
  .hamburger-btn { 
    display: flex !important; 
    order: -1;
  }
  
  .topbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 60px !important;
    z-index: 50 !important;
    background: var(--bg-surface) !important;
    padding: 0 12px !important;
    align-items: center !important;
    border-bottom: 1px solid var(--stroke) !important;
    gap: 12px !important;
    display: flex !important;
    justify-content: space-between !important;
  }
  
  .page-title {
    flex: 1;
    min-width: 0;
    margin: 0;
  }
  
  .page-title h1 {
    margin: 0 !important;
    font-size: 16px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .page-title p { 
    display: none !important; 
  }
  
  .top-actions {
    gap: 8px !important;
    align-items: center !important;
    display: flex !important;
  }
  
  .main { 
    padding: 16px !important; 
    padding-top: 80px !important;
    margin: 0 !important;
  }
  
  .grid-3, .grid-2, .grid-4, .quick-actions, .kanban, .form-grid { 
    grid-template-columns: 1fr !important; 
  }
  
  .footer-help { 
    flex-direction: column !important; 
    align-items: flex-start !important; 
  }
  
  .search { 
    display: none !important; 
  }
}

/* Responsive - Mobile */
@media screen and (max-width: 600px) {
  :root { --sidebar-width: 100%; }
  
  .app-shell { 
    grid-template-columns: 1fr !important; 
  }
  
  .topbar { 
    margin-bottom: 0 !important;
  }
  
  .page-title h1 { 
    font-size: 14px !important; 
  }
  .page-title p { 
    display: none !important; 
  }
  
  .sidebar {
    height: 100vh !important;
    padding: 12px !important;
    padding-top: 80px !important;
  }
  
  .brand { padding: 8px 10px 16px; }
  .brand img { width: 100px; }
  
  .nav-group { margin-top: 12px; gap: 4px; }
  .nav-link { padding: 11px 12px; font-size: 14px; }
  .nav-icon { width: 16px; }
  
  .profile-card { padding: 10px; gap: 10px; }
  .avatar { width: 40px; height: 40px; }
  .avatar.small { width: 32px; height: 32px; }
  .profile-info strong { font-size: 13px; }
  .profile-info span { font-size: 11px; }
  .role-pill { font-size: 10px; }
  
  .main { 
    padding: 12px !important;
    padding-top: 80px !important;
  }
  
  input, select, textarea {
    padding: 10px 12px !important;
    font-size: 16px !important;
  }
  
  button { padding: 10px 14px; font-size: 14px; }
  
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  
  .list-item { 
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px;
  }
  
  .list-item > div:last-child {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  
  .card { margin-bottom: 16px; }
  
  .hero { 
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 18px;
  }
  
  .hero h2 { font-size: 16px; }
  .hero p { font-size: 12px; }
  .hero-actions { flex-wrap: wrap; gap: 8px; }
  .hero-actions .btn { font-size: 12px; padding: 10px 12px; }
  
  .modal { 
    max-width: 95vw !important; 
    max-height: 90vh !important;
    margin: 0 auto !important;
  }
  .modal header { flex-direction: column; }
  
  .form-grid { gap: 10px; }
  .form-group { gap: 6px; }
  label { font-size: 12px; }
  
  .pill-tabs { gap: 6px; }
  .pill-tab { padding: 8px 12px; font-size: 12px; }
  
  .entity-meta { gap: 6px; }
  .tag { padding: 4px 8px; font-size: 11px; }
  
  .finance-toolbar { 
    flex-direction: column;
    gap: 12px;
  }
  
  .company-filter { width: 100%; }
  .company-filter-wrap { width: 100%; }
  
  .finance-actions { width: 100%; }
  
  .search { 
    display: none;
  }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
  .page-title h1 { font-size: 18px; }
  
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; }
  
  .btn { width: 100%; text-align: center; }
  .btn.ghost { width: auto; }
  
  table { font-size: 12px; }
  
  .sidebar {
    height: calc(100vh - 44px);
  }
  
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Autocomplete styles */
.autocomplete-wrapper { position: relative; width: 100%; }
.autocomplete-input { width: 100%; }
.autocomplete-list { 
  position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
  background: rgba(8,12,28,.95); border:1px solid rgba(255,255,255,.09); 
  border-top: none; border-radius: 0 0 14px 14px;
  max-height: 200px; overflow-y: auto;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: 13px; color: var(--text);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.selected { background: rgba(123,63,242,.24); }

/* Fix for select/input visibility */
input, select, textarea { color: var(--text) !important; }
select option { background: rgba(8,12,28,.95); color: #dbe1ff; }
