/* =========================================================
   ANGARA OS — LAYOUT
   Topbar, tabs, page structure, grids, hero strip, bottom nav
   ========================================================= */

/* ---- App shell ---- */
#app {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 0;
  padding: 0 24px;
  height: 64px;
  background: rgba(17,13,10,0.84);
  border-bottom: 1px solid var(--hl-1);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.app-wordmark {
  font-family: var(--serif); font-size: 18px; color: var(--text);
  letter-spacing: -0.01em; margin-right: 20px; flex-shrink: 0;
  position: relative;
}
.app-wordmark::before {
  content: '';
  position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(212,173,117,0.6);
}
.app-wordmark i {
  font-style: normal; color: var(--text-3); font-weight: 400;
  margin-left: 4px; letter-spacing: 0.04em; text-transform: uppercase; font-size: 12px;
}

/* Topbar breadcrumb — current page name beside wordmark */
.topbar-crumb {
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--text-3);
  padding-left: 16px; margin-left: 4px;
  border-left: 1px solid var(--hl-1);
  flex: 1; min-width: 0;
}

/* ---- Side nav (desktop) ----
   Grouped left column inspired by v89: Dashboard standalone on top, then
   Money / Personal sections with small uppercase eyebrows, glyph + label rows. */
.app-shell {
  display: flex; align-items: flex-start;
  flex: 1; min-height: 0;
}
.side-nav {
  position: sticky; top: 64px;
  width: 220px; flex-shrink: 0;
  height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  padding: 18px 14px 18px 24px;
  border-right: 1px solid var(--hl-1);
  background: rgba(17,13,10,0.55);
  overflow-y: auto;
}
.side-nav-section {
  font-family: var(--sans);
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--text-4);
  padding: 14px 12px 8px; margin-top: 6px;
}
.sn-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 9px 12px; margin: 1px 0;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--text-2);
  cursor: pointer; text-align: left;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.sn-item:hover { color: var(--text); background: var(--glass-1); }
.sn-item.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(212,173,117,0.22);
  font-weight: 600;
}
.sn-glyph {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; font-size: 13px; color: var(--text-3);
  flex-shrink: 0;
}
.sn-item.active .sn-glyph { color: var(--accent); }
.sn-label { flex: 1; min-width: 0; }
.side-nav-spacer { flex: 1; }
.side-nav-foot { padding-top: 14px; border-top: 1px solid var(--hl-1); }
.sn-foot .sn-glyph { color: var(--accent); }

/* ---- Topbar right controls ---- */
.topbar-right {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0; margin-left: auto; padding-left: 12px;
  min-width: 0;
}
.search-wrap { position: relative; flex: 0 1 180px; min-width: 0; }
.search-input {
  background: var(--glass-2); border: 1px solid var(--glass-border);
  color: var(--text); font-family: var(--sans); font-size: 12px;
  padding: 6px 12px; border-radius: 50px; outline: none;
  width: 100%; transition: border-color 0.2s, background 0.2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-4); }
#searchResults {
  position: absolute; top: calc(100% + 6px); right: 0;
  width: 320px; max-height: 320px; overflow-y: auto;
  background: var(--void-2); border: 1px solid var(--glass-border-bright);
  border-radius: var(--radius-sm); box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  display: none; z-index: 200;
}
.search-result-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--glass-2); }

/* Month selector */
#globalMonth {
  background: var(--glass-2); border: 1px solid var(--glass-border);
  color: var(--text); font-family: var(--sans); font-size: 12px;
  padding: 5px 10px; border-radius: 50px; outline: none; cursor: pointer;
}
.month-pill { /* alias */ }

/* Icon buttons */
.icon-btn {
  background: var(--glass-1); border: 1px solid var(--glass-border);
  color: var(--text-3); font-size: 15px; width: 32px; height: 32px;
  border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Cmd+B hides the sidebar, giving content full width */
.app-shell.sidebar-hidden .side-nav { display: none; }

/* ---- Content column (right of side-nav) ---- */
.content {
  flex: 1; min-width: 0;
}

/* ---- Pages ---- */
.page {
  display: none; padding: 24px 32px 120px;
  max-width: 1200px; margin: 0 auto; width: 100%;
}
.page.active { display: block; }
.page-title {
  font-family: var(--display); font-size: 46px; font-weight: 300;
  color: var(--text); letter-spacing: -0.025em; line-height: 0.98;
  margin-bottom: 4px;
}
.page-title em { font-style: normal; font-weight: 600; color: var(--accent); }
.page-sub {
  font-size: 13px; color: var(--text-3); margin-top: 10px; margin-bottom: 20px;
  font-style: italic; font-weight: 400;
}

/* ---- Section header ---- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-size: 10px; font-weight: 600; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-3);
  font-family: var(--sans);
}

/* ---- Grids ---- */
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }

/* ---- Hero (dashboard) ----
   Cash is the answer 90% of the time you open the app, so
   it gets display-serif type and the full width. Revenue /
   expenses / pipeline live in a single quiet row below. */
.hero-cash {
  margin-bottom: 14px;
  padding: 32px 32px 28px;
  position: relative;
}
.hero-cash-label {
  font-family: var(--sans);
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 14px;
}
.hero-cash-label-basis {
  font-weight: 400; text-transform: none; letter-spacing: 0;
  opacity: 0.65; margin-left: 6px;
}
.hero-cash-value {
  font-family: var(--display);
  font-size: clamp(52px, 8.5vw, 92px);
  font-weight: 300;
  color: var(--text);
  letter-spacing: -0.03em; line-height: 0.96;
  font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
}
.hero-cash-sub {
  font-family: var(--sans);
  font-size: 12px; color: var(--text-3);
  letter-spacing: 0.01em;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.hero-stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 22px 24px;
}
.hero-stat-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-3);
}
.hero-stat-label-basis { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.7; }
.hero-stat-value {
  font-family: var(--display);
  font-size: 24px; font-weight: 300;
  color: var(--text);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.hero-stat-sub { font-size: 11px; color: var(--text-4); }

/* Legacy hero classes — kept for any code paths still using them.
   New markup uses .hero-cash + .hero-stats. */
.hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}
.hero-tile {
  background: var(--void-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 22px 24px 18px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: border-color 0.2s;
  position: relative; overflow: hidden;
}
.hero-tile:hover { border-color: var(--glass-border-bright); }
.hero-tile.cash {
  background: linear-gradient(135deg, rgba(212,173,117,0.12) 0%, var(--void-2) 65%);
  border-color: rgba(212,173,117,0.22);
}
.hero-tile.expenses {
  background: linear-gradient(135deg, rgba(226,85,73,0.08) 0%, var(--void-2) 65%);
  border-color: rgba(226,85,73,0.12);
}
.hero-tile.pipeline {
  background: linear-gradient(135deg, rgba(216,177,74,0.07) 0%, var(--void-2) 65%);
  border-color: rgba(216,177,74,0.12);
}
.hero-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 12px;
}
.hero-label-basis { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.65; }
.hero-value {
  font-size: 28px; font-weight: 800; color: var(--text);
  letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums;
}
.hero-sub { font-size: 10px; color: var(--text-3); margin-top: 10px; }

@media (max-width: 700px) {
  .hero-stats { grid-template-columns: 1fr; gap: 12px; }
  .hero-cash-value { font-size: 52px; }
}

/* ---- Bottom nav (mobile) ---- */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: rgba(8,8,11,0.95);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: var(--blur-sm);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  justify-content: space-around;
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: var(--sans); font-size: 9px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-4); background: none; border: none; cursor: pointer;
  padding: 4px 12px; min-width: 52px; transition: color 0.15s;
}
.bn-item.active { color: var(--accent); }
.bn-icon { font-size: 18px; }

/* Pipeline header */
.pipeline-h2 {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 12px;
}

/* Project breakdown pill row */
.proj-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px;
  background: var(--glass-1);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.proj-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px;
  background: var(--glass-2);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
}

/* Freelancer pool card */
#freelancerPool { margin-bottom: 20px; }
#freelancerPoolInner { display: flex; flex-wrap: wrap; gap: 8px; }
.template-card {
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  padding: 14px 18px; cursor: pointer; transition: all 0.2s;
  background: var(--glass-1);
}
.template-card:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Rv/Py rows in pipelines */
.rv-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--glass-border);
}
.rv-row:last-child { border-bottom: none; }

/* ---- Responsive ---- */
/* Small laptop — shrink search before topbar starts overflowing */
@media (max-width: 1200px) {
  .search-wrap { flex: 0 1 140px; }
}
/* Tablet landscape — give tabs the room they need; ⌘K still focuses search */
@media (max-width: 1100px) {
  .search-wrap { display: none; }
}

/* Tablet portrait + below — hide desktop chrome, surface bottom nav */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .hero-grid { grid-template-columns: repeat(2,1fr); }
  .side-nav { display: none; }
  .topbar-crumb { display: none; }
  .bottom-nav { display: flex; }
  .page { padding: 16px 16px 100px; }
  .hero-value { font-size: 22px; }
  .topbar { padding: 0 12px; }
  .search-wrap { display: none; }
  /* Mobile chrome: keep theme + export-menu + settings.
     Hide shortcuts (no keyboard), quick-add (FAB covers it),
     and restore (rare; backup-first flow is enough). */
  .topbar-right [data-action="shortcuts"],
  .topbar-right [data-action="quick-add"],
  .topbar-right label.icon-btn { display: none; }
}

/* Phone — single-column dashboards + compact topbar */
@media (max-width: 640px) {
  .grid-3 { grid-template-columns: repeat(2,1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .hero-grid { grid-template-columns: 1fr; }
  .topbar { height: 56px; padding: 0 16px; }
  .icon-btn { width: 36px; height: 36px; }
  .app-wordmark { font-size: 17px; margin-right: 10px; }
  #globalMonth { max-width: 110px; }
  .page-title { font-size: 36px; line-height: 1.05; }
}
