:root {
  /* Light theme with Catholic-inspired palette (Marian blue + gold) */
  --bg: #f8fafc;         /* slate-50 */
  --panel: #ffffff;      /* white */
  --muted: #f1f5f9;      /* slate-100 */
  --text: #0f172a;       /* slate-900 */
  --text-dim: #475569;   /* slate-600 */
  --brand: #1e40af;      /* indigo-800 */
  --accent: #eab308;     /* yellow-500 */
  --err: #dc2626;        /* red-600 */
}
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--text); font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; min-height:100vh; }
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.space { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--brand); letter-spacing: .2px; }
.muted { color: var(--text-dim); }
.small { font-size: 12px; }
.panel { background: var(--panel); border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; box-shadow: 0 10px 30px rgba(15,23,42,0.05); display: block; width: 100%; }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.panel-header h3 { margin: 0; }
.panel-header p { margin: 4px 0 0; }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.kpi { font-size: 28px; font-weight: 700; color: #0f172a; margin: 6px 0 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid #e5e7eb; white-space: normal; }
.table-profile th { width: 180px; color: var(--text-dim); font-weight: 600; }
.table-profile td { color: var(--text); }
.table-responsive { width: 100%; }
.table-compact th, .table-compact td { padding: 8px 10px; white-space: nowrap; }
.table-compact.targets-table td { white-space: normal; }
.targets-table tr.target-met td { color: #166534; font-weight: 600; }
.table-compact td a { text-decoration: none; }
.table-compact td a:hover { text-decoration: underline; }
.dataTables_wrapper { width: 100%; max-width: 100%; }
.button {
  background: var(--brand);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1.2;
  gap: 6px;
}
.button.secondary {
  background: var(--muted);
  color: var(--text);
  border: 1px solid #cbd5e1;
  text-decoration: none;
}
.button.ghost {
  background: transparent;
  color: var(--brand);
  border: 1px dashed #cbd5e1;
}
.button.ghost:hover { background: rgba(30,64,175,0.05); }

.list { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--panel); border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px; }
.flex { display:flex; gap: 12px; align-items:center; }
.right { text-align: right; }
.pill { display:inline-block; padding: 2px 8px; border-radius: 999px; background: #e2e8f0; color:#0f172a; font-size: 12px; }
.status-open { background: #dcfce7; color: #14532d; }
.status-in_progress { background: #ede9fe; color: #5b21b6; }
.status-completed { background: #fef3c7; color: #92400e; }
.status-expired { background: #fee2e2; color: #991b1b; }
.status-abandoned { background: #e2e8f0; color: #1f2937; }
.pill-off { background: #fee2e2; color: #991b1b; }
.user-flag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.user-flag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #e2e8f0; color: #0f172a; }
.user-flag.is-on { background: #dbeafe; color: #1e3a8a; font-weight: 600; }
.divider { height: 1px; background: #e5e7eb; margin: 16px 0; }
.field { margin-bottom: 12px; }
.field label { display:block; margin-bottom: 6px; color: var(--text-dim); font-size: 13px; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="search"],
input[type="number"],
input[type="url"],
.input,
select,
textarea {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
.input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
textarea { min-height: 90px; }
summary.button { cursor: pointer; display: inline-block; }
.flash { list-style: none; padding: 0; margin: 0 0 16px; }
.flash li { padding: 10px 12px; border-radius: 8px; margin-bottom: 8px; background: #eef2ff; color: #312e81; font-weight: 500; }
.flash li.error { background: #fee2e2; color: #991b1b; }
.flash li.success { background: #dcfce7; color: #14532d; }
.inline-form { display: inline; }
.is-hidden { display: none; }
.mt-sm { margin-top: 10px; }
.mt-xs { margin-top: 4px; }
.panel-stack { display: flex; flex-direction: column; gap: 16px; }
.table-editable input { width: 100%; }

/* Application shell */
.app-shell { min-height: 100vh; display: flex; background: var(--bg); }
.sidebar { width: 250px; background: #0f172a; color: #e2e8f0; display: flex; flex-direction: column; padding: 28px 24px 32px; position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.sidebar-logo { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, #1e40af, #4338ca); display: flex; align-items: center; justify-content: center; font-weight: 700; color: #f8fafc; }
.sidebar-title { font-size: 18px; font-weight: 600; color: #f8fafc; }
.sidebar-subtitle { font-size: 13px; color: #cbd5f5; }
.sidebar-section { margin-bottom: 24px; }
.sidebar-label { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: #64748b; margin-bottom: 12px; }
.sidebar-nav { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav li a { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; color: #e2e8f0; font-weight: 500; }
.sidebar-nav li a:hover { background: rgba(226, 232, 240, 0.12); text-decoration: none; }
.sidebar-nav li.is-active a { background: rgba(226,232,240,0.2); color: #f8fafc; }
.app-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid #e2e8f0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-headings { display: flex; flex-direction: column; gap: 4px; }
.topbar-title { margin: 0; font-size: 24px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.user-chip { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.user-name { font-weight: 600; }
.page { width: 100%; margin: 0 auto; padding: 32px; }

/* Login/auth */
.auth-page { background: #0f172a; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.auth-panel { background: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: center; }
.auth-panel .form { margin-top: 24px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.auth-logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, #1e40af, #4338ca); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.auth-hero { background: radial-gradient(circle at top, rgba(255,255,255,0.12), rgba(15,23,42,0.9)); color: #fff; padding: 64px; display: flex; flex-direction: column; justify-content: center; }
.auth-hero h1 { font-size: 42px; margin-bottom: 16px; }
.auth-hero p { max-width: 420px; line-height: 1.6; }
.auth-hero .pill { background: rgba(255,255,255,0.1); color: #f8fafc; border: 1px solid rgba(255,255,255,0.16); }
.auth-card { max-width: 420px; margin: 0 auto; width: 100%; }
.auth-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.auth-note { margin-top: 16px; color: #94a3b8; font-size: 13px; }

/* Forms / filters */
.filter-panel { margin-bottom: 16px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.filter-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dashboard-filters { margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.dashboard-filters .filter-core {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.dashboard-filters .filter-core .field { flex: 1 1 220px; margin: 0; }
.dashboard-filters .filter-core .field.status-field { flex: 0 0 200px; min-width: 180px; }
.filter-inline-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 260px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.filter-inline-controls .filter-actions {
  margin: 0;
  display: flex;
  gap: 8px;
}
.dashboard-filters .filter-extra {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
}
.dashboard-filters .filter-extra .field { margin: 0; }
.dashboard-filters .filter-extra[hidden] {
  display: none !important;
}

.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi-grid-wide { margin-top: 12px; }
.stat-columns {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 24px;
}
.stat-column {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
}
.stat-column-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-list {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
.stat-list.two-up {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.stat-card {
  background: var(--muted);
  border-radius: 10px;
  padding: 6px 14px;
  border: 1px solid #e2e8f0;
}
.stat-card .stat-label { font-size: 13px; color: var(--text-dim); margin-bottom: 4px; margin-top: 6px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-card .stat-meta { font-size: 12px; color: #64748b; margin-top: 4px; }

.panel-space-top { margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-grid-wide { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.full-row { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.assign-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.assign-form .field { flex: 1; min-width: 220px; margin: 0; }
.assign-form button { white-space: nowrap; }
.grid-balanced { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.list-gap { display: flex; flex-direction: column; gap: 12px; }
.table-hide-md { display: table-cell; }
.table-hide-sm { display: table-cell; }

/* Inline tooltip for ⓘ hints */
.hint { position: relative; display: inline-block; margin-left: 4px; cursor: help; font-weight: 700; color: var(--text-dim); }
.hint:focus { outline: none; }
.hint[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: auto;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,23,42,0.95);
  color: #fff;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
  z-index: 10;
}
.hint[data-tip]::before {
  content: '';
  position: absolute;
  top: auto;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(15,23,42,0.95);
  opacity: 0;
  transition: opacity .15s ease;
}
.hint:hover[data-tip]::after,
.hint:focus[data-tip]::after,
.hint:hover[data-tip]::before,
.hint:focus[data-tip]::before { opacity: 1; }

@media (max-width: 1024px) {
  .sidebar { display: none; }
  .topbar { position: static; }
  .page { padding: 24px 20px 40px; }
  .table-hide-md { display: none; }
  .filter-inline-controls { justify-content: flex-start; }
}

@media (max-width: 600px) {
  .panel-header { flex-direction: column; align-items: flex-start; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .table-hide-sm { display: none; }
}



.no-margin-top { margin-top: 0px; }
.no-margin-bottom { margin-bottom: 0px; }
