/* ============================================================
   SELVA SYSTEM — Complete Stylesheet
   ============================================================ */

:root {
  --g1:#1B5E20; --g2:#2E7D32; --g3:#43A047; --g4:#66BB6A; --g5:#E8F5E9; --g6:#F1F8E9;
  --b1:#1565C0; --b2:#E3F2FD; --b3:#90CAF9;
  --o1:#E65100; --o2:#FFF3E0; --o3:#FFCC80;
  --d1:#263238; --d2:#37474F; --d3:#546E7A; --d4:#78909C; --d5:#B0BEC5; --d6:#ECEFF1; --d7:#F5F5F5;
  --white:#fff; --radius:8px; --shadow:0 2px 8px rgba(0,0,0,.08);
  --sidebar-w:260px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --danger:#C62828; --danger-bg:#FFEBEE;
  --warning:#F57F17; --warning-bg:#FFF8E1;
  --success:#2E7D32; --success-bg:#E8F5E9;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--d7);
  color: var(--d1);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--b1); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--g1) 0%, var(--g2) 50%, var(--g3) 100%);
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

.login-logo h1 {
  font-size: 1.6rem;
  color: var(--g1);
  font-weight: 700;
}

.login-logo p {
  color: var(--d4);
  font-size: .9rem;
}

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 12px;
}

/* ============================================================
   FORM FIELDS
   ============================================================ */
.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: block;
  font-weight: 600;
  font-size: .85rem;
  color: var(--d2);
  margin-bottom: 6px;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--d5);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9rem;
  color: var(--d1);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--g3);
  box-shadow: 0 0 0 3px rgba(67,160,71,.15);
}

.form-field textarea {
  resize: vertical;
  min-height: 80px;
}

.form-field input[type="color"] {
  height: 42px;
  padding: 4px;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s, box-shadow .2s;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--g2);
  color: var(--white);
}
.btn-primary:hover { background: var(--g1); }

.btn-ghost {
  background: transparent;
  color: var(--d3);
}
.btn-ghost:hover { background: var(--d6); color: var(--d1); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover { background: #B71C1C; }

.btn-approve {
  background: var(--g3);
  color: var(--white);
}
.btn-approve:hover { background: var(--g2); }

.btn-reject {
  background: var(--white);
  color: var(--danger);
  border: 1.5px solid var(--danger);
}
.btn-reject:hover { background: var(--danger-bg); }

.btn-sm {
  padding: 6px 12px;
  font-size: .8rem;
}

.btn-full {
  width: 100%;
}

.btn-outline {
  background: var(--white);
  color: var(--g2);
  border: 1.5px solid var(--g2);
}
.btn-outline:hover { background: var(--g5); }

.btn-warning {
  background: var(--warning);
  color: var(--white);
}

.btn-blue {
  background: var(--b1);
  color: var(--white);
}
.btn-blue:hover { background: #0D47A1; }

/* ============================================================
   APP SHELL LAYOUT
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--d1);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--d2);
}

.sidebar-header .logo-icon { font-size: 24px; }

.sidebar-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--g4);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-title {
  padding: 8px 20px 4px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--d4);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--d5);
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--d2);
  color: var(--white);
}

.nav-item.active {
  background: rgba(67,160,71,.12);
  color: var(--g4);
  border-left-color: var(--g4);
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--o1);
  color: var(--white);
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* Client nav */
.client-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px 7px 28px;
  color: var(--d5);
  font-size: .84rem;
  cursor: pointer;
  transition: background .15s;
}

.client-nav-item:hover {
  background: var(--d2);
  color: var(--white);
}

.client-nav-item.active {
  color: var(--g4);
  background: rgba(67,160,71,.08);
}

.client-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.client-expand-btn {
  background: none;
  border: none;
  color: var(--d4);
  cursor: pointer;
  padding: 2px;
  font-size: .7rem;
  transition: transform .2s;
}

.client-expand-btn.expanded {
  transform: rotate(90deg);
}

.client-brands {
  padding-left: 36px;
}

.client-brands .brand-link {
  display: block;
  padding: 4px 20px;
  color: var(--d4);
  font-size: .78rem;
  cursor: pointer;
}

.client-brands .brand-link:hover {
  color: var(--g4);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--d2);
}

/* ============================================================
   MAIN AREA
   ============================================================ */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--d6);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  flex: 1;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--d1);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notification-wrapper {
  position: relative;
}

.notification-bell {
  position: relative;
  font-size: 1.2rem;
}

.notification-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: var(--white);
  font-size: .65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 420px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  border: 1px solid var(--d6);
  overflow: hidden;
  z-index: 200;
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--d6);
}

.notification-list {
  overflow-y: auto;
  max-height: 360px;
}

.notification-entry {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--d6);
  cursor: pointer;
  transition: background .15s;
}

.notification-entry:hover { background: var(--d7); }

.notification-entry.unread { background: var(--b2); }

.notification-entry .notif-icon { font-size: 1.1rem; flex-shrink: 0; }

.notification-entry .notif-body { flex: 1; }

.notification-entry .notif-title {
  font-weight: 600;
  font-size: .85rem;
  color: var(--d1);
}

.notification-entry .notif-message {
  font-size: .8rem;
  color: var(--d3);
  margin-top: 2px;
}

.notification-entry .notif-time {
  font-size: .72rem;
  color: var(--d4);
  margin-top: 4px;
}

.notification-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--d4);
  font-size: .85rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: var(--white);
}

.user-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--d2);
}

.mobile-only { display: none; }

/* ============================================================
   CONTENT
   ============================================================ */
.content {
  flex: 1;
  padding: 24px;
}

/* Loading */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px;
  color: var(--d4);
  font-size: .95rem;
}

.loading-state::before {
  content: '';
  width: 24px;
  height: 24px;
  border: 3px solid var(--d6);
  border-top-color: var(--g3);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-right: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--d4);
}

.empty-state .empty-icon {
  font-size: 2.4rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: .95rem;
  margin-bottom: 16px;
}

/* ============================================================
   DASHBOARD STATS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--g3);
}

.stat-card.blue { border-left-color: var(--b1); }
.stat-card.orange { border-left-color: var(--o1); }
.stat-card.green { border-left-color: var(--g2); }
.stat-card.red { border-left-color: var(--danger); }

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--d1);
}

.stat-card .stat-label {
  font-size: .82rem;
  color: var(--d4);
  margin-top: 4px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--d1);
}

.card-section {
  margin-bottom: 20px;
}

.card-section:last-child { margin-bottom: 0; }

.card-section-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--d4);
  margin-bottom: 8px;
}

/* ============================================================
   PROJECT LIST / CARDS
   ============================================================ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  cursor: pointer;
  transition: box-shadow .2s, transform .15s;
  border-left: 4px solid var(--g3);
}

.project-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  transform: translateY(-1px);
}

.project-card .project-client {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

.project-card .project-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--d1);
  margin-bottom: 4px;
}

.project-card .project-template {
  font-size: .8rem;
  color: var(--d4);
  margin-bottom: 12px;
}

.project-card .project-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .78rem;
  color: var(--d3);
  margin-bottom: 10px;
}

.project-card .project-meta .priority-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
}

.priority-alta { background: var(--danger-bg); color: var(--danger); }
.priority-media { background: var(--warning-bg); color: var(--warning); }
.priority-normal { background: var(--b2); color: var(--b1); }

.progress-bar {
  height: 6px;
  background: var(--d6);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar .progress-fill {
  height: 100%;
  background: var(--g3);
  border-radius: 3px;
  transition: width .4s;
}

.progress-text {
  font-size: .75rem;
  color: var(--d4);
  margin-top: 4px;
}

/* Client group header */
.client-group {
  margin-bottom: 28px;
}

.client-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--d6);
}

.client-group-header .group-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.client-group-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--d1);
}

.client-group-header .group-count {
  font-size: .8rem;
  color: var(--d4);
}

/* ============================================================
   KANBAN
   ============================================================ */
.kanban-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.kanban-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.kanban-header .project-info {
  font-size: .85rem;
  color: var(--d3);
}

.kanban-views {
  display: flex;
  gap: 8px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  min-height: 400px;
}

.kanban-column {
  background: var(--d7);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 300px;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--d5);
}

.kanban-column-header h4 {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.kanban-column-header .col-count {
  font-size: .72rem;
  font-weight: 600;
  background: var(--d5);
  color: var(--white);
  padding: 2px 7px;
  border-radius: 10px;
}

.col-blocked .kanban-column-header { border-bottom-color: var(--d4); }
.col-pending .kanban-column-header { border-bottom-color: var(--o1); }
.col-in_progress .kanban-column-header { border-bottom-color: var(--b1); }
.col-review .kanban-column-header { border-bottom-color: var(--warning); }
.col-done .kanban-column-header { border-bottom-color: var(--g2); }

/* Kanban cards */
.kanban-card {
  background: var(--white);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  border-left: 3px solid var(--d5);
}

.kanban-card:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

.kanban-card.status-blocked { border-left-color: var(--d4); }
.kanban-card.status-pending { border-left-color: var(--o1); }
.kanban-card.status-in_progress { border-left-color: var(--b1); }
.kanban-card.status-review { border-left-color: var(--warning); }
.kanban-card.status-done { border-left-color: var(--g2); }

.kanban-card .kc-phase {
  font-size: .7rem;
  font-weight: 600;
  color: var(--d4);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 4px;
}

.kanban-card .kc-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--d1);
  margin-bottom: 6px;
}

.kanban-card .kc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: .72rem;
  color: var(--d4);
}

.kanban-card .kc-tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 600;
}

.kc-tag.sla { background: var(--b2); color: var(--b1); }
.kc-tag.owner { background: var(--g5); color: var(--g1); }
.kc-tag.dep { background: var(--o2); color: var(--o1); }
.kc-tag.checklist { background: var(--d6); color: var(--d3); }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--d5);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .15s;
}

.timeline-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }

.timeline-dot {
  position: absolute;
  left: -26px;
  top: 18px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--white);
  box-shadow: 0 0 0 2px var(--d5);
}

.timeline-dot.status-blocked { background: var(--d4); box-shadow: 0 0 0 2px var(--d4); }
.timeline-dot.status-pending { background: var(--o1); box-shadow: 0 0 0 2px var(--o1); }
.timeline-dot.status-in_progress { background: var(--b1); box-shadow: 0 0 0 2px var(--b1); }
.timeline-dot.status-review { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-dot.status-done { background: var(--g2); box-shadow: 0 0 0 2px var(--g2); }

.timeline-item .tl-phase {
  font-size: .72rem;
  font-weight: 600;
  color: var(--d4);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.timeline-item .tl-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--d1);
  margin: 4px 0;
}

.timeline-item .tl-meta {
  display: flex;
  gap: 12px;
  font-size: .78rem;
  color: var(--d4);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-container {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
  animation: modalIn .2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--d6);
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--d1);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--d4);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--d1); }

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--d6);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-container.wide {
  max-width: 800px;
}

/* ============================================================
   TASK DETAIL
   ============================================================ */
.task-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.task-detail-header .td-main { flex: 1; }

.task-detail-header .td-status {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.status-blocked { background: var(--d6); color: var(--d3); }
.status-pending { background: var(--o2); color: var(--o1); }
.status-in_progress { background: var(--b2); color: var(--b1); }
.status-review { background: var(--warning-bg); color: var(--warning); }
.status-done { background: var(--success-bg); color: var(--success); }
.status-cancelled { background: var(--d6); color: var(--d4); }

.task-detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.td-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.td-meta-item .td-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--d4);
}

.td-meta-item .td-value {
  font-size: .9rem;
  font-weight: 600;
  color: var(--d1);
}

/* Scope boxes */
.scope-box {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.scope-box.scope-in {
  background: var(--g5);
  border: 1px solid var(--g4);
}

.scope-box.scope-out {
  background: var(--danger-bg);
  border: 1px solid #EF9A9A;
}

.scope-box h4 {
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.scope-box.scope-in h4 { color: var(--g1); }
.scope-box.scope-out h4 { color: var(--danger); }

.scope-box ul {
  list-style: none;
  padding: 0;
}

.scope-box ul li {
  padding: 3px 0;
  font-size: .85rem;
  color: var(--d2);
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.scope-box ul li::before {
  font-size: .75rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.scope-box.scope-in ul li::before { content: '\2713'; color: var(--g2); }
.scope-box.scope-out ul li::before { content: '\2717'; color: var(--danger); }

/* Checklist */
.checklist {
  list-style: none;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--d6);
  font-size: .88rem;
}

.checklist-item:last-child { border-bottom: none; }

.checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--g3);
  cursor: pointer;
}

.checklist-item.is-done .checklist-text {
  text-decoration: line-through;
  color: var(--d4);
}

/* ============================================================
   COMMENTS THREAD
   ============================================================ */
.comments-thread {
  margin-top: 16px;
}

.comment-entry {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--d6);
}

.comment-entry:last-child { border-bottom: none; }

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .75rem;
  color: var(--white);
  flex-shrink: 0;
}

.comment-body { flex: 1; }

.comment-body .comment-author {
  font-weight: 600;
  font-size: .85rem;
  color: var(--d1);
}

.comment-body .comment-time {
  font-size: .72rem;
  color: var(--d4);
  margin-left: 8px;
}

.comment-body .comment-type-badge {
  font-size: .68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.comment-type-badge.type-rejection { background: var(--danger-bg); color: var(--danger); }
.comment-type-badge.type-approval { background: var(--success-bg); color: var(--success); }
.comment-type-badge.type-system { background: var(--b2); color: var(--b1); }

.comment-body .comment-text {
  font-size: .88rem;
  color: var(--d2);
  margin-top: 4px;
  line-height: 1.5;
}

.comment-form {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.comment-form textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--d5);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .85rem;
  resize: none;
  min-height: 44px;
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--g3);
}

/* Task action buttons */
.task-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--d6);
}

/* Reject reason */
.reject-reason-box {
  margin-top: 12px;
  padding: 14px;
  background: var(--danger-bg);
  border-radius: var(--radius);
  border: 1px solid #EF9A9A;
}

.reject-reason-box label {
  display: block;
  font-weight: 600;
  font-size: .82rem;
  color: var(--danger);
  margin-bottom: 6px;
}

.reject-reason-box textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #EF9A9A;
  border-radius: 6px;
  font-family: var(--font);
  font-size: .85rem;
  resize: vertical;
  min-height: 60px;
}

/* ============================================================
   TEMPLATES
   ============================================================ */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.template-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border-top: 3px solid var(--g3);
}

.template-card .tc-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--d1);
  margin-bottom: 4px;
}

.template-card .tc-desc {
  font-size: .82rem;
  color: var(--d3);
  margin-bottom: 12px;
}

.template-card .tc-meta {
  display: flex;
  gap: 12px;
  font-size: .78rem;
  color: var(--d4);
  margin-bottom: 12px;
}

.phase-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.phase-pill {
  padding: 3px 10px;
  background: var(--g5);
  color: var(--g1);
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 600;
}

/* ============================================================
   BRAIN / CEREBRO IA
   ============================================================ */
.brain-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.brain-metric-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}

.brain-metric-card .bm-value {
  font-size: 1.6rem;
  font-weight: 700;
}

.brain-metric-card .bm-label {
  font-size: .78rem;
  color: var(--d4);
  margin-top: 2px;
}

.brain-feed {
  margin-top: 16px;
}

.brain-entry {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  border-left: 4px solid var(--d5);
  transition: box-shadow .15s;
}

.brain-entry:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }

.brain-entry.severity-info { border-left-color: var(--b1); }
.brain-entry.severity-success { border-left-color: var(--g2); }
.brain-entry.severity-warning { border-left-color: var(--warning); }
.brain-entry.severity-critical { border-left-color: var(--danger); }

.brain-entry .be-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.brain-entry .be-body { flex: 1; }

.brain-entry .be-type {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--d4);
}

.brain-entry .be-message {
  font-size: .88rem;
  color: var(--d1);
  margin-top: 2px;
}

.brain-entry .be-action {
  font-size: .8rem;
  color: var(--g2);
  font-weight: 600;
  margin-top: 4px;
}

.brain-entry .be-time {
  font-size: .72rem;
  color: var(--d4);
  margin-top: 4px;
}

/* Brain alerts */
.alert-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  align-items: flex-start;
}

.alert-card.alert-warning {
  background: var(--warning-bg);
  border: 1px solid var(--o3);
}

.alert-card.alert-critical {
  background: var(--danger-bg);
  border: 1px solid #EF9A9A;
}

.alert-card.alert-info {
  background: var(--b2);
  border: 1px solid var(--b3);
}

.alert-card.alert-success {
  background: var(--success-bg);
  border: 1px solid var(--g4);
}

.alert-card .alert-icon { font-size: 1.1rem; }
.alert-card .alert-body { flex: 1; }

.alert-card .alert-title {
  font-weight: 600;
  font-size: .88rem;
}

.alert-card .alert-message {
  font-size: .82rem;
  color: var(--d3);
  margin-top: 2px;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-bar select {
  padding: 7px 12px;
  border: 1.5px solid var(--d5);
  border-radius: 6px;
  font-family: var(--font);
  font-size: .82rem;
  color: var(--d2);
  background: var(--white);
  cursor: pointer;
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--g3);
}

.filter-bar .filter-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--d4);
}

.filter-bar .filter-count {
  font-size: .75rem;
  color: var(--d4);
  margin-left: auto;
}

.filter-bar .btn-clear-filters {
  font-size: .78rem;
  color: var(--b1);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.filter-bar .btn-clear-filters:hover { text-decoration: underline; }

/* ============================================================
   TEAM CARDS
   ============================================================ */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.team-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border-top: 3px solid var(--g3);
}

.team-card.overloaded { border-top-color: var(--danger); }

.team-card .tc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.team-card .tc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--white);
}

.team-card .tc-info h4 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--d1);
}

.team-card .tc-info p {
  font-size: .78rem;
  color: var(--d4);
}

.team-card .tc-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.team-card .tc-stat {
  text-align: center;
}

.team-card .tc-stat .ts-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.team-card .tc-stat .ts-label {
  font-size: .7rem;
  color: var(--d4);
}

.overload-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--danger-bg);
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 10px;
}

.team-task-list {
  list-style: none;
}

.team-task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--d6);
  font-size: .82rem;
}

.team-task-item:last-child { border-bottom: none; }

/* ============================================================
   PROPOSALS
   ============================================================ */
.proposal-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 12px;
  border-left: 4px solid var(--b1);
}

.proposal-card .pc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.proposal-card .pc-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--d1);
}

.proposal-card .pc-client {
  font-size: .8rem;
  color: var(--d3);
}

.proposal-card .pc-amount {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--g1);
}

.proposal-card .pc-meta {
  display: flex;
  gap: 16px;
  font-size: .78rem;
  color: var(--d4);
  margin-bottom: 10px;
}

.proposal-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.proposal-status.ps-draft { background: var(--d6); color: var(--d3); }
.proposal-status.ps-sent { background: var(--b2); color: var(--b1); }
.proposal-status.ps-negotiation { background: var(--warning-bg); color: var(--warning); }
.proposal-status.ps-accepted { background: var(--success-bg); color: var(--success); }
.proposal-status.ps-rejected { background: var(--danger-bg); color: var(--danger); }
.proposal-status.ps-expired { background: var(--d6); color: var(--d4); }

/* ============================================================
   INVOICES TABLE
   ============================================================ */
.invoices-table-wrapper {
  overflow-x: auto;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.invoices-table {
  width: 100%;
  border-collapse: collapse;
}

.invoices-table th,
.invoices-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--d6);
  font-size: .85rem;
}

.invoices-table th {
  background: var(--d7);
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--d3);
}

.invoices-table tr:hover { background: var(--d7); }

.invoices-table .amount {
  font-weight: 700;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.invoice-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.invoice-status.is-draft { background: var(--d6); color: var(--d3); }
.invoice-status.is-sent { background: var(--b2); color: var(--b1); }
.invoice-status.is-paid { background: var(--success-bg); color: var(--success); }
.invoice-status.is-overdue { background: var(--danger-bg); color: var(--danger); }
.invoice-status.is-cancelled { background: var(--d6); color: var(--d4); }

/* ============================================================
   TIME TRACKER
   ============================================================ */
.time-tracker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--d7);
  border-radius: var(--radius);
}

.time-display {
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--d1);
}

/* ============================================================
   ATTACHMENTS
   ============================================================ */
.attachment-list {
  list-style: none;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--d6);
  font-size: .85rem;
}

.attachment-item:last-child { border-bottom: none; }

.attachment-item .att-icon { font-size: 1.1rem; }

.attachment-item .att-name {
  flex: 1;
  color: var(--b1);
  font-weight: 500;
}

.attachment-item .att-size {
  color: var(--d4);
  font-size: .78rem;
}

/* ============================================================
   CLIENT DETAIL
   ============================================================ */
.client-detail-header {
  padding: 24px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  color: var(--white);
}

.client-detail-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.client-detail-header .cdh-meta {
  display: flex;
  gap: 16px;
  font-size: .85rem;
  margin-top: 6px;
  opacity: .9;
}

.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.brand-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
  cursor: pointer;
  transition: box-shadow .15s;
}

.brand-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }

.brand-card .brand-name {
  font-weight: 700;
  font-size: .95rem;
  color: var(--d1);
}

.brand-card .brand-projects {
  font-size: .78rem;
  color: var(--d4);
  margin-top: 4px;
}

/* Client management */
.client-mgmt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.client-mgmt-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border-top: 3px solid var(--g3);
}

.client-mgmt-card .cmc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.client-mgmt-card .cmc-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--d1);
}

.client-mgmt-card .cmc-type {
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--d6);
  color: var(--d3);
}

.client-mgmt-card .cmc-brands {
  margin: 10px 0;
}

.cmc-brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--g5);
  color: var(--g1);
  border-radius: 12px;
  font-size: .78rem;
  font-weight: 600;
  margin: 2px 4px 2px 0;
}

.cmc-brand-tag .brand-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: .85rem;
  padding: 0 2px;
  font-weight: 700;
}

.cmc-brand-tag .brand-remove:hover { color: #B71C1C; }

.cmc-add-brand {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.cmc-add-brand input {
  flex: 1;
  padding: 6px 10px;
  border: 1.5px solid var(--d5);
  border-radius: 6px;
  font-family: var(--font);
  font-size: .82rem;
}

.cmc-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--d6);
}

/* ============================================================
   PHASE PREVIEW (in new project modal)
   ============================================================ */
.phase-preview {
  margin-top: 16px;
  padding: 14px;
  background: var(--d7);
  border-radius: var(--radius);
}

.phase-preview h4 {
  font-size: .82rem;
  font-weight: 700;
  color: var(--d3);
  margin-bottom: 10px;
}

.phase-preview-list {
  list-style: none;
}

.phase-preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: .82rem;
  color: var(--d2);
}

.phase-preview-item .pp-order {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--g3);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.phase-preview-item .pp-sla {
  margin-left: auto;
  font-size: .72rem;
  color: var(--d4);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--d1);
  color: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  font-size: .88rem;
  animation: toastIn .25s ease-out;
  max-width: 360px;
}

.toast.toast-success { background: var(--g2); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(12px); }
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--d1);
}

/* ============================================================
   MISC / UTILITIES
   ============================================================ */
.text-muted { color: var(--d4); }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .72rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.divider {
  height: 1px;
  background: var(--d6);
  margin: 16px 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-area {
    margin-left: 0;
  }

  .mobile-only {
    display: inline-flex;
  }

  .content {
    padding: 16px;
  }

  .topbar {
    padding: 10px 16px;
  }

  .kanban-board {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .templates-grid {
    grid-template-columns: 1fr;
  }

  .team-grid {
    grid-template-columns: 1fr;
  }

  .client-mgmt-grid {
    grid-template-columns: 1fr;
  }

  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }

  .notification-dropdown {
    width: calc(100vw - 32px);
    right: -80px;
  }

  .modal-overlay {
    padding: 16px;
  }

  .task-detail-meta {
    grid-template-columns: 1fr;
  }
}
