:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --sidebar-bg: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #94a3b8;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #111827;
  --surface-subtle: #1e293b;
  --sidebar-bg: #020617;
  --sidebar-text: #f1f5f9;
  --sidebar-muted: #94a3b8;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --border: #334155;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

h1, h2, h3, h4, p {
  margin: 0;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.small {
  font-size: 0.82rem;
}

.text-success { color: var(--success); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }

/* Toast */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 340px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-subtle); }

.btn-ghost {
  background: transparent;
  color: inherit;
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(148, 163, 184, 0.16); }

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
}
.btn-danger-ghost:hover { background: rgba(220, 38, 38, 0.12); }

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

.btn-full { width: 100%; }
.sm-btn { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Auth Shell */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-logo.sm {
  width: 34px;
  height: 34px;
  font-size: 0.85rem;
}

.brand-logo-img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.25);
}

.brand-logo-img.sm {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-subtle);
  padding: 4px;
  border-radius: 9px;
  border: 1px solid var(--border);
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 0.5rem;
  border-radius: 7px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.form-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

:root[data-theme="dark"] .form-error {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

/* Forms */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  font: inherit;
  font-weight: 400;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

/* App Shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.4rem 1.25rem;
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mobile-topbar {
  display: none;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  background: transparent;
  color: var(--sidebar-muted);
  border: none;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}

.lucide-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

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

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.nav-link-external {
  text-decoration: none;
  display: block;
  margin-top: 0.4rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  padding-top: 0.75rem;
}

.nav-hub-btn {
  margin-bottom: 0.35rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px 8px 0 0;
  padding-bottom: 0.7rem;
  color: #cbd5e1;
}

/* Unified Workspace Hub */
.hub-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background:
    radial-gradient(640px circle at 22% 24%, rgba(37, 99, 235, 0.09), transparent 65%),
    radial-gradient(600px circle at 78% 72%, rgba(15, 118, 110, 0.08), transparent 65%);
}

:root[data-theme="dark"] .hub-shell {
  background:
    radial-gradient(700px circle at 22% 24%, rgba(59, 130, 246, 0.14), transparent 65%),
    radial-gradient(640px circle at 78% 72%, rgba(20, 184, 166, 0.12), transparent 65%);
}

.hub-container {
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.hub-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

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

.hub-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.hub-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.hub-card-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hub-card-desc {
  font-size: 0.9rem;
  line-height: 1.45;
}

.xs-btn {
  padding: 0.22rem 0.55rem;
  font-size: 0.76rem;
  min-height: 28px;
}

.hub-card-footer {
  margin-top: auto;
  padding-top: 0.35rem;
}

.hub-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding-top: 0.25rem;
}

.pm-logo {
  background: #0f766e;
}

@media (max-width: 720px) {
  .hub-grid {
    grid-template-columns: 1fr;
  }
}

.sidebar-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  padding-top: 0.9rem;
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.user-pill {
  padding: 0 0.35rem;
  min-width: 0;
  flex: 1;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-email {
  color: var(--sidebar-muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-logout-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-logout-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.workspace {
  padding: 1.75rem 2rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.view-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input[type="date"] {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

:root[data-theme="dark"] .inline-form input[type="date"] {
  background: #131824;
  border-color: #2A3447;
  color: #F8FAFC;
  color-scheme: dark;
}

.inline-form input[type="date"]:focus {
  outline: 2px solid rgba(59, 130, 246, 0.3);
  border-color: var(--primary);
}

/* Cards & KPIs */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.kpi-card.subtle {
  background: var(--surface-subtle);
  box-shadow: none;
}

.kpi-label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.5rem; font-weight: 700; }

/* Filters */
.filter-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.quick-date-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.quick-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-right: 0.2rem;
}

.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  border-radius: 999px;
  padding: 0.28rem 0.72rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--primary);
}

.chip-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.filter-reset-link {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.filter-reset-link:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(115px, 1fr)) minmax(180px, 1.5fr);
  gap: 0.65rem;
  align-items: end;
}

.field.compact { min-width: 0; }
.field.grow { min-width: 0; }

/* Activity List */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--border);
}

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

.activity-main {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.activity-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.activity-title { font-weight: 600; font-size: 0.98rem; }
.activity-meta { font-size: 0.84rem; color: var(--muted); display: flex; gap: 0.75rem; flex-wrap: wrap; }
.activity-desc { font-size: 0.88rem; color: var(--text-secondary); white-space: pre-wrap; word-break: break-word; }

.row-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.row-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.row-menu-trigger:hover,
.row-menu-trigger[aria-expanded="true"] {
  background: var(--surface-subtle);
  border-color: var(--border);
  color: var(--text);
}

.row-menu-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.row-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.48rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.row-menu-item:hover {
  background: var(--surface-subtle);
}

.row-menu-item.danger {
  color: var(--danger);
}

.row-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.12);
}

/* Badges & Swatches */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text);
}

.status-toggle-btn {
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.status-toggle-btn:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.status-completed { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.status-in_progress { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.status-not_started { background: #f8fafc; color: #475569; border-color: #cbd5e1; }

:root[data-theme="dark"] .status-completed { background: rgba(16, 185, 129, 0.16); color: #34d399; border-color: rgba(16, 185, 129, 0.35); }
:root[data-theme="dark"] .status-in_progress { background: rgba(59, 130, 246, 0.16); color: #60a5fa; border-color: rgba(59, 130, 246, 0.35); }
:root[data-theme="dark"] .status-not_started { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.3); }

:root[data-theme="dark"] .report-item-btn.active { background: rgba(59, 130, 246, 0.18); }

.inline-edit-input {
  font: inherit;
  padding: 0.32rem 0.55rem;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-width: 140px;
}

.modal-sm { max-width: 400px; }

/* Settings */
.settings-tabs {
  display: flex;
  gap: 0.45rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
  flex-wrap: wrap;
}

.settings-tab-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 0.48rem 0.95rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.settings-tab-btn:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.settings-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.settings-card {
  max-width: 560px;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .theme-options {
    grid-template-columns: minmax(0, 1fr);
  }
}

.theme-option-btn {
  text-align: left;
  background: var(--surface-subtle);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.theme-option-btn:hover {
  border-color: var(--primary);
}

.theme-option-btn.active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
}

.security-stack {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.security-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.security-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.security-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.security-row-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.swatch-blue { background: #3b82f6; }
.swatch-purple { background: #8b5cf6; }
.swatch-emerald { background: #10b981; }
.swatch-red { background: #ef4444; }
.swatch-amber { background: #f59e0b; }
.swatch-teal { background: #14b8a6; }
.swatch-pink { background: #ec4899; }
.swatch-slate { background: #64748b; }

/* Reports */
.reports-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.report-item-btn {
  width: 100%;
  text-align: left;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.report-item-btn:hover { border-color: var(--primary); }
.report-item-btn.active { border-color: var(--primary); background: #eff6ff; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.compact-grid { margin-bottom: 1.2rem; }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.chart-card {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chart-card h4 {
  font-size: 0.86rem;
  color: var(--text);
}

.chart-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  background: transparent;
}

:root[data-theme="dark"] .chart-canvas {
  background: #111622;
}

.report-breakdown-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 1.75rem;
  align-items: start;
  margin-top: 0.5rem;
}

.report-summary-col,
.report-log-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.report-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.report-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.metric-list,
.highlight-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

:root[data-theme="dark"] .metric-row {
  border-bottom-color: #1E293B;
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-label {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.metric-value.is-muted {
  color: var(--muted);
  font-weight: 400;
}

.metric-empty {
  padding: 0.65rem 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.highlight-list.is-scrollable {
  max-height: 410px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.highlight-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.52rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
}

:root[data-theme="dark"] .highlight-row {
  border-bottom-color: rgba(30, 41, 59, 0.6);
}

.highlight-row:last-child {
  border-bottom: none;
}

.highlight-date {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.highlight-title {
  color: var(--text);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-theme="dark"] .highlight-title {
  color: #F1F5F9;
}

.highlight-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  white-space: nowrap;
}

:root[data-theme="dark"] .highlight-tag {
  background: rgba(30, 41, 59, 0.65);
  border-color: rgba(51, 65, 85, 0.7);
  color: #94A3B8;
}

.markdown-details {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.markdown-pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82rem;
  margin-top: 0.5rem;
}

/* Categories & Two-Col */
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.category-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 500;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border-radius: 12px;
  padding: 1.4rem;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
  max-height: 92vh;
  overflow-y: auto;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

/* WhatsApp Paste Auto-Fill */
.wa-import-box {
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
  padding: 0.55rem 0.75rem;
}

.wa-import-summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.wa-import-summary::-webkit-details-marker {
  display: none;
}

.wa-import-body {
  margin-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wa-import-body textarea {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  resize: vertical;
}

.wa-import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 1.75rem 1rem;
  font-size: 0.92rem;
}

/* Responsive (Tablet <= 960px & Phone <= 720px) */
body {
  -webkit-tap-highlight-color: transparent;
}

button,
.nav-btn,
.chip-btn,
.theme-option-btn {
  touch-action: manipulation;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 205px minmax(0, 1fr);
  }

  .workspace {
    padding: 1.25rem 1.15rem;
  }

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

  .reports-layout,
  .two-col,
  .charts-grid,
  .report-breakdown-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .activity-item {
    flex-direction: row;
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  html {
    scroll-padding-top: 64px;
  }

  .app-shell {
    display: block;
    min-height: 100vh;
  }

  /* Sticky compact mobile topbar */
  .mobile-topbar {
    display: block;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
  }

  .mobile-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.55rem max(12px, env(safe-area-inset-right)) 0.55rem max(12px, env(safe-area-inset-left));
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
  }

  .mobile-brand .brand-name {
    font-size: 0.98rem;
    color: var(--text);
  }

  .mobile-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
  }

  .mobile-topbar-actions .btn {
    min-height: 36px;
    padding: 0.35rem 0.65rem;
  }

  /* Fixed bottom tab bar */
  .sidebar {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: auto;
    overflow: visible;
    padding: 0 0 env(safe-area-inset-bottom);
    gap: 0;
    background: var(--surface);
    color: var(--text);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08);
  }

  :root[data-theme="dark"] .sidebar {
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.45);
  }

  .sidebar-top {
    width: 100%;
  }

  .brand-inline,
  .nav-hub-btn,
  .sidebar-footer {
    display: none;
  }

  .nav-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    width: 100%;
  }

  .nav-btn {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    min-height: 58px;
    padding: 7px 2px 6px;
    border-radius: 0;
    text-align: center;
    color: var(--muted);
  }

  .nav-btn:hover {
    background: transparent;
    color: var(--text);
  }

  .nav-btn.active {
    background: transparent;
    color: var(--primary);
  }

  .nav-btn.active::before {
    content: "";
    position: absolute;
    left: 20%;
    right: 20%;
    top: 0;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--primary);
  }

  .nav-icon {
    font-size: 19px;
  }

  .nav-label {
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.15;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Workspace spacing (clear of bottom bar) */
  .workspace {
    padding: 1rem max(12px, env(safe-area-inset-right)) calc(86px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    max-width: 100%;
  }

  .view-section {
    gap: 0.95rem;
  }

  .card {
    padding: 0.95rem;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .section-header > .btn,
  .section-header .inline-form,
  .section-header .inline-form .btn {
    width: 100%;
  }

  .section-header .inline-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .section-header .inline-form input[type="date"] {
    width: 100%;
    min-height: 44px;
  }

  /* Touch-friendly buttons & inputs */
  .btn {
    min-height: 42px;
  }

  .sm-btn {
    min-height: 38px;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 44px;
    font-size: 16px;
  }

  /* KPI cards */
  .kpi-grid {
    gap: 0.65rem;
  }

  .kpi-card {
    padding: 0.85rem;
  }

  .kpi-value {
    font-size: 1.35rem;
  }

  /* Quick range pills */
  .quick-date-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .quick-date-row::-webkit-scrollbar {
    display: none;
  }

  .quick-label,
  .chip-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .chip-btn {
    min-height: 36px;
    padding: 0.35rem 0.8rem;
  }

  /* Filter bar: 2-column grid for compact fields, full-width search & actions */
  .filter-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    align-items: end;
  }

  .field.compact {
    min-width: 0;
  }

  .field.grow,
  .filter-actions {
    grid-column: 1 / -1;
  }

  .filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .filter-actions .btn {
    width: 100%;
  }

  /* Activity rows stay aligned with right-side overflow menu */
  .activity-item {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.9rem 0;
  }

  .row-menu-trigger {
    width: 38px;
    height: 38px;
  }

  /* Report detail exports */
  .detail-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .detail-header .btn-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    width: 100%;
  }

  .detail-header .btn-row .btn {
    width: 100%;
    padding: 0.45rem 0.4rem;
    font-size: 0.78rem;
    text-align: center;
  }

  /* Settings tabs: full-width 3-column bar */
  .settings-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .settings-tab-btn {
    text-align: center;
    padding: 0.55rem 0.4rem;
    min-height: 40px;
  }

  .settings-card {
    max-width: none;
  }

  /* Workspace Hub on mobile */
  .hub-shell {
    align-items: flex-start;
    padding: 0.85rem max(12px, env(safe-area-inset-right)) 1.25rem max(12px, env(safe-area-inset-left));
  }

  .hub-container {
    gap: 0.85rem;
  }

  .hub-header {
    padding: 0.9rem 1rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.75rem;
  }

  .hub-brand {
    min-width: 0;
    gap: 0.65rem;
  }

  .hub-brand h1 {
    font-size: 1.2rem;
    line-height: 1.2;
  }

  .hub-brand .muted {
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .hub-header-actions .btn {
    min-height: 34px;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .hub-grid {
    gap: 0.85rem;
  }

  .hub-card {
    padding: 1rem;
    gap: 0.55rem;
  }

  .hub-card h2 {
    font-size: 1.15rem;
  }

  .hub-card-desc {
    font-size: 0.86rem;
  }

  .hub-card-status .xs-btn {
    min-height: 28px;
    padding: 0.2rem 0.5rem;
  }

  /* Auth card on mobile */
  .auth-shell {
    padding: 1rem;
  }

  .auth-card {
    padding: 1.25rem;
  }

  /* Modals on mobile */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 1.15rem 1rem calc(1.15rem + env(safe-area-inset-bottom));
    max-height: 90vh;
  }

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

  .modal-actions {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-actions .btn {
    width: 100%;
  }

  /* Toasts above bottom tab bar */
  .toast-container {
    top: auto;
    bottom: calc(74px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
  }

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 360px) {
  .nav-label {
    font-size: 9.5px;
  }

  .detail-header .btn-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  .sidebar .nav-btn {
    min-height: 48px;
    flex-direction: row;
    gap: 5px;
  }

  .workspace {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }
}
