*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f7f6f3;
  --bg-tertiary: #f0ede8;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-tertiary: #a0a0a0;
  --border-light: rgba(0,0,0,0.08);
  --border-mid: rgba(0,0,0,0.13);
  --border-strong: rgba(0,0,0,0.20);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 16px; }
html, body { height: 100%; font-family: var(--font); background: var(--bg-secondary); color: var(--text-primary); }

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  zoom: 1.25;
}

/* ─── SIDEBAR ──────────────────────────────────────────────────────────────── */

#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-primary);
  border-right: 0.5px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  height: calc(100vh / 1.25);
  max-height: calc(100vh / 1.25);
}

.sidebar-header {
  padding: 16px 14px 12px;
  border-bottom: 0.5px solid var(--border-light);
  flex-shrink: 0;
}

.sidebar-brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font-size: 13px; font-weight: 500; }
.brand-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }

.nav-body { padding: 8px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background 0.1s;
}
.nav-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.nav-item.active { background: var(--bg-secondary); color: var(--text-primary); font-weight: 500; }
.nav-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.nav-divider { height: 0.5px; background: var(--border-light); margin: 5px 0; }

/* ─── MAIN ──────────────────────────────────────────────────────────────────── */

#main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── RIGHT PANEL ───────────────────────────────────────────────────────────── */

#right-panel {
  width: 48px;
  min-width: 48px;
  background: var(--bg-primary);
  border-left: 0.5px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 2px;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

#right-panel-expanded {
  position: fixed;
  top: 0;
  right: 48px;
  bottom: 0;
  width: 320px;
  background: var(--bg-primary);
  border-left: 0.5px solid var(--border-light);
  box-shadow: -8px 0 24px rgba(0,0,0,0.08);
  z-index: 49;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
#right-panel-expanded.open { display: flex; }

.rp-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-tertiary);
  position: relative;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.rp-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }
.rp-btn.active { background: var(--bg-secondary); color: var(--text-primary); }
.rp-btn svg { width: 16px; height: 16px; }

.rp-tooltip {
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-primary);
  color: white;
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.rp-btn:hover .rp-tooltip { opacity: 1; }

.rp-divider { width: 24px; height: 0.5px; background: var(--border-light); margin: 4px 0; }

.rp-timer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2E7D00;
  position: absolute;
  top: 6px;
  right: 6px;
  animation: rp-pulse 1.5s infinite;
}

@keyframes rp-pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ─── PAGE TOPBAR ───────────────────────────────────────────────────────────── */

.page-topbar {
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--border-light);
  padding: 0 24px;
  height: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.page-title { font-size: 15px; font-weight: 500; }

/* ─── BUTTONS ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
  border: 0.5px solid var(--border-mid);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  transition: background 0.1s;
}
.btn:hover { background: var(--bg-secondary); }
.btn-primary { background: var(--text-primary); color: var(--bg-primary); border-color: transparent; }
.btn-primary:hover { opacity: 0.85; background: var(--text-primary); }

/* ─── STATUS BAR ────────────────────────────────────────────────────────────── */

.status-bar-wrap {
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--border-light);
  padding: 10px 24px;
  flex-shrink: 0;
}

.status-bar {
  display: flex;
  height: 20px;
  border-radius: var(--radius-md);
  overflow: hidden;
  gap: 2px;
}

.seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 500;
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  cursor: default;
  transition: opacity 0.15s;
}
.seg:hover { opacity: 0.85; }

/* ─── TOOLS BAR ─────────────────────────────────────────────────────────────── */

.tools-bar {
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--border-light);
  padding: 9px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.tools-right { margin-left: auto; }

/* ─── DROPDOWNS ─────────────────────────────────────────────────────────────── */

.dd-wrap { position: relative; display: inline-block; }

.dd-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
  border: 0.5px solid var(--border-mid);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-family: var(--font);
  white-space: nowrap;
  transition: background 0.1s;
}
.dd-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }

.dd-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-lg);
  min-width: 180px;
  z-index: 999;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}
.dd-menu.open { display: block; }

.dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}
.dd-item:hover { background: var(--bg-secondary); }

.chk {
  width: 14px;
  height: 14px;
  border: 0.5px solid var(--border-mid);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chk.on { background: var(--text-primary); border-color: var(--text-primary); }

/* ─── TOGGLE SWITCH ─────────────────────────────────────────────────────────── */

.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
  border: 0.5px solid var(--border-mid);
  color: var(--text-secondary);
  transition: background 0.1s;
}
.toggle-wrap:hover { background: var(--bg-secondary); }

.sw {
  width: 26px;
  height: 15px;
  border-radius: 8px;
  background: var(--border-mid);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.sw.on { background: #1D9E75; }
.sw-knob {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left 0.15s;
}
.sw.on .sw-knob { left: 13px; }

/* ─── SEARCH ────────────────────────────────────────────────────────────────── */

.search-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-mid);
  background: var(--bg-primary);
}
.search-wrap input {
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
  width: 180px;
  font-family: var(--font);
}
.search-wrap input::placeholder { color: var(--text-tertiary); }

/* ─── TABLE ─────────────────────────────────────────────────────────────────── */

.table-wrap { flex: 1; overflow: auto; background: var(--bg-primary); }

table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 600px; }
thead { position: sticky; top: 0; z-index: 10; }

th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--border-light);
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text-primary); }
th.sortable:hover .sort-arrow { opacity: 0.5 !important; }

td {
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--border-light);
  vertical-align: middle;
  white-space: nowrap;
}
tr:hover td { background: var(--bg-secondary); }

.sort-arrow {
  font-size: 10px;
  margin-left: 3px;
  color: var(--text-tertiary);
  transition: opacity 0.1s;
}

/* ─── CHECKBOX ───────────────────────────────────────────────────────────────── */

.cb {
  width: 14px;
  height: 14px;
  border: 0.5px solid var(--border-mid);
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cb.on { background: var(--text-primary); border-color: var(--text-primary); }

/* ─── STATUS PILL ────────────────────────────────────────────────────────────── */

.s-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  letter-spacing: 0.01em;
}

.s-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.s-dd {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-lg);
  min-width: 200px;
  z-index: 9999;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.s-dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-primary);
}
.s-dd-item:hover { background: var(--bg-secondary); }

/* ─── TEAM AVATARS ───────────────────────────────────────────────────────────── */

.av-stack { display: flex; }
.av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--bg-primary);
  margin-left: -6px;
  flex-shrink: 0;
  background: #d0d0d0;
  color: #666;
  filter: grayscale(1);
}
.av:first-child { margin-left: 0; }

/* ─── PROGRESS ───────────────────────────────────────────────────────────────── */

.prog-wrap { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.prog-pct { font-size: 11px; font-weight: 400; color: var(--text-secondary); white-space: nowrap; min-width: 28px; }
.prog-bar { flex: 1; height: 4px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; min-width: 60px; }
.prog-fill { height: 100%; border-radius: 2px; background: #1D9E75; transition: width 0.3s ease; }
.prog-count { font-size: 11px; font-weight: 400; color: var(--text-secondary); white-space: nowrap; }

/* ─── TAGS ───────────────────────────────────────────────────────────────────── */

.tags-wrap { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }

.t-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 500;
}
.t-x { cursor: pointer; opacity: 0.5; font-size: 11px; margin-left: 1px; }
.t-x:hover { opacity: 1; }

.add-tag {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0.5px dashed var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 14px;
  line-height: 1;
}
.add-tag:hover { background: var(--bg-secondary); color: var(--text-primary); }

.t-input {
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 11px;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  font-family: var(--font);
  width: 80px;
}

/* ─── CLIENT & POC TOOLTIP ───────────────────────────────────────────────────── */

.client-wrap { display: flex; align-items: center; gap: 7px; position: relative; }

.c-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #d0d0d0;
  color: #666;
  filter: grayscale(1);
}

.poc-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  padding-top: 6px;
  z-index: 500;
  min-width: 210px;
}
.poc-tooltip-inner {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.10);
}
.client-wrap:hover .poc-tooltip { display: block; }

.poc-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.poc-av {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #d0d0d0;
  color: #666;
  filter: grayscale(1);
}

/* ─── SWATCHES ───────────────────────────────────────────────────────────────── */

.swatches { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  flex-shrink: 0;
}
.swatch.on { border-color: var(--text-primary); }

/* ─── BILLABLE ───────────────────────────────────────────────────────────────── */

.bill-main { font-size: 12px; font-weight: 500; }
.bill-sub { font-size: 10px; color: var(--text-tertiary); margin-top: 1px; }

/* ─── KANBAN ─────────────────────────────────────────────────────────────────── */

.kanban-col { transition: outline 0.1s; }
.kanban-col-over { outline: 2px dashed var(--border-mid) !important; border-radius: 10px; }

[id^="task-card-"] { -webkit-user-select: none; user-select: none; }
[id^="task-card-"]:active { cursor: grabbing; }

.dep-draw-btn { display: none !important; }
[id^="task-card-"]:hover .dep-draw-btn { display: flex !important; }

/* ─── TIMELINE SCROLL ────────────────────────────────────────────────────────── */

.tl-scroll { overflow: auto; flex: 1; position: relative; cursor: grab; }
.tl-scroll:active { cursor: grabbing; }
.tl-scroll::-webkit-scrollbar { height: 6px; width: 6px; }
.tl-scroll::-webkit-scrollbar-track { background: var(--bg-secondary); }
.tl-scroll::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }

/* ─── CARD VIEW ──────────────────────────────────────────────────────────────── */

.card-client-wrap { position: relative; display: inline-block; }

.card-poc-tip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  padding-top: 6px;
  z-index: 500;
  min-width: 210px;
}
.card-poc-tip-inner {
  background: var(--bg-primary);
  border: 0.5px solid var(--border-mid);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}
.card-client-wrap:hover .card-poc-tip { display: block; }

/* ─── GLOBAL SEARCH OVERLAY ──────────────────────────────────────────────────── */

#global-search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}

#global-search-box {
  background: var(--bg-primary);
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
  overflow: hidden;
}

#global-search-input {
  width: 100%;
  border: none;
  padding: 16px 20px;
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  font-family: var(--font);
  border-bottom: 0.5px solid var(--border-light);
  background: var(--bg-primary);
}

.gs-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.1s;
}
.gs-result:hover { background: var(--bg-secondary); }
.gs-result-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

/* ─── QUICK NOTE ─────────────────────────────────────────────────────────────── */

#rp-note-area {
  width: 100%;
  flex: 1;
  border: none;
  resize: none;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  background: transparent;
  outline: none;
  padding: 16px;
  line-height: 1.6;
}

/* ─── CONTEXT MENU ───────────────────────────────────────────────────────────── */

.context-menu {
  position: fixed;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 4px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 9999;
}
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-primary);
}
.context-menu-item:hover { background: var(--bg-secondary); }
.context-menu-item.danger { color: #C94000; }
.context-menu-item.danger:hover { background: #FAECE7; }
.context-menu-divider { height: 0.5px; background: var(--border-light); margin: 4px 0; }