/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg: #0c0c0e;
  --surface: #131317;
  --surface2: #1a1a20;
  --surface3: #22222a;
  --border: rgba(255, 255, 255, 0.07);
  --border2: rgba(255, 255, 255, 0.12);
  --text-primary: #f0efe8;
  --text-secondary: #7a7a8a;
  --text-muted: #45454f;
  --accent: #da1818;
  --accent-dim: rgba(218, 24, 24, 0.15);
  --accent-glow: rgba(218, 24, 24, 0.08);
  --blue: #5b8def;
  --blue-dim: rgba(91, 141, 239, 0.15);
  --orange: #f5a623;
  --orange-dim: rgba(245, 166, 35, 0.15);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --gray: #5a5a68;
  --gray-dim: rgba(90, 90, 104, 0.2);
  --red: #f87171;
  --radius: 10px;
  --radius-lg: 16px;
  --font-display: 'Nunito', sans-serif;
  --font-body: 'Nunito', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --sidebar-w: 240px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface2: #f0efe8;
  --surface3: #e8e7df;
  --border: rgba(0, 0, 0, 0.07);
  --border2: rgba(0, 0, 0, 0.12);
  --text-primary: #18181e;
  --text-secondary: #5a5a6e;
  --text-muted: #9a9aaa;
  --accent: #dc0e0e;
  --accent-dim: rgba(220, 14, 14, 0.15);
  --accent-glow: rgba(220, 14, 14, 0.08);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.1);
  --orange: #d97706;
  --orange-dim: rgba(217, 119, 6, 0.1);
  --green: #16a34a;
  --green-dim: rgba(22, 163, 74, 0.1);
  --gray: #6b7280;
  --gray-dim: rgba(107, 114, 128, 0.1);
  --red: #dc2626;
}

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

html {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  transition: background var(--transition), color var(--transition);
  line-height: 1.5;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface3);
  border-radius: 99px;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background var(--transition);
}

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

.logo-mark {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

[data-theme="dark"] .logo-mark {
  background: var(--accent);
}

.logo-mark svg {
  width: 16px;
  height: 16px;
  fill: #0c0c0e;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.logo-version {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 1px;
}

.sidebar-date {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-date-label {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sidebar-date-value {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-secondary);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section-label {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: 17px;
  font-weight: 400;
  color: var(--text-secondary);
  user-select: none;
  position: relative;
}

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

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

[data-theme="light"] .nav-item.active {
  color: var(--accent);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--surface3);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 1px 6px;
  border-radius: 99px;
}

.nav-item.active .nav-badge {
  background: var(--accent-dim);
  color: var(--accent);
}

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

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 17px;
  color: var(--text-secondary);
}

.theme-toggle:hover {
  background: var(--surface2);
}

.toggle-track {
  width: 32px;
  height: 18px;
  background: var(--surface3);
  border-radius: 99px;
  position: relative;
  margin-left: auto;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-track.on {
  background: var(--accent);
}

[data-theme="light"] .toggle-track.on {
  background: var(--accent);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-track.on .toggle-thumb {
  transform: translateX(14px);
}

/* Topbar theme toggle button */
.topbar-theme-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.topbar-theme-btn:hover {
  background: var(--surface3);
  color: var(--text-primary);
  border-color: var(--border2);
}

.topbar-theme-btn svg {
  width: 16px;
  height: 16px;
}

/* Show sun in dark mode, moon in light mode */
[data-theme="dark"] .topbar-theme-btn .icon-moon {
  display: none;
}

[data-theme="light"] .topbar-theme-btn .icon-sun {
  display: none;
}

/* Sidebar theme toggle — keep for desktop, hide on mobile when sidebar hidden */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  transition: background var(--transition);
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar-spacer {
  flex: 1;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  width: 220px;
  transition: border-color var(--transition), background var(--transition);
}

.search-box:focus-within {
  border-color: var(--border2);
  background: var(--surface3);
}

.search-box svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--text-primary);
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--green);
  color: #0c0c0e;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}

.btn-primary:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary svg {
  width: 14px;
  height: 14px;
}

[data-theme="light"] .btn-primary {
  background: var(--green);
  color: white;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border2);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  opacity: 0.07;
  transform: translate(20px, -20px);
}

.stat-card.blue::before {
  background: var(--blue);
}

.stat-card.green::before {
  background: var(--green);
}

.stat-card.orange::before {
  background: var(--orange);
}

.stat-card.accent::before {
  background: var(--accent);
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.stat-card.blue .stat-icon {
  background: var(--blue-dim);
  color: var(--blue);
}

.stat-card.green .stat-icon {
  background: var(--green-dim);
  color: var(--green);
}

.stat-card.orange .stat-icon {
  background: var(--orange-dim);
  color: var(--orange);
}

.stat-card.accent .stat-icon {
  background: var(--accent-dim);
  color: var(--accent);
}

.stat-icon svg {
  width: 17px;
  height: 17px;
}

.stat-label {
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.2px;
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-sub {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
}

/* ============================================================
   SECTION HEADER
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-action {
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 400;
  transition: color var(--transition);
}

.section-action:hover {
  color: var(--text-primary);
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.filter-chip:hover {
  border-color: var(--border2);
  color: var(--text-primary);
}

.filter-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

[data-theme="light"] .filter-chip.active {
  color: var(--accent);
  border-color: var(--accent);
}

.filter-chip svg {
  width: 12px;
  height: 12px;
}

.filter-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 75px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item {
  display: grid;
  grid-template-columns: 75px 1fr;
  gap: 0;
  position: relative;
  animation: fadeSlide 0.4s ease both;
}

.timeline-item:nth-child(1) {
  animation-delay: 0.05s;
}

.timeline-item:nth-child(2) {
  animation-delay: 0.1s;
}

.timeline-item:nth-child(3) {
  animation-delay: 0.15s;
}

.timeline-item:nth-child(4) {
  animation-delay: 0.2s;
}

.timeline-item:nth-child(5) {
  animation-delay: 0.25s;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.timeline-time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 20px 20px 20px 0;
  gap: 2px;
  flex-shrink: 0;
}

.time-start {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1;
}

.time-end {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1;
}

.timeline-dot-area {
  position: absolute;
  left: 75px;
  top: 24px;
  transform: translateX(-50%);
  z-index: 2;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg);
}

.timeline-dot.blue {
  background: var(--blue);
}

.timeline-dot.green {
  background: var(--green);
}

.timeline-dot.orange {
  background: var(--orange);
}

.timeline-dot.gray {
  background: var(--gray);
}

.timeline-card {
  margin: 10px 0 10px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.timeline-card:hover {
  border-color: var(--border2);
  transform: translateX(3px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.timeline-card.active-timer {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue), 0 4px 20px var(--blue-dim);
}

.timer-pulse {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}

.timer-pulse::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  opacity: 0;
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0% {
    opacity: 0.6;
    transform: scale(0.8);
  }

  100% {
    opacity: 0;
    transform: scale(2);
  }
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.card-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition);
}

.timeline-card:hover .card-actions {
  opacity: 1;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--surface3);
  color: var(--text-primary);
  border-color: var(--border2);
}

.icon-btn.danger:hover {
  background: rgba(248, 113, 113, 0.1);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.3);
}

.icon-btn svg {
  width: 13px;
  height: 13px;
}

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

.status-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 99px;
  letter-spacing: 0.3px;
}

.status-badge.proses {
  background: var(--blue-dim);
  color: var(--blue);
}

.status-badge.selesai {
  background: var(--green-dim);
  color: var(--green);
}

.status-badge.pending {
  background: var(--orange-dim);
  color: var(--orange);
}

.status-badge.batal {
  background: var(--gray-dim);
  color: var(--gray);
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.cat-tag {
  font-size: 15px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 99px;
}

.priority-indicator {
  display: flex;
  gap: 2px;
  align-items: center;
}

.priority-bar {
  width: 3px;
  height: 10px;
  border-radius: 99px;
  background: var(--surface3);
}

.priority-bar.filled {
  background: var(--orange);
}

.priority-bar.p4.filled {
  background: var(--red);
}

.card-detail {
  margin-top: 8px;
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-duration {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-duration svg {
  width: 11px;
  height: 11px;
}

/* ============================================================
   CHART SECTION
   ============================================================ */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: background var(--transition), border-color var(--transition);
}

.chart-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.chart-placeholder {
  height: 140px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-top: 10px;
}

.bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  transition: opacity var(--transition);
  position: relative;
  overflow: hidden;
}

.bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px 4px 0 0;
}

.bar:hover {
  opacity: 0.8;
}

.bar-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

.pie-chart-wrap {
  display: flex;
  gap: 20px;
  align-items: center;
}

.pie-visual {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  flex-shrink: 0;
  background: conic-gradient(var(--accent) 0deg 140deg,
      var(--blue) 140deg 230deg,
      var(--orange) 230deg 290deg,
      var(--green) 290deg 360deg);
  position: relative;
}

.pie-visual::after {
  content: '';
  position: absolute;
  inset: 25px;
  border-radius: 50%;
  background: var(--surface);
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-pct {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ============================================================
   TIMER WIDGET
   ============================================================ */
.timer-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: background var(--transition);
}

.timer-display {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 300;
  letter-spacing: 2px;
  color: var(--text-primary);
  min-width: 130px;
}

.timer-display span {
  color: var(--blue);
}

.timer-info {
  flex: 1;
}

.timer-info-label {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.timer-info-name {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
}

.btn-timer-stop {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 9px;
  padding: 10px 18px;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-timer-stop:hover {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.4);
}

.btn-timer-stop svg {
  width: 14px;
  height: 14px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 28px;
  width: 520px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--surface3);
  color: var(--text-primary);
}

.modal-close svg {
  width: 14px;
  height: 14px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

.form-input,
.form-select,
.form-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  background: var(--surface3);
}

.form-select {
  appearance: none;
  cursor: pointer;
}

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

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.priority-selector {
  display: flex;
  gap: 6px;
}

.priority-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  cursor: pointer;
  text-align: center;
  font-size: 16px;
  color: var(--text-muted);
  transition: all var(--transition);
  font-family: var(--font-body);
}

.priority-btn:hover {
  border-color: var(--border2);
  color: var(--text-secondary);
}

.priority-btn.sel {
  border-color: var(--orange);
  background: var(--orange-dim);
  color: var(--orange);
  font-weight: 600;
}

.priority-btn.urgent.sel {
  border-color: var(--red);
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  justify-content: flex-end;
}

.btn-secondary {
  padding: 9px 18px;
  border: 1px solid var(--border);
  background: var(--green-dim);
  color: var(--green);
  color: var(--text-secondary);
  border-radius: 9px;
  font-family: var(--font-body);
  font-size: 17px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  background: var(--surface3);
  color: var(--text-primary);
}

.btn-submit {
  padding: 9px 22px;
  background: var(--green);
  color: #0c0c0e;
  border: none;
  border-radius: 9px;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-submit:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

[data-theme="light"] .btn-submit {
  color: white;
}

/* ============================================================
   MONITOR PAGE
   ============================================================ */
.monitor-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.monitor-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.25);
  color: var(--green);
  padding: 4px 12px;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.monitor-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.monitor-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 0;
}

.summary-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: center;
}

.summary-num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text-primary);
}

.summary-label {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.empty-icon svg {
  width: 22px;
  height: 22px;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 17px;
  line-height: 1.6;
}

/* ============================================================
   VIEWS
   ============================================================ */
.view {
  display: none;
  flex-direction: column;
  height: 100%;
}

.view.active {
  display: flex;
}

/* ============================================================
   CATEGORIES PAGE
   ============================================================ */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  group: true;
}

.cat-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
}

.cat-card-icon {
  font-size: 28px;
  margin-bottom: 10px;
}

.cat-card-name {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.cat-card-count {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-muted);
}

.cat-card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.cat-card:hover .cat-card-actions {
  opacity: 1;
}

.add-cat-card {
  background: var(--surface);
  border: 1px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 110px;
  color: var(--text-muted);
}

.add-cat-card:hover {
  background: var(--surface2);
  color: var(--text-secondary);
  border-color: var(--accent);
}

.add-cat-card svg {
  width: 20px;
  height: 20px;
}

.add-cat-card span {
  font-size: 17px;
}

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

.toast {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 17px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  animation: toastIn 0.3s ease;
  min-width: 220px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-icon svg {
  width: 11px;
  height: 11px;
}

.toast.success .toast-icon {
  background: var(--green-dim);
  color: var(--green);
}

.toast.info .toast-icon {
  background: var(--blue-dim);
  color: var(--blue);
}

/* ============================================================
   BOTTOM NAV (mobile only)
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
  align-items: center;
  justify-content: space-around;
  gap: 4px;
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  min-height: 52px;
  -webkit-tap-highlight-color: transparent;
}

.bnav-item.active {
  color: var(--accent);
}

.bnav-item svg {
  width: 20px;
  height: 20px;
}

.bnav-label {
  font-size: 14px;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
  line-height: 1;
}

/* ============================================================
   MOBILE TOPBAR
   ============================================================ */
.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--surface2);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn svg {
  width: 18px;
  height: 18px;
}

/* FAB */
.fab {
  display: none;
  position: fixed;
  bottom: calc(64px + 16px + env(safe-area-inset-bottom));
  right: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--green);
  color: #0c0c0e;
  border: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 150;
  transition: transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.fab:active {
  transform: scale(0.93);
}

.fab svg {
  width: 22px;
  height: 22px;
}

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  backdrop-filter: blur(2px);
}

/* ============================================================
   MODAL - mobile sheet
   ============================================================ */
@media (max-width: 640px) {
  .modal-overlay {
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    max-height: 92vh;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
  }

  .modal-overlay.open .modal {
    transform: translateY(0);
  }

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

  .form-group.full {
    grid-column: 1;
  }

  .priority-selector {
    flex-wrap: wrap;
  }

  .priority-btn {
    min-width: calc(50% - 4px);
  }
}

/* ============================================================
   RESPONSIVE — TABLET 768–1024px
   ============================================================ */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 200px;
  }

  .content {
    padding: 20px 20px;
    gap: 18px;
  }

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

  .two-col {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 20px;
    gap: 10px;
  }

  .search-box {
    width: 180px;
  }
}

/* ============================================================
   RESPONSIVE — MOBILE < 768px
   ============================================================ */
@media (max-width: 768px) {

  /* Layout shifts */
  body {
    flex-direction: column;
    overflow: auto;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background var(--transition);
    z-index: 100;
    height: 100%;
    width: 260px;
    min-width: 260px;
  }

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

  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: all;
  }

  .main {
    height: 100dvh;
    overflow: hidden;
  }

  .content {
    padding: 16px 16px calc(80px + env(safe-area-inset-bottom));
    gap: 16px;
    /* allow momentum scroll */
    -webkit-overflow-scrolling: touch;
  }

  /* Topbar */
  .topbar {
    padding: 0 16px;
    height: 56px;
    gap: 10px;
  }

  .topbar-title {
    font-size: 19px;
  }

  .search-box {
    display: none;
  }

  .topbar .btn-primary {
    display: none;
  }

  .mobile-menu-btn {
    display: flex;
  }

  /* FAB & bottom nav */
  .bottom-nav {
    display: flex;
  }

  .fab {
    display: flex;
  }

  /* Stats: 2 col */
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-value {
    font-size: 26px;
  }

  .stat-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 10px;
  }

  .stat-icon svg {
    width: 14px;
    height: 14px;
  }

  .stat-label {
    font-size: 14px;
  }

  .stat-sub {
    font-size: 13px;
  }

  /* Timer widget: stack */
  .timer-widget {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .timer-display {
    font-size: 30px;
  }

  .btn-timer-stop {
    width: 100%;
    justify-content: center;
  }

  /* Timeline: compact */
  .timeline::before {
    left: 55px;
  }

  .timeline-item {
    grid-template-columns: 55px 1fr;
  }

  .timeline-time {
    padding: 16px 12px 16px 0;
  }

  .time-start {
    font-size: 14px;
  }

  .time-end {
    font-size: 13px;
  }

  .timeline-dot-area {
    left: 55px;
    top: 20px;
  }

  .timeline-card {
    margin: 8px 0 8px 14px;
    padding: 12px 14px;
  }

  .card-title {
    font-size: 17px;
  }

  /* Always show actions on mobile (no hover) */
  .card-actions {
    opacity: 1;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
  }

  /* Two col → 1 col */
  .two-col {
    grid-template-columns: 1fr;
  }

  /* Filter bar: horizontal scroll */
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 6px;
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  .filter-chip {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 15px;
  }

  .filter-divider {
    display: none;
  }

  /* Monitor header */
  .monitor-header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 16px;
  }

  .monitor-summary {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .summary-num {
    font-size: 22px;
  }

  .summary-label {
    font-size: 14px;
  }

  /* Category grid */
  .cat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .cat-card {
    padding: 14px;
  }

  /* Section header */
  .section-header {
    margin-bottom: 10px;
  }

  /* Toast bottom offset */
  .toast-container {
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 16px;
  }
}

/* ============================================================
   RESPONSIVE — VERY SMALL < 380px
   ============================================================ */
@media (max-width: 380px) {
  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-value {
    font-size: 24px;
  }

  .monitor-summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }

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

  .timer-display {
    font-size: 26px;
  }
}

/* ============================================================
   Touch target improvements
   ============================================================ */
@media (hover: none) {
  .timeline-card:hover {
    transform: none;
    box-shadow: none;
  }

  .stat-card:hover {
    transform: none;
  }

  .btn-primary:hover {
    transform: none;
    opacity: 1;
  }

  .timeline-card:active {
    opacity: 0.85;
  }

  .icon-btn:active {
    background: var(--surface3);
  }

  .bnav-item:active {
    background: var(--surface2);
  }

  .filter-chip:active {
    background: var(--accent-dim);
  }
}

/* ============================================================
   PHOTO UPLOAD
   ============================================================ */
.photo-upload-area {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface2);
}

.photo-upload-area:hover,
.photo-upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Thumbnail in modal */
.photo-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.photo-thumb-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color .2s;
  display: block;
}

.photo-thumb-img:hover {
  border-color: var(--accent);
}

.photo-thumb-del {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  border: 2px solid var(--bg);
  transition: transform .15s;
}

.photo-thumb-del:hover {
  transform: scale(1.15);
}

.photo-thumb-del svg {
  width: 10px;
  height: 10px;
}

/* Lightbox */
.lb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.lb-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.lb-img {
  max-width: 96vw;
  max-height: 90dvh;
  object-fit: contain;
  border-radius: 10px;
}

.lb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
}

.lb-close svg {
  width: 18px;
  height: 18px;
}

.lb-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: background .2s;
}

.lb-arrow:hover {
  background: rgba(255, 255, 255, .22);
}

.lb-arrow svg {
  width: 20px;
  height: 20px;
}

.lb-arrow-left {
  left: 16px;
}

.lb-arrow-right {
  right: 16px;
}

.lb-caption {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 15px;
  color: rgba(255, 255, 255, .5);
}

/* Thumbnail strip on timeline cards */
.card-thumb-strip {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.card-thumb {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 7px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color .2s, transform .15s;
  flex-shrink: 0;
}

.card-thumb:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}
/* ============================================================
   CHARTS & STATS
   ============================================================ */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
@media(max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.chart-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.chart-placeholder { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding-top: 20px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 32px; border-radius: 6px 6px 0 0; transition: height var(--transition); }
.bar-label { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.pie-chart-wrap { display: flex; gap: 24px; align-items: center; }
.pie-visual { width: 120px; height: 120px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 4px var(--surface), 0 4px 12px rgba(0,0,0,0.2); }
.pie-legend { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; }
.legend-pct { margin-left: auto; font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text-primary); }


/* ============================================================
   CHARTS & STATS
   ============================================================ */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
@media(max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.chart-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.chart-placeholder { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding-top: 20px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 32px; border-radius: 6px 6px 0 0; transition: height var(--transition); }
.bar-label { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.pie-chart-wrap { display: flex; gap: 24px; align-items: center; }
.pie-visual { width: 120px; height: 120px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 4px var(--surface), 0 4px 12px rgba(0,0,0,0.2); }
.pie-legend { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; }
.legend-pct { margin-left: auto; font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--text-primary); }
