/* ============================================
   DEEPWORK — Délégation IA
   Dark premium theme
   ============================================ */

:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-card-hover: #1a1a1a;
  --border: #1e1e1e;
  --border-light: #2a2a2a;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.15);
  --accent-glow: rgba(0, 212, 170, 0.3);
  --red: #ff4757;
  --orange: #ffa502;
  --text: #ffffff;
  --text-secondary: #888888;
  --text-muted: #555555;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-width: 220px;
  --font-heading: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}

/* ============ LAYOUT ============ */

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============ SIDEBAR ============ */

#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  margin-bottom: 36px;
}

.brand-icon { color: var(--accent); display: flex; }
.brand-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--text);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.nav-item:hover { color: var(--text); background: var(--bg-card); }
.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.footer-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sync-indicator {
  display: block;
  font-size: 10px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.sync-indicator.synced { color: var(--accent); }
.sync-indicator.syncing { color: var(--orange); }
.sync-indicator.error { color: var(--red); }
.sync-indicator.idle { color: var(--text-muted); }

/* ============ MAIN ============ */

#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#main::-webkit-scrollbar { width: 6px; }
#main::-webkit-scrollbar-track { background: transparent; }
#main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.view { display: none; }
.view.active { display: block; }

.view-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 28px;
  color: var(--text);
}

/* ============ FOCUS VIEW ============ */

.focus-layout {
  display: flex;
  gap: 48px;
  align-items: flex-start;
  justify-content: center;
  min-height: calc(100vh - 100px);
}

.timer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: min(420px, 100%);
  max-width: 420px;
  flex-shrink: 0;
}

/* Timer Ring */

.timer-wrapper {
  position: relative;
  width: 340px;
  height: 340px;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ticks line {
  stroke: var(--border-light);
  stroke-width: 2;
}

.ticks line.tick-major {
  stroke: var(--text-muted);
  stroke-width: 2.5;
}

.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.timer-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.timer-time {
  font-family: var(--font-heading);
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  color: var(--text);
}

.timer-mode {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--accent);
  margin-top: 8px;
  text-transform: uppercase;
}

.timer-mode.break { color: var(--orange); }

/* Timer Controls */

.timer-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.btn-ctrl {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-ctrl:hover {
  background: var(--bg-card-hover);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-ctrl.btn-primary {
  width: 64px;
  height: 64px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.btn-ctrl.btn-primary:hover {
  background: #00e4b8;
  box-shadow: 0 0 24px var(--accent-glow);
}

.task-planner {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.task-planner[hidden] {
  display: none !important;
}

.task-preset-row,
.task-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.task-input-row input {
  flex: 1;
  min-width: 0;
}

#task-input,
#notion-search,
#custom-focus-minutes {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
}

#task-input:focus,
#notion-search:focus,
#custom-focus-minutes:focus {
  outline: none;
  border-color: var(--accent);
}

.task-minutes {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

#custom-focus-minutes {
  width: 70px;
  text-align: center;
}

.task-meta,
.task-empty {
  font-size: 12px;
  color: var(--text-muted);
}

.notion-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.notion-panel-head,
.notion-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notion-panel-head span {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.notion-toolbar {
  display: grid;
  gap: 8px;
}

.notion-filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.notion-filter {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
}

.notion-filter.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.notion-task-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.notion-empty {
  min-height: 96px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.notion-task-card {
  width: 100%;
  display: grid;
  grid-template-columns: 22px 26px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 66px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.notion-task-card:hover,
.notion-task-card.selected {
  border-color: var(--border-light);
  background: var(--bg-card);
}

.notion-task-card.done {
  opacity: 0.72;
  cursor: default;
}

.notion-task-card.done .notion-task-title {
  color: var(--text-secondary);
  text-decoration: line-through;
}

.notion-check {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--bg);
  background: transparent;
  font-size: 14px;
  font-weight: 800;
}

.notion-task-card.selected .notion-check {
  border-color: var(--border-light);
  background: #2f2f2f;
  color: var(--text);
}

.notion-task-card.done .notion-check {
  border-color: var(--border-light);
  background: #2f2f2f;
  color: var(--text);
}

.notion-task-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.notion-page-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 18px;
}

.notion-page-icon img {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
}

.notion-task-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notion-task-meta {
  color: var(--text-muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notion-badges {
  grid-column: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.notion-status,
.notion-dpg,
.notion-importance {
  max-width: 82px;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.notion-status.doing {
  background: rgba(180, 103, 45, 0.62);
  color: #ffe7d2;
}

.notion-status.todo {
  background: rgba(126, 86, 153, 0.72);
  color: #f1ddff;
}

.notion-status.done {
  background: rgba(82, 82, 82, 0.72);
  color: #e7e7e7;
}

.notion-dpg {
  background: rgba(163, 73, 68, 0.86);
  color: #ffe5e0;
}

.notion-importance {
  background: rgba(130, 61, 56, 0.9);
  color: #fff0ed;
}

.btn-compact {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 12px;
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.task-list {
  list-style: none;
  display: grid;
  gap: 8px;
}

.task-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.task-page-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 18px;
}

.task-page-icon img {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
}

.task-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.task-source {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.task-title {
  color: var(--text-secondary);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-remove {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.task-remove:hover {
  color: var(--red);
  background: rgba(255, 71, 87, 0.1);
}

.running-task-panel {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #0d0d0d;
}

.running-task-panel[hidden] {
  display: none !important;
}

.running-task-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.running-task-kicker {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
}

.running-task-count {
  font-size: 12px;
  color: var(--text-muted);
}

.running-task-list {
  list-style: none;
  display: grid;
  gap: 8px;
}

.running-task-item {
  min-height: 52px;
  cursor: default;
}

.running-task-item:hover {
  border-color: var(--border);
  background: var(--bg);
}

/* Session tracker */

.session-tracker {
  text-align: center;
}

#session-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.session-dots {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: center;
}

.session-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.session-dot.completed { background: var(--accent); }
.session-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* ============ QUICK STATS ============ */

.quick-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 320px;
  padding-top: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--border-light); }

.stat-today {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-ring-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.stat-ring { width: 100%; height: 100%; transform: rotate(-90deg); }

.stat-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.stat-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}

.stat-ring-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.stat-info { display: flex; flex-direction: column; gap: 2px; }

.stat-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.stat-goal-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-goal-label strong {
  color: var(--accent);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.stat-header .stat-value { font-size: 20px; }
.stat-header .stat-label { font-size: 12px; }

.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.8s ease;
  width: 0%;
}

.stat-goal {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-goal strong { color: var(--text-secondary); }

.stat-streak-card { text-align: center; position: relative; overflow: hidden; }
.stat-streak {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 4px;
}

.streak-fire {
  font-size: 28px;
  position: absolute;
  top: 12px;
  right: 16px;
  opacity: 0;
  transition: opacity 0.3s;
}

.streak-fire.visible { opacity: 1; }

.stat-week, .stat-month-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-streak { font-size: 48px; }
.stat-streak-card .stat-label { font-size: 13px; }

/* ============ DASHBOARD ============ */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.dash-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.dash-card-header h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
}

.dash-total {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

/* Weekly chart */

.weekly-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 160px;
  padding: 0 8px;
}

.weekly-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 6px;
}

.weekly-bar {
  width: 100%;
  max-width: 40px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
  position: relative;
}

.weekly-bar.today { background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.weekly-bar:not(.today) { background: var(--border-light); }

.weekly-bar-value {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.weekly-labels {
  display: flex;
  gap: 12px;
  padding: 8px 8px 0;
}

.weekly-label {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.weekly-label.today { color: var(--accent); font-weight: 700; }

/* Monthly grid */

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.month-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-secondary);
  position: relative;
  cursor: default;
}

.month-day.empty { visibility: hidden; }
.month-day.today { color: var(--accent); font-weight: 700; }

.month-day .day-heat {
  position: absolute;
  inset: 2px;
  border-radius: 4px;
  z-index: -1;
}

.month-day.h0 .day-heat { background: transparent; }
.month-day.h1 .day-heat { background: rgba(0, 212, 170, 0.1); }
.month-day.h2 .day-heat { background: rgba(0, 212, 170, 0.2); }
.month-day.h3 .day-heat { background: rgba(0, 212, 170, 0.35); }
.month-day.h4 .day-heat { background: rgba(0, 212, 170, 0.55); }

.month-day-header {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text); }

.month-nav { display: flex; gap: 4px; }

/* Goal ring */

.dash-goal { text-align: center; }

.goal-ring-wrapper {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 16px;
}

.goal-ring { width: 100%; height: 100%; transform: rotate(-90deg); }

.goal-ring-bg { fill: none; stroke: var(--border); stroke-width: 10; }
.goal-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.goal-ring-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.goal-current {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
}

.goal-target {
  font-size: 14px;
  color: var(--text-muted);
}

.goal-meta {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 8px;
}

.goal-meta-item { text-align: center; }
.goal-meta-value {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: block;
}
.goal-meta-label { font-size: 12px; color: var(--text-secondary); }

/* Top days */

.top-days-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.top-day {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.top-day-date { font-size: 13px; color: var(--text-secondary); }
.top-day-hours {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--accent);
}

.top-day-bar {
  flex: 1;
  margin: 0 16px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.top-day-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ============ HISTORY ============ */

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.history-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.select-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
}

.select-input option { background: var(--bg-card); }

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-light); }

.btn-danger {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover { background: rgba(255, 71, 87, 0.1); }

.history-summary {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
}

.summary-item {
  font-size: 13px;
  color: var(--text-secondary);
}

.summary-item strong {
  color: var(--accent);
  font-weight: 700;
}

.history-table-wrapper { position: relative; }

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.history-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.history-row {
  cursor: pointer;
}

.history-row:focus {
  outline: none;
}

.history-row:hover td,
.history-row:focus td {
  background: var(--bg-card);
  color: var(--text);
}

.history-row.is-selected td {
  background: var(--bg-card);
  color: var(--text);
  border-bottom-color: var(--border-light);
}

.history-table-task-list {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.history-table-task {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.history-table-task-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 16px;
}

.history-table-task-icon img {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
}

.history-table-task-title {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-table-empty {
  color: var(--text-muted);
}

.type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.type-badge.focus { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }
.type-badge.break { background: rgba(255, 165, 2, 0.15); color: var(--orange); }

.history-empty {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 14px;
  display: none;
}

.history-empty.visible { display: block; }

.history-detail {
  margin-top: 16px;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #0d0d0d;
}

.history-detail[hidden] {
  display: none !important;
}

.history-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.history-detail-title {
  display: grid;
  gap: 4px;
}

.history-detail-title span,
.history-task-heading span:last-child,
.history-detail-date {
  color: var(--text-muted);
  font-size: 12px;
}

.history-detail-title strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.history-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.history-detail-grid > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.history-detail-grid span {
  color: var(--text-muted);
  font-size: 11px;
}

.history-detail-grid strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-task-section {
  display: grid;
  gap: 8px;
}

.history-task-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.history-task-heading span:first-child {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.history-task-list {
  display: grid;
  gap: 8px;
}

.history-task-row {
  display: grid;
  grid-template-columns: 22px 26px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: inherit;
  text-decoration: none;
}

.history-task-row:hover {
  border-color: var(--border-light);
  background: var(--bg-card);
}

.history-task-empty {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
}

.history-detail-note {
  min-width: 0;
  padding-top: 2px;
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ SETTINGS ============ */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.settings-section h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: none; }

.setting-row label {
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.setting-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.setting-input-group input[type="number"],
.setting-input-group input[type="text"] {
  width: 64px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  text-align: center;
}

.setting-input-group input[type="text"] {
  width: min(220px, 42vw);
  text-align: left;
}

.setting-input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-suffix {
  font-size: 12px;
  color: var(--text-muted);
}

/* Toggle switch */

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 12px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

.file-input {
  font-size: 13px;
  color: var(--text-secondary);
  width: 180px;
}

.file-input::file-selector-button {
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  margin-right: 8px;
}

/* ============ TOAST ============ */

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1000;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ============ SESSION OVERLAY ============ */

.session-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  animation: overlay-in 0.3s ease;
}

.session-overlay.hidden {
  display: none;
}

.session-overlay-card {
  background: #1a1a1a;
  border: 1px solid #00d4aa;
  border-radius: 20px;
  padding: 48px 64px;
  text-align: center;
  box-shadow: 0 0 60px rgba(0, 212, 170, 0.15);
  animation: card-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.session-overlay-icon {
  margin-bottom: 24px;
}

.session-overlay-card h2 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 8px;
}

.session-overlay-card p {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0 32px;
}

.overlay-btn {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 48px;
  border: none;
  border-radius: 10px;
  background: #00d4aa;
  color: #0a0a0a;
  cursor: pointer;
  transition: background 0.2s;
}

.overlay-btn:hover {
  background: #00eabb;
}

.overlay-task-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 14px;
}

.overlay-task-actions.hidden {
  display: none;
}

.overlay-btn-secondary {
  background: transparent;
  color: #00d4aa;
  border: 1px solid #00d4aa;
}

.overlay-btn-secondary:hover {
  background: rgba(0, 212, 170, 0.12);
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes card-pop {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

/* ============ RESPONSIVE ============ */

@media (max-width: 1100px) {
  .focus-layout { flex-direction: column; align-items: center; }
  .quick-stats { flex-direction: row; flex-wrap: wrap; width: 100%; justify-content: center; }
  .quick-stats .stat-card { flex: 1; min-width: 200px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  #sidebar {
    width: 64px;
    min-width: 64px;
  }
  .brand-text, .nav-item span, .footer-label { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .sidebar-brand { justify-content: center; padding: 0; }
  #main { padding: 20px; }
  .timer-wrapper { width: 280px; height: 280px; }
  .timer-time { font-size: 56px; }
}

/* ============================================================
   V2 OVERHAUL — 2026-07-05
   Timer geant en haut a gauche, stats a droite, taches dessous.
   Tout est plus grand sur PC. Les regles ci-dessous ecrasent
   volontairement les anciennes (cascade en fin de fichier).
   ============================================================ */

/* ---------- Focus : structure ---------- */

.focus-layout {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 24px;
  min-height: 0;
}

.timer-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 8px 0 0;
}

.task-zone {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

@media (min-width: 1100px) {
  .focus-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas:
      "hero stats"
      "tasks stats";
    gap: 28px 44px;
    align-items: start;
  }
  .timer-hero { grid-area: hero; }
  .quick-stats { grid-area: stats; width: auto; padding-top: 4px; }
  .task-zone { grid-area: tasks; }
}

/* ---------- Timer geant ---------- */

.timer-wrapper {
  width: clamp(340px, 54vmin, 620px);
  height: clamp(340px, 54vmin, 620px);
}

.timer-time {
  font-size: clamp(72px, 13.5vmin, 152px);
  letter-spacing: -3px;
  font-variant-numeric: tabular-nums;
}

.timer-mode {
  font-size: clamp(13px, 1.6vmin, 18px);
  letter-spacing: 4px;
  margin-top: 12px;
}

.timer-controls { gap: 20px; margin-top: -4px; }

.btn-ctrl { width: 60px; height: 60px; }
.btn-ctrl.btn-primary { width: 76px; height: 76px; }

/* ---------- Zone taches : 2 colonnes ---------- */

.task-planner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 20px;
}

@media (min-width: 900px) {
  .task-planner {
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    align-items: start;
  }
}

.planner-manual {
  display: grid;
  gap: 12px;
  align-content: start;
}

.notion-panel { min-width: 0; }

/* ---------- Stats colonne droite : plus lisible ---------- */

.stat-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
}

.stat-card .stat-value { font-size: 30px; }
.stat-card .stat-label { font-size: 14px; }

.stat-streak-card {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.stat-streak-card .stat-value.stat-streak { font-size: 44px; }

/* ---------- Sync indicator ---------- */

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
}

.sync-indicator::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.sync-indicator.synced { color: var(--accent); }
.sync-indicator.synced::before { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.sync-indicator.syncing { color: var(--text-secondary); }
.sync-indicator.syncing::before { background: var(--orange); }
.sync-indicator.error { color: var(--red); }
.sync-indicator.error::before { background: var(--red); }
.sync-indicator.locked { color: var(--orange); }
.sync-indicator.locked::before { background: var(--orange); }
.sync-indicator.idle::before { display: none; }

/* ---------- Dashboard : resume + sous-titres ---------- */

.dash-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.dash-summary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-summary-value {
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.dash-summary-item:first-child .dash-summary-value { color: var(--accent); }

.dash-summary-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.dash-card-sub {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 400;
}

/* ---------- Historique : plus propre ---------- */

.history-table th {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}

.history-table td { padding: 14px 12px; font-size: 14px; }
.history-row { cursor: pointer; }
.history-row:hover td { background: var(--bg-card-hover); }
.history-row.is-selected td { background: var(--accent-dim); }

.history-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.history-summary .summary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.history-summary .summary-item strong {
  color: var(--text);
  font-family: var(--font-heading);
}

/* ---------- Ecran code d'acces ---------- */

.key-gate {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.key-gate.hidden { display: none; }

.key-gate-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 40px 44px;
  max-width: 380px;
  width: calc(100% - 40px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.key-gate-icon { color: var(--accent); }

.key-gate-card h2 {
  font-family: var(--font-heading);
  font-size: 22px;
}

.key-gate-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.key-gate-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.key-gate-card input {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 13px 16px;
  font-size: 16px;
  text-align: center;
  letter-spacing: 2px;
  outline: none;
}

.key-gate-card input:focus { border-color: var(--accent); }

.key-gate-error {
  font-size: 13px;
  color: var(--orange);
  min-height: 18px;
}

/* ---------- Echelle generale PC ---------- */

@media (min-width: 1400px) {
  #main { padding: 40px 56px; }
  .view-title { font-size: 28px; }
  .notion-task-title { font-size: 14.5px; }
}

/* ---------- Mobile : le timer reste roi ---------- */

@media (max-width: 768px) {
  .timer-wrapper { width: min(78vw, 340px); height: min(78vw, 340px); }
  .timer-time { font-size: clamp(56px, 17vw, 76px); }
  .task-planner { grid-template-columns: 1fr; }
}

/* ============ RECAP VIEW ============ */

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: auto;
  box-shadow: 0 0 8px var(--accent-glow);
}

.recap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.recap-header .view-title { margin-bottom: 0; }

.recap-kinds {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.recap-kind {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
}

.recap-kind:hover { color: var(--text); }
.recap-kind.active { background: var(--accent-dim); color: var(--accent); }

.recap-editor { margin-bottom: 20px; }

.recap-periodbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.recap-period {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 260px;
}

.recap-period-label {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
}

.recap-periodbar .btn-secondary { margin-left: auto; }

.recap-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.recap-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recap-stat-value {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.recap-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.recap-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 22px 0;
}

.recap-field { display: flex; flex-direction: column; gap: 8px; }
.recap-field.wide { grid-column: 1 / -1; }

.recap-field label {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.recap-field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 14px;
  min-height: 104px;
  resize: vertical;
  user-select: text;
  transition: border-color 0.2s;
}

.recap-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.recap-field textarea::placeholder { color: var(--text-muted); }

.recap-scores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 20px 0 4px;
  border-top: 1px solid var(--border);
}

.recap-score { display: flex; flex-direction: column; gap: 8px; }

.recap-score-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.recap-score-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.recap-score-value {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.recap-score-value.empty { color: var(--text-muted); }

.recap-score input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  cursor: pointer;
}

.recap-score input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}

.recap-score input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}

.recap-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  margin-top: 18px;
}

.recap-saved {
  font-size: 12px;
  color: var(--text-muted);
}

.recap-saved.ok { color: var(--accent); }

.recap-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding-bottom: 40px;
}

.recap-trend { min-height: 180px; }
.recap-trend svg { width: 100%; height: 180px; display: block; }

.recap-legend {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.recap-legend span { display: flex; align-items: center; gap: 6px; }
.recap-legend i {
  width: 14px;
  height: 2px;
  border-radius: 2px;
  display: inline-block;
}

.recap-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
  text-align: center;
}

.recap-history { max-height: 420px; overflow-y: auto; }
.recap-history::-webkit-scrollbar { width: 6px; }
.recap-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.recap-entry {
  border-bottom: 1px solid var(--border);
}

.recap-entry:last-child { border-bottom: none; }

.recap-entry > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 2px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
}

.recap-entry > summary::-webkit-details-marker { display: none; }
.recap-entry > summary:hover .recap-entry-title { color: var(--accent); }

.recap-entry-title {
  font-weight: 500;
  transition: color 0.2s;
}

.recap-entry-meta {
  margin-left: auto;
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.recap-entry-body {
  padding: 4px 2px 18px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
  user-select: text;
}

.recap-entry-body h4 {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 12px 0 4px;
}

.recap-entry-body p { white-space: pre-wrap; }

@media (max-width: 1100px) {
  .recap-fields { grid-template-columns: 1fr; }
  .recap-scores { grid-template-columns: repeat(2, 1fr); }
  .recap-bottom { grid-template-columns: 1fr; }
}
