/* ===== Design tokens ===== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2430;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 24px -8px rgba(16, 24, 40, 0.18);
  --sidebar-w: 252px;
  --header-h: 64px;
  --ease: 180ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
a { color: inherit; }
svg.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ===== App shell ===== */
.app-shell { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform var(--ease);
}
.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
}
.sidebar-brand .logo-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7c6ef2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
}
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg.icon { width: 17px; height: 17px; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.sidebar-footer .who { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; }
.sidebar-footer .who strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .who span { font-size: 11.5px; color: var(--text-faint); }

.sidebar-backdrop { display: none; }

/* ===== Main column ===== */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ===== Top header ===== */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hamburger {
  display: none;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); width: 34px; height: 34px;
  align-items: center; justify-content: center; cursor: pointer;
}
.topbar-titles { min-width: 0; }
.topbar-titles h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar-titles p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  border: 1px solid var(--border); background: var(--surface);
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: background var(--ease), border-color var(--ease);
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--ease), border-color var(--ease), transform var(--ease), opacity var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-primary:disabled { opacity: 0.65; cursor: not-allowed; }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn .spinner { display: none; }
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-label-idle { display: none; }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Content ===== */
.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ===== Hero / report header card ===== */
.hero-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  box-shadow: var(--shadow-sm);
}
.hero-title { display: flex; flex-direction: column; gap: 4px; }
.hero-title h2 { margin: 0; font-size: 20px; font-weight: 700; }
.hero-title .range-label { color: var(--text-muted); font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.hero-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero-controls form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-field {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 10px; background: var(--surface);
}
.date-field label { font-size: 11.5px; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.date-field input[type=date] { border: none; outline: none; font-size: 13px; background: transparent; color: var(--text); width: 128px; }
.period-nav { display: flex; gap: 4px; }

.saved-reports-select {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px; background: var(--surface); color: var(--text);
  max-width: 240px;
}

/* ===== KPI cards ===== */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 18px 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease), transform var(--ease);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.kpi-icon.total { background: var(--accent-soft); color: var(--accent); }
.kpi-icon.completed { background: var(--green-soft); color: var(--green); }
.kpi-icon.progress { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.rate { background: var(--blue-soft); color: var(--blue); }
.kpi-trend { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.kpi-trend.up { background: var(--green-soft); color: var(--green); }
.kpi-trend.down { background: var(--red-soft); color: var(--red); }
.kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; margin: 0 0 4px; }
.kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* ===== Analytics section ===== */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-header h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.panel-header p { margin: 2px 0 0; font-size: 12px; color: var(--text-faint); }

/* donut */
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.legend-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.legend-row .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.legend-row .lbl { display: flex; align-items: center; color: var(--text-muted); }
.legend-row .val { font-weight: 700; color: var(--text); }

/* activity */
.activity-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.activity-row { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.activity-dot.completed { background: var(--green); }
.activity-dot.inprogress { background: var(--amber); }
.activity-body { min-width: 0; }
.activity-body .a-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-body .a-meta { font-size: 12px; color: var(--text-faint); }
.panel-empty { padding: 24px 4px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ===== Tasks section ===== */
.tasks-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.tasks-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.tasks-header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.tasks-header p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-faint); }

.tasks-toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 20px; flex-wrap: wrap; border-bottom: 1px solid var(--border); background: #fbfbfc; }
.search-input-wrap { position: relative; flex: 1; min-width: 180px; }
.search-input-wrap svg.icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); width: 15px; height: 15px; }
.search-input-wrap input {
  width: 100%; padding: 8px 10px 8px 32px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; outline: none; background: var(--surface);
}
.search-input-wrap input:focus { border-color: var(--accent); }
.select-sm {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
  font-size: 13px; background: var(--surface); color: var(--text);
}
/* table */
.task-table { width: 100%; border-collapse: collapse; }
.task-table thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-faint); font-weight: 700; padding: 10px 20px; border-bottom: 1px solid var(--border);
}
.task-table tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--ease); }
.task-table tbody tr:hover { background: #fafafa; }
/* Contents are vertically centered within each row for an even, aligned
   look across columns of different heights, while staying left-aligned
   horizontally (text-align is untouched here). */
.task-table td { padding: 13px 20px; vertical-align: middle; text-align: left; font-size: 13.5px; }
.task-name-cell strong { display: block; font-weight: 600; color: var(--text); }
.task-name-cell .meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
}
.badge.completed { background: var(--green-soft); color: var(--green); }
.badge.inprogress { background: var(--amber-soft); color: var(--amber); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.done-by-cell { display: flex; align-items: center; gap: 8px; }
.done-by-cell .avatar { width: 26px; height: 26px; font-size: 10.5px; }

.action-preview { color: var(--text-muted); white-space: pre-line; max-width: 360px; }
.action-preview .clamp {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.view-details-link { color: var(--accent); font-size: 12px; font-weight: 600; margin-top: 4px; display: inline-block; cursor: pointer; }

/* mobile task cards (hidden on desktop) */
.task-cards { display: none; flex-direction: column; gap: 12px; padding: 16px; }
.task-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface); cursor: pointer;
}
.task-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.task-card h4 { margin: 0 0 6px; font-size: 14px; font-weight: 700; }
.task-card .who-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; }
.task-card .action-preview { font-size: 12.5px; }

.no-results { padding: 40px 20px; text-align: center; color: var(--text-faint); font-size: 13.5px; }

/* ===== Empty state ===== */
.empty-state {
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-lg);
  padding: 56px 24px; text-align: center;
}
.empty-state .icon-circle {
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
}
.empty-state h3 { margin: 0 0 6px; font-size: 16px; }
.empty-state p { margin: 0 0 20px; color: var(--text-muted); font-size: 13.5px; max-width: 380px; margin-left: auto; margin-right: auto; }
.empty-state .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ===== Modal / drawer ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 18, 25, 0.45); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity var(--ease);
}
.modal-overlay.open { display: flex; opacity: 1; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 520px;
  max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.98); opacity: 0; transition: transform var(--ease), opacity var(--ease);
}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); opacity: 1; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-header h3 { margin: 0; font-size: 15.5px; }
.modal-close { border: none; background: none; cursor: pointer; color: var(--text-faint); width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-row { display: flex; flex-direction: column; gap: 3px; }
.modal-row .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-faint); font-weight: 700; }
.modal-row .v { font-size: 13.5px; color: var(--text); white-space: pre-line; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* ===== Toasts ===== */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start;
  transform: translateX(120%); transition: transform var(--ease), opacity var(--ease); opacity: 0;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast .t-icon { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast.success .t-icon { background: var(--green-soft); color: var(--green); }
.toast.error .t-icon { background: var(--red-soft); color: var(--red); }
.toast .t-body strong { display: block; font-size: 13px; }
.toast .t-body span { font-size: 12px; color: var(--text-muted); }
.toast .t-close { margin-left: auto; border: none; background: none; cursor: pointer; color: var(--text-faint); }

/* ===== Skeleton ===== */
.skeleton { background: linear-gradient(90deg, #eef0f3 25%, #f7f8f9 37%, #eef0f3 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ===== Responsive ===== */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .analytics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(15,18,25,0.4); z-index: 30;
  }
  .sidebar-backdrop.open { display: block; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .hero-card { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 24px; }
  .task-table { display: none; }
  .task-cards { display: flex; }
  .tasks-toolbar { gap: 8px; }
  .topbar-titles p { display: none; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .hero-controls, .hero-controls form { width: 100%; }
  .date-field input[type=date] { width: 96px; }
}
/* ---------- Category badge + "reported" check button ---------- */
.badge.category {
  background: var(--bg, #f1f1f4);
  color: var(--text-muted, #555);
  border: 1px solid var(--border, #e2e2e6);
}

.reported-check {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border, #ddd);
  background: transparent;
  color: var(--text-faint, #aaa);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
}
.reported-check:hover { border-color: var(--green, #1e9e5a); color: var(--green, #1e9e5a); }
.reported-check.is-reported {
  background: var(--green, #1e9e5a);
  border-color: var(--green, #1e9e5a);
  color: #fff;
}
.reported-check.loading { opacity: .5; pointer-events: none; }