/* ==========================================================================
   SMART - THREAD | Design System Oficial (Inspirado em https://threadbrasil.com/)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
  --font-poppins: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Brand Identity - Thread Brasil */
  --thread-red: #ca373b;
  --thread-red-hover: #df4347;
  --thread-red-soft: rgba(202, 55, 59, 0.14);
  --thread-red-border: rgba(202, 55, 59, 0.38);
  --thread-purple: #442d78;
  --thread-purple-light: #6d4cb8;
  --thread-purple-soft: rgba(68, 45, 120, 0.25);
  --thread-linen: #faf0e6;
  --thread-yellow: #ffe393;

  /* Status Semantic Colors */
  --color-success: #22c55e;
  --color-success-soft: rgba(34, 197, 94, 0.14);
  --color-warning: #f59e0b;
  --color-warning-soft: rgba(245, 158, 11, 0.15);
  --color-danger: #ef4444;
  --color-danger-soft: rgba(239, 68, 68, 0.16);
  --color-info: #38bdf8;
  --color-info-soft: rgba(56, 189, 248, 0.14);

  /* Dark Theme (Default - Padrão threadbrasil.com) */
  --bg-canvas: #0e0f11;
  --bg-surface-1: #16171b;
  --bg-surface-2: #1f2025;
  --bg-surface-3: #29292c;
  --bg-elevated: #2d2e34;
  --bg-glass: rgba(22, 23, 27, 0.88);
  --border-subtle: #2b2c32;
  --border-strong: #3d3e44;
  --grid-rule: rgba(61, 62, 68, 0.35);

  --text-primary: #ffffff;
  --text-secondary: #b9bcc6;
  --text-muted: #7f8391;
  --text-inverse: #0e0f11;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 22px 54px rgba(0, 0, 0, 0.62);

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --sidebar-w: 256px;
  --header-h: 64px;
}

[data-theme="light"] {
  --bg-canvas: #f3f4f6;
  --bg-surface-1: #ffffff;
  --bg-surface-2: #f8f9fb;
  --bg-surface-3: #eef0f4;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.92);
  --border-subtle: #e5e7eb;
  --border-strong: #d1d5db;
  --grid-rule: rgba(209, 213, 219, 0.45);

  --text-primary: #141519;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --text-inverse: #ffffff;

  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 25px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: var(--font-poppins);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* Custom Scrollbar (Idêntico ao site threadbrasil.com: 4px + #ca373b) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background: var(--bg-surface-2);
}
::-webkit-scrollbar-track {
  background: var(--bg-surface-2);
}
::-webkit-scrollbar-thumb {
  background: var(--thread-red);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--thread-red-hover);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   APP SHELL LAYOUT
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  position: relative;
  background-image:
    linear-gradient(to right, var(--grid-rule) 1px, transparent 1px);
  background-size: 33.333% 100%;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 74px 1fr;
}

/* SIDEBAR */
.sidebar {
  background: var(--bg-surface-1);
  border-right: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  transition: width 0.22s ease, transform 0.25s ease;
  overflow: hidden;
}

.brand-header {
  height: var(--header-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  gap: 10px;
}

.brand-identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(202, 55, 59, 0.35);
}

.brand-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-name span {
  color: var(--thread-red);
}

.brand-sub {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-collapsed .brand-titles,
.sidebar-collapsed .sidebar-section-label,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .workspace-box-details,
.sidebar-collapsed .sidebar-footer-text {
  display: none;
}

.workspace-switcher {
  margin: 14px 12px 8px;
  padding: 10px 12px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workspace-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-select {
  width: 100%;
  background: var(--bg-surface-3);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.workspace-select:focus {
  border-color: var(--thread-red);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 10px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(90deg, var(--thread-red-soft), rgba(68, 45, 120, 0.16));
  color: var(--text-primary);
  border-color: var(--thread-red-border);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 20%;
  height: 60%;
  width: 3px;
  background: var(--thread-red);
  border-radius: 0 4px 4px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--bg-surface-3);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
}

.nav-item.active .nav-badge {
  background: var(--thread-red);
  color: #fff;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
  flex-shrink: 0;
}
.status-dot.cloud {
  background: var(--color-info);
  box-shadow: 0 0 8px var(--color-info);
}
.status-dot.locked {
  background: var(--color-warning);
}

/* ==========================================================================
   MAIN WORKSPACE AREA & TOPBAR
   ========================================================================== */
.main-area {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  height: var(--header-h);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-strong);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  z-index: 25;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 240px;
}

.page-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-center {
  flex: 0 1 340px;
  min-width: 180px;
  display: flex;
  align-items: center;
}

.global-search-btn {
  width: 100%;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.global-search-btn > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.global-search-btn:hover {
  border-color: var(--thread-red);
  color: var(--text-secondary);
}

.kbd-hint {
  font-size: 10.5px;
  background: var(--bg-surface-3);
  border: 1px solid var(--border-strong);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--text-secondary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ACTIVE LIVE TIMER CHIP */
.live-timer-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--thread-red-soft);
  border: 1px solid var(--thread-red);
  color: var(--text-primary);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  animation: pulseBorder 2s infinite;
}

@keyframes pulseBorder {
  0%, 100% { box-shadow: 0 0 0 0 rgba(202, 55, 59, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(202, 55, 59, 0); }
}

/* ==========================================================================
   BUTTONS, INPUTS & BADGES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--bg-surface-3);
  border-color: var(--text-muted);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--thread-red);
  border-color: var(--thread-red);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--thread-red-hover);
  border-color: var(--thread-red-hover);
  box-shadow: 0 4px 14px rgba(202, 55, 59, 0.38);
}

.btn-purple {
  background: var(--thread-purple);
  border-color: var(--thread-purple-light);
  color: #ffffff;
}
.btn-purple:hover {
  background: #533891;
}

.btn-linen {
  background: var(--thread-linen);
  border-color: var(--thread-linen);
  color: #141519;
}
.btn-linen:hover {
  background: #ffffff;
}

.btn-danger {
  background: var(--color-danger-soft);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}
.btn-danger:hover {
  background: var(--color-danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-surface-2);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
}

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--thread-red);
  box-shadow: 0 0 0 3px var(--thread-red-soft);
}

.textarea {
  resize: vertical;
  min-height: 76px;
}

.form-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.prio-critica { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }
.prio-alta { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.prio-media { background: rgba(56, 189, 248, 0.16); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.32); }
.prio-baixa { background: rgba(148, 163, 184, 0.16); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }

/* ==========================================================================
   VIEW CONTAINER & SUB-TOOLBAR
   ========================================================================== */
.view-toolbar {
  padding: 12px 20px;
  background: var(--bg-surface-1);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  flex-shrink: 0;
}

.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.view-content {
  flex: 1;
  overflow: auto;
  padding: 18px 20px calc(28px + env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* ==========================================================================
   1. KANBAN BOARD (ESTILO TRELLO + THREAD)
   ========================================================================== */
.kanban-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

.kanban-column {
  width: 312px;
  min-width: 312px;
  max-height: 100%;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.kanban-column.drag-over {
  border-color: var(--thread-red);
  box-shadow: 0 0 0 2px var(--thread-red-soft);
}

.kanban-column.wip-exceeded {
  border-color: var(--color-danger);
}

.column-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.column-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.column-color-bar {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.column-title {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.column-count {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-surface-3);
  color: var(--text-secondary);
}

.column-cards {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 90px;
}

.task-card {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
}

.task-card:hover {
  border-color: var(--thread-red-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.task-card.dragging {
  opacity: 0.45;
  border: 1px dashed var(--thread-red);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--thread-purple-soft);
  color: #c4b5fd;
}
[data-theme="light"] .tag-pill {
  background: rgba(68, 45, 120, 0.12);
  color: var(--thread-purple);
}

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

.card-progress-bar {
  height: 4px;
  background: var(--bg-surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--thread-red), #f97316);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.card-progress-fill.done {
  background: var(--color-success);
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
}

.card-indicators {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface-3);
  color: var(--text-secondary);
  font-size: 10.5px;
}
.meta-chip.overdue {
  background: var(--color-danger-soft);
  color: #f87171;
  font-weight: 600;
}
.meta-chip.due-soon {
  background: var(--color-warning-soft);
  color: #fbbf24;
}

.avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--thread-red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-surface-2);
  flex-shrink: 0;
}

.column-footer {
  padding: 10px;
  border-top: 1px solid var(--border-subtle);
}

.add-column-card {
  width: 280px;
  min-width: 280px;
  background: rgba(41, 41, 44, 0.35);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   2. KPI CARDS & DASHBOARD / REPORTS / COSTS
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--thread-red);
}
.kpi-card.purple::after { background: var(--thread-purple-light); }
.kpi-card.green::after { background: var(--color-success); }
.kpi-card.amber::after { background: var(--color-warning); }

.kpi-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.kpi-value {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.kpi-foot {
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.panel {
  grid-column: span 12;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 1024px) {
  .panel.span-6 { grid-column: span 6; }
  .panel.span-7 { grid-column: span 7; }
  .panel.span-5 { grid-column: span 5; }
  .panel.span-8 { grid-column: span 8; }
  .panel.span-4 { grid-column: span 4; }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 14.5px;
  font-weight: 700;
}

/* ==========================================================================
   3. AGENDA / CALENDAR VIEW
   ========================================================================== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  border-top: 1px solid var(--border-strong);
  border-left: 1px solid var(--border-strong);
  background: var(--bg-surface-1);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.calendar-dow {
  padding: 10px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

.calendar-cell {
  min-height: 118px;
  padding: 8px;
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: background 0.15s ease;
}

.calendar-cell:hover {
  background: var(--bg-surface-2);
}

.calendar-cell.other-month {
  opacity: 0.42;
}

.calendar-cell.is-today {
  background: rgba(202, 55, 59, 0.07);
}

.calendar-day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

.today-badge {
  background: var(--thread-red);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
}

.cal-event-pill {
  padding: 4px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-surface-3);
  border-left: 3px solid var(--thread-red);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cal-event-pill.done {
  border-left-color: var(--color-success);
  opacity: 0.72;
  text-decoration: line-through;
}

/* ==========================================================================
   4. INTERACTIVE GANTT CHART
   ========================================================================== */
.gantt-shell {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: calc(100dvh - 185px);
  position: relative;
}

.gantt-table {
  min-width: 980px;
  width: max-content;
}

.gantt-header-row, .gantt-task-row {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
}

.gantt-header-row {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-strong);
}

.gantt-left-col {
  width: 290px;
  min-width: 290px;
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--bg-surface-1);
  border-right: 1px solid var(--border-strong);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.gantt-header-row .gantt-left-col {
  background: var(--bg-surface-2);
  z-index: 18;
  font-weight: 700;
  font-size: 12px;
}

.gantt-timeline-header {
  display: flex;
}

.gantt-day-cell {
  text-align: center;
  font-size: 10.5px;
  padding: 8px 2px;
  border-right: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.gantt-day-cell.weekend {
  background: rgba(127, 131, 145, 0.06);
}
.gantt-day-cell.today {
  background: var(--thread-red-soft);
  color: var(--thread-red);
  font-weight: 700;
}

.gantt-timeline-track {
  position: relative;
  display: flex;
  align-items: center;
  height: 46px;
  background-image: linear-gradient(to right, var(--border-subtle) 1px, transparent 1px);
}

.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--thread-red);
  z-index: 5;
  pointer-events: none;
}

.gantt-bar {
  position: absolute;
  height: 28px;
  border-radius: 7px;
  background: var(--bg-surface-3);
  border: 1px solid var(--thread-red);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 9px;
  z-index: 6;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease;
}
.gantt-bar:hover {
  transform: scaleY(1.06);
  z-index: 9;
}

.gantt-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--thread-red), var(--thread-purple));
  opacity: 0.82;
  z-index: 1;
}
.gantt-bar.done {
  border-color: var(--color-success);
}
.gantt-bar.done .gantt-bar-fill {
  background: var(--color-success);
}

.gantt-bar-label {
  position: relative;
  z-index: 2;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.65);
}

/* ==========================================================================
   5. TABLES (TEAM, COSTS, IMPORT PREVIEW, AUDIT)
   ========================================================================== */
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12.5px;
}

.data-table th {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: rgba(202, 55, 59, 0.04);
}

/* ==========================================================================
   6. MODALS, COMMAND PALETTE & LOCK VAULT
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 12, 0.76);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  width: 100%;
  max-width: 780px;
  max-height: 90dvh;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.18s ease-out;
}

.modal-dialog.modal-sm {
  max-width: 480px;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

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

/* DROPZONE */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 28px 20px;
  text-align: center;
  background: var(--bg-surface-2);
  cursor: pointer;
  transition: all 0.18s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--thread-red);
  background: var(--thread-red-soft);
}

/* TOAST NOTIFICATIONS */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 390px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--thread-red);
  color: var(--text-primary);
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  animation: modalIn 0.2s ease;
}
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-danger); }

/* VAULT LOCK OVERLAY */
.vault-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: radial-gradient(circle at top right, rgba(68, 45, 120, 0.32), transparent 45%),
              radial-gradient(circle at bottom left, rgba(202, 55, 59, 0.25), transparent 45%),
              #0e0f11;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.vault-screen.active {
  display: flex;
}
.vault-card {
  width: 100%;
  max-width: 410px;
  background: #16171b;
  border: 1px solid #3d3e44;
  border-radius: var(--radius-lg);
  padding: 30px 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   MOBILE & iOS RESPONSIVE ADAPTATION (iPhone / iPad Safe Areas)
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
}

.mobile-menu-overlay {
  display: none;
}

@media (max-width: 920px) {
  .app-shell, .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 275px;
    transform: translateX(-105%);
    z-index: 95;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-menu-overlay.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
  }

  .topbar {
    padding: 0 12px;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(58px + env(safe-area-inset-top, 0px));
  }

  .topbar-center {
    display: none;
  }

  .hide-mobile-btn {
    display: none !important;
  }

  .page-subtitle {
    display: none;
  }

  .view-content {
    padding: 12px 12px calc(78px + env(safe-area-inset-bottom, 0px));
  }

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

  /* Prevent iOS Safari auto-zoom on input focus */
  .input, .select, .textarea, .workspace-select {
    font-size: 16px;
  }

  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-surface-1);
    border-top: 1px solid var(--border-strong);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 80;
  }

  .mob-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 9px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
  }
  .mob-nav-btn.active {
    color: var(--thread-red);
  }
}

@media (max-width: 640px) {
  .hide-xs {
    display: none !important;
  }
  .topbar-actions {
    gap: 5px;
  }
  .topbar-actions .btn {
    padding: 6px 9px;
  }
  .kanban-column {
    width: 84vw;
    min-width: 84vw;
  }
}
