/* ── Variables ───────────────────────────────────────────────────── */
:root {
  --c-primary:       #16A34A;
  --c-primary-dk:    #15803D;
  --c-primary-lt:    #4ADE80;
  --c-primary-bg:    #DCFCE7;
  --c-accent:        #22C55E;
  --c-bg:            #F5F5F5;
  --c-surface:       #FFFFFF;
  --c-border:        #E5E7EB;
  --c-text:          #111827;
  --c-text-2:        #6B7280;
  --c-text-3:        #9CA3AF;
  --c-green:         #16A34A;
  --c-amber:         #F59E0B;
  --c-red:           #EF4444;
  --c-gray:          #D1D5DB;
  --c-on-primary:    #FFFFFF;
  --nav-h:           60px;
  --safe-b:          env(safe-area-inset-bottom, 0px);
  --radius:          14px;
  --radius-sm:       10px;
  --shadow:          0 1px 4px rgba(0,0,0,.07);
  --shadow-md:       0 4px 16px rgba(0,0,0,.10);
  --header-h:        52px;
  --tabs-h:          42px;
}

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  min-height: calc(100% + env(safe-area-inset-top));
  /* El inset inferior lo gestionan .nav-bar/.view/.fab vía --safe-b: aplicarlo
     también aquí lo duplicaría en dispositivos con notch. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; overflow-x: hidden; width: 100%; }
body { background: var(--c-bg); color: var(--c-text); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea, select { font: inherit; }
/* Indicador de foco para navegación por teclado (el reset elimina el nativo) */
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ── Layout ──────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100dvh; }

.view {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
}

.view-inner { max-width: 480px; margin: 0 auto; padding: 0 16px 8px; }

/* ── Navigation bar ──────────────────────────────────────────────── */
.nav-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: fit-content;
  padding-bottom: var(--safe-b);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  display: flex; align-items: stretch;
  box-shadow: 0 -1px 0 var(--c-border);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: var(--c-text-3); padding: 6px 4px 0;
  transition: color .15s;
}
.nav-item.active { color: var(--c-primary); }
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 10px; font-weight: 600; line-height: 1; }

/* ── Page header (all screens except dashboard) ──────────────────── */
.page-header {
  background: var(--c-surface);
  color: var(--c-text);
  height: var(--header-h);
  padding: 0 20px;
  display: flex; align-items: center;
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--c-border);
}
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--c-text); }
/* Sub-pantallas (con botón atrás): título más compacto sin overrides inline */
.page-header .header-row h1 { font-size: 18px; margin: 0; }
.page-header .subtitle { display: none; }

.header-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 1; }
.header-nav-btn {
  background: var(--c-bg); border: none; color: var(--c-text);
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  flex-shrink: 0;
}
.header-nav-btn.nav-primary {
  background: var(--c-primary-bg); color: var(--c-primary);
}
.header-nav-btn.danger {
  background: #FEF2F2; color: var(--c-red);
}
.header-nav-btn:disabled { opacity: 0.35; cursor: default; }

/* ── Dashboard header ────────────────────────────────────────────── */
.dash-header {
  background: var(--c-surface);
  padding: 12px 20px 10px;
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 10;
}
.dash-title-row {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 480px; margin: 0 auto;
}
.dash-h1 { font-size: 22px; font-weight: 800; color: var(--c-text); line-height: 1.2; text-transform: capitalize; }
.dash-date-btn {
  position: relative; width: 38px; height: 38px; border-radius: 12px;
  background: var(--c-bg); color: var(--c-text-2);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0;
}
.dash-date-btn input[type=date] {
  position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer;
}

/* ── Day tag row ─────────────────────────────────────────────────── */
.day-tag-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--c-surface); padding: 10px 16px;
  border-bottom: 1px solid var(--c-border);
}
.day-tag-label { font-size: 13px; color: var(--c-text-2); white-space: nowrap; font-weight: 500; }
.day-tag-select {
  border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-bg); color: var(--c-text);
  font-size: 14px; padding: 7px 10px;
  min-width: 140px; max-width: 180px; cursor: pointer;
}
.day-tag-select:focus { outline: none; border-color: var(--c-primary); }
.day-tag-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.day-note-toggle {
  flex-shrink: 0; border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-bg); font-size: 18px; line-height: 1; padding: 5px 9px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.day-note-toggle.has-note { border-color: var(--c-primary); background: var(--c-primary-bg); }
.day-note-body {
  background: var(--c-surface); padding: 0 16px 12px;
  border-bottom: 1px solid var(--c-border);
}
.day-note-textarea {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 60px;
  border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-bg); color: var(--c-text);
  font-size: 14px; font-family: inherit; padding: 8px 10px;
}
.day-note-textarea:focus { outline: none; border-color: var(--c-primary); }
.day-note-text {
  font-size: 14px; color: var(--c-text); line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-bg); padding: 8px 10px;
}
/* Listado de notas por período (Histórico → Semana/Mes) */
.note-list-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 16px; border-bottom: 1px solid var(--c-border); cursor: pointer;
}
.note-list-item:last-child { border-bottom: none; }
.note-list-item:active { background: var(--c-bg); }
.note-list-date { font-size: 12px; color: var(--c-text-3); flex-shrink: 0; width: 52px; padding-top: 1px; }
.note-list-text {
  font-size: 13px; color: var(--c-text-2); line-height: 1.4; min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 10px;
}
.card-header {
  padding: 12px 16px; font-weight: 700; font-size: 11px;
  color: var(--c-text-3); letter-spacing: .6px; text-transform: uppercase;
  border-bottom: 1px solid var(--c-border);
}
.card-body { padding: 0; }

/* ── Category section separator (dashboard) ─────────────────────── */
.cat-section { margin-bottom: 16px; }
.cat-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2px 6px;
}
.cat-section-label { font-size: 13px; font-weight: 700; letter-spacing: 0.1px; display: flex; align-items: center; gap: 5px; }
.cat-section-icon { font-size: 15px; line-height: 1; text-transform: none; letter-spacing: 0; }
.category-toggle-btn, .cat-toggle-btn {
  background: none; padding: 0; border: none;
  font-size: 14px; line-height: 1; color: inherit; opacity: 0.55;
  transition: opacity .15s;
}

/* ── Objective row ───────────────────────────────────────────────── */
.obj-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--c-border);
}
.obj-row:last-child { border-bottom: none; }
.obj-icon { font-size: 22px; flex-shrink: 0; width: 28px; text-align: center; }
.obj-info { flex: 1; min-width: 0; }
.obj-name { font-size: 14px; font-weight: 500; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obj-meta { font-size: 12px; color: var(--c-text-3); margin-top: 2px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.obj-control { flex-shrink: 0; }
.obj-inherited-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  color: #0284C7; background: #F0F9FF; border: 1px solid #BAE6FD;
  border-radius: 8px; padding: 0 5px; line-height: 16px; vertical-align: middle;
}

/* Hidden dependents */
.obj-row.dependent { padding-left: 36px; }
.obj-row.hidden-dep { display: none; }

/* Secondary (dependent) objective rows */
.obj-row.nested-obj {
  padding: 9px 16px 9px 32px;
  background: #FAFAFA;
  position: relative;
}
.obj-row.nested-obj::before {
  content: '';
  position: absolute;
  left: 17px; top: 10px; bottom: 10px;
  width: 2px; border-radius: 1px;
  background: var(--c-border);
}
.obj-row.nested-obj .obj-icon { font-size: 18px; width: 24px; }
.obj-row.nested-obj .obj-name { font-size: 13px; color: var(--c-text-2); }
.obj-row.nested-obj .obj-meta { font-size: 11px; }
.obj-row.nested-obj .stepper-btn { width: 30px; height: 30px; }
.obj-row.nested-obj .stepper-val { font-size: 13px; width: 34px; }
.obj-row.nested-obj .toggle-btn { padding: 4px 10px; font-size: 13px; }
.obj-row.nested-obj .text-input { font-size: 13px; width: 114px; }
.obj-row.nested-obj .scale-btns { width: auto; }
.obj-row.nested-obj .scale-btn { font-size: 10px; }

/* ── Scale picker ────────────────────────────────────────────────── */
/* flex-wrap: los rangos de 11-20 valores se reparten en dos filas legibles */
.scale-btns { display: flex; flex-wrap: wrap; gap: 3px; width: 200px; justify-content: flex-end; }
.scale-btn {
  flex: 1 0 17px; min-width: 0; height: 26px; padding: 0;
  border-radius: 6px; border: 1.5px solid var(--c-border);
  background: var(--c-bg); color: var(--c-text-2);
  font-size: 11px; font-weight: 500; cursor: pointer;
  transition: background .1s, color .1s, border-color .1s;
}
.scale-btn.selected {
  background: var(--c-primary); color: #fff; border-color: var(--c-primary);
  font-weight: 700;
}

/* ── Stepper ─────────────────────────────────────────────────────── */
.stepper { display: flex; align-items: center; }
.stepper-btn {
  width: 36px; height: 36px; border-radius: 50%;
  color: var(--c-primary); background: var(--c-bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .12s, transform .1s; flex-shrink: 0;
}
.stepper-btn:active { opacity: 0.6; transform: scale(.88); }
.stepper-btn:disabled { opacity: 0.3; cursor: default; }
.stepper-val {
  width: 40px; text-align: center; font-size: 17px; font-weight: 700;
  color: var(--c-text); border: none; outline: none; background: transparent;
  -moz-appearance: textfield;
}
.stepper-val::-webkit-outer-spin-button,
.stepper-val::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ── Toggle ──────────────────────────────────────────────────────── */
.bool-toggle { display: flex; gap: 4px; }
.toggle-btn {
  padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--c-border); color: var(--c-text-2);
  background: var(--c-surface); transition: all .15s;
}
.toggle-btn.active-ok  { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.toggle-btn.active-bad { background: #FEF2F2; border-color: var(--c-red); color: var(--c-red); }

/* ── Text input (objective text type) ───────────────────────────── */
.text-input {
  border: 1.5px solid var(--c-border); border-radius: var(--radius-sm);
  padding: 6px 10px; font-size: 13px; width: 130px; outline: none;
  background: var(--c-bg); transition: border-color .15s;
}
.text-input:focus { border-color: var(--c-primary); background: var(--c-surface); }

/* ── Save / action buttons ───────────────────────────────────────── */
.save-bar {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b)); left: 0; right: 0; z-index: 50;
  padding: 12px 16px 0px 16px;
  background: linear-gradient(to top, var(--c-bg) 75%, transparent);
}
.btn-primary {
  display: block; width: 100%; max-width: 480px; margin: 0 auto;
  padding: 15px; border-radius: var(--radius); font-size: 15px; font-weight: 700;
  background: var(--c-primary); color: #fff;
  box-shadow: 0 4px 14px rgba(22,163,74,.3);
  transition: opacity .15s, transform .1s;
}
.btn-primary:active { opacity: .88; transform: scale(.99); }
.btn-primary:disabled { opacity: .45; }

.btn-secondary {
  padding: 10px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  border: 1.5px solid var(--c-primary); color: var(--c-primary);
  background: transparent; transition: background .15s;
}
.btn-secondary:active { background: var(--c-primary-bg); }

.btn-danger {
  padding: 10px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  background: #FEF2F2; border: 1.5px solid var(--c-red); color: var(--c-red);
}

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs {
  display: flex; background: var(--c-surface);
  border-bottom: 1px solid var(--c-border); position: sticky; top: var(--header-h); z-index: 5;
}
.tab-btn {
  flex: 1; text-align: center;
  padding: 12px 8px; font-size: 14px; font-weight: 600;
  color: var(--c-text-3);
  position: relative;
  transition: color .15s;
}
.tab-btn.active { color: var(--c-primary); }
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--c-primary);
}

/* ── Calendar ────────────────────────────────────────────────────── */
.calendar { padding: 8px 12px; }
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; font-weight: 700; font-size: 16px;
}
.cal-nav-btn {
  width: 32px; height: 32px; border-radius: 50%; background: var(--c-bg);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; margin-bottom: 4px;
}
.cal-weekday { text-align: center; font-size: 10px; font-weight: 700; color: var(--c-text-3); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: opacity .15s; margin: 0 auto;
}
.cal-day.empty { visibility: hidden; }
.cal-day.today { border: 2px solid var(--c-primary); font-weight: 700; }
.cal-day.c-green  { background: #DCFCE7; color: #15803D; }
.cal-day.c-amber  { background: #FEF3C7; color: #B45309; }
.cal-day.c-gray   { background: var(--c-bg); color: var(--c-text-3); }
.cal-day.c-red-light { background: #FEE2E2; color: #DC2626; }
.cal-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.cal-cell.empty { visibility: hidden; }
.cal-marks {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 1px; line-height: 1; min-height: 10px; max-width: 100%;
}
.cal-marks span { font-size: 9px; }
.cal-mark-more { font-size: 8px; font-weight: 600; color: var(--c-text-3); }

/* ── Week table ──────────────────────────────────────────────────── */
.week-table table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  table-layout: fixed;
}
.week-table th, .week-table td {
  padding: 7px 4px; text-align: center; border-bottom: 1px solid var(--c-border);
}
.week-table th { font-weight: 700; color: var(--c-text-2); background: var(--c-bg); }
.week-table .obj-col { text-align: left; width: 36%; }
.week-table .val-ok      { color: #15803D; font-weight: 700; }
.week-table .val-partial { color: #e68b03; font-weight: 700; }
.week-table .val-no      { color: #DC2626; font-weight: 700;}
.week-table .val-empty   { color: var(--c-text-3); }
.week-table .val-data    { color: var(--c-text-2); font-weight: 500; }
/* Valor guardado sin modificar (heredado del registro anterior) */
.week-table .val-inherited { opacity: 0.35; font-weight: 400; }
/* Fondo de color activado desde preferencia de apariencia */
.week-table--bg .val-ok      { background: #DCFCE7; }
.week-table--bg .val-partial { background: #FEF9C3; }
.week-table--bg .val-no      { background: #FEE2E2; }

/* Obj col inner layout */
.obj-col-inner { display: flex; align-items: flex-start; gap: 5px; }
.obj-col-icon { font-size: 16px; flex-shrink: 0; line-height: 1.2; }
.obj-col-info { min-width: 0; overflow: hidden; }
.obj-col-name {
  font-size: 12px; font-weight: 600; color: var(--c-text); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.obj-col-sub {
  font-size: 10px; color: var(--c-text-3); line-height: 1.4; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Dependent rows in week table */
.week-row-dep td { background: #FAFAFA; }
.week-row-dep .obj-col-inner { padding-left: 8px; border-left: 2px solid var(--c-border); }
.week-row-dep .obj-col-name { color: var(--c-text-2); font-weight: 500; }

/* ── Objective list (objectives screen) ──────────────────────────── */
.obj-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--c-border);
}
.obj-list-item:last-child { border-bottom: none; }
.obj-list-icon { font-size: 22px; flex-shrink: 0; }
.obj-list-info { flex: 1; min-width: 0; }
.obj-list-name { font-size: 15px; font-weight: 600; }
.obj-list-sub  { font-size: 12px; color: var(--c-text-3); margin-top: 2px; }
.obj-list-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 16px;
  background: var(--c-bg);
}
.icon-btn.danger { background: #FEF2F2; color: var(--c-red); }
.icon-btn.primary { background: var(--c-primary-bg); color: var(--c-primary); }
.icon-btn.sm { width: 30px; height: 30px; font-size: 14px; background: var(--c-bg); }
.icon-btn.sm:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── FAB ─────────────────────────────────────────────────────────── */
.fab {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); right: 20px; z-index: 50;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--c-primary); color: #fff; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(22,163,74,.35);
  transition: transform .15s;
}
.fab:active { transform: scale(.93); }

/* ── Form ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--c-text-2); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--c-border); font-size: 15px; outline: none;
  background: var(--c-surface); color: var(--c-text);
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--c-primary); }
.form-hint { font-size: 12px; color: var(--c-text-3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--c-red); margin-top: 4px; }

.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-option { display: none; }
.radio-label {
  padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--c-border); color: var(--c-text-2); cursor: pointer;
  transition: all .15s;
}
.radio-option:checked + .radio-label {
  background: var(--c-primary); border-color: var(--c-primary); color: #fff;
}

/* ── Analysis ────────────────────────────────────────────────────── */
/* Barra de controles pegajosa bajo las pestañas */
.sticky-bar {
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  padding: 10px 16px; position: sticky;
  top: calc(var(--header-h) + var(--tabs-h)); z-index: 5;
}
/* Cabecera de tarjeta de gráfica (icono + nombre del objetivo) */
.chart-card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 8px; border-bottom: 1px solid var(--c-border);
}
.chart-card-icon { font-size: 22px; flex-shrink: 0; }

.delta-pos { color: var(--c-primary); font-weight: 700; }
.delta-neg { color: var(--c-red); font-weight: 700; }
.delta-neu { color: var(--c-text-3); font-weight: 700; }

.section-title {
  font-size: 14px; font-weight: 700; color: var(--c-text);
  margin: 20px 0 10px; display: flex; align-items: center; gap: 8px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--c-border);
}

/* ── Categories screen ───────────────────────────────────────────── */
.cat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--c-border);
}
.cat-item:last-child { border-bottom: none; }
.cat-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.cat-item-icon { font-size: 22px; }
.cat-item-info { flex: 1; }
.cat-item-name { font-size: 15px; font-weight: 600; }
.cat-item-count { font-size: 12px; color: var(--c-text-3); }
.cat-item.inactive { opacity: .5; }

/* ── More / Settings ─────────────────────────────────────────────── */
.settings-group { background: var(--c-surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.settings-group-title { padding: 14px 16px 6px; font-size: 11px; font-weight: 700; color: var(--c-text-3); letter-spacing: .8px; text-transform: uppercase; }
.settings-item {
  display: flex; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--c-border); gap: 12px; cursor: pointer;
}
.settings-item:last-child { border-bottom: none; }
.settings-item-icon { font-size: 20px; flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; background: var(--c-primary-bg); display: flex; align-items: center; justify-content: center; }
.settings-item-info { flex: 1; }
.settings-item-name { font-size: 15px; font-weight: 500; }
.settings-item-sub  { font-size: 12px; color: var(--c-text-3); margin-top: 1px; }
.settings-arrow { color: var(--c-text-3); font-size: 16px; }

/* ── Tag management ──────────────────────────────────────────────── */
.tag-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--c-border);
}
.tag-item:last-child { border-bottom: none; }
.tag-badge {
  padding: 4px 12px; border-radius: 14px; font-size: 13px; font-weight: 500;
  background: var(--c-bg); color: var(--c-text-2);
}
.tag-system { font-size: 11px; color: var(--c-text-3); margin-left: 6px; }

/* ── Search bar ──────────────────────────────────────────────────── */
.search-bar {
  padding: 10px 16px 10px; background: var(--c-surface); position: sticky; top: var(--header-h); z-index: 5;
  border-bottom: 1px solid var(--c-border);
}
.search-input {
  width: 100%; padding: 9px 14px; border-radius: 24px;
  border: none; font-size: 14px; outline: none;
  background: var(--c-bg);
  transition: background .15s;
}
.search-input:focus { background: var(--c-border); }

/* ── Filter chips row ────────────────────────────────────────────── */
.filter-chips {
  display: flex; gap: 6px; padding: 10px 16px; overflow-x: auto;
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0; padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--c-border); color: var(--c-text-2); white-space: nowrap;
  background: var(--c-surface);
}
.filter-chip.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* ── Toggle switch (iOS-style) ───────────────────────────────────── */
.toggle-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  width: 44px; height: 26px; background: var(--c-border); border-radius: 13px;
  transition: background .2s; position: relative;
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-track { background: var(--c-primary); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Archived section toggle ─────────────────────────────────────── */
.archived-toggle {
  padding: 12px 16px; font-size: 13px; font-weight: 600; color: var(--c-text-3);
  display: flex; align-items: center; gap: 6px; cursor: pointer;
}

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.35); display: flex; align-items: flex-end;
}
.modal-sheet {
  width: 100%; max-width: 480px; margin: 0 auto;
  background: var(--c-surface); border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(24px + var(--safe-b));
  max-height: 90dvh; overflow-y: auto;
}
.modal-handle {
  width: 36px; height: 4px; border-radius: 2px; background: var(--c-border);
  margin: 0 auto 20px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn-primary { flex: 1; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 24px; background: var(--c-surface);
}
.login-logo { font-size: 60px; margin-bottom: 12px; }
.login-title { font-size: 26px; font-weight: 800; color: var(--c-primary); margin-bottom: 4px; }
.login-sub   { font-size: 14px; color: var(--c-text-3); margin-bottom: 36px; }
.login-form  { width: 100%; max-width: 320px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 16px 0 24px; }
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--c-border); background: transparent; transition: all .15s;
}
.pin-dot.filled { background: var(--c-primary); border-color: var(--c-primary); }
.pin-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.pin-key {
  height: 58px; border-radius: var(--radius); font-size: 22px; font-weight: 600;
  background: var(--c-bg); color: var(--c-text); transition: background .1s;
}
.pin-key:active { background: var(--c-primary-bg); }
.pin-key.del { font-size: 18px; }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); left: 50%;
  transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column;
  align-items: center; gap: 8px; width: 90%; max-width: 360px; pointer-events: none;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 600;
  color: #fff; box-shadow: var(--shadow-md); opacity: 0;
  animation: toast-in .3s forwards;
}
.toast.success { background: var(--c-primary); }
.toast.error   { background: var(--c-red); }
.toast.info    { background: #374151; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Utility ─────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-sm     { font-size: 13px; }
.text-muted  { color: var(--c-text-3); }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Tarjeta de estado vacío compacta y aviso de carga (Análisis) */
.empty-card { padding: 20px; text-align: center; font-size: 13px; color: var(--c-text-3); }
.loading-hint { padding: 24px; text-align: center; color: var(--c-text-3); font-size: 13px; }
.empty-state { padding: 48px 24px; text-align: center; color: var(--c-text-3); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }
.divider { height: 1px; background: var(--c-border); margin: 8px 0; }

/* ── Admin ───────────────────────────────────────────────────────── */
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--c-border);
}
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--c-primary-bg);
  color: var(--c-primary); display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; flex-shrink: 0;
}
.user-info { flex: 1; }
.user-name  { font-size: 15px; font-weight: 600; }
.user-email { font-size: 12px; color: var(--c-text-3); }
.badge {
  padding: 2px 8px; border-radius: 8px; font-size: 11px; font-weight: 700;
  background: var(--c-primary-bg); color: var(--c-primary);
}
.badge.admin { background: #DCFCE7; color: #15803D; }

/* ── Collapsed category sections ─────────────────────────────────── */
[data-cat-section].collapsed { display: none; }

/* ── Obj list — chevron style ────────────────────────────────────── */
.obj-list-item { cursor: pointer; transition: background .12s; }
.obj-list-item:active { background: var(--c-bg); }
.obj-list-item.is-archived { opacity: 0.55; }

.section-label {
  font-size: 13px; font-weight: 700; color: var(--c-text-2);
  margin: 18px 0 10px; letter-spacing: 0.1px;
}

/* ── History day view ────────────────────────────────────────────── */
.hist-day-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 20px; background: var(--c-surface);
  border-bottom: 1px solid var(--c-border); position: sticky; top: calc(var(--header-h) + var(--tabs-h)); z-index: 5;
}
.hist-nav-btn {
  width: 36px; height: 36px; border-radius: 50%; background: var(--c-bg);
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  color: var(--c-primary);
}
.hist-nav-btn:disabled { opacity: 0.3; }
.hist-nav-date {
  font-size: 15px; font-weight: 700; text-transform: capitalize;
  display: flex; align-items: center; gap: 8px;
}
.hist-nav-tag {
  font-size: 22px; line-height: 1;
}

/* Tag count chips (week/month summary) */
.tag-count-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 13px; font-weight: 600;
  background: var(--c-bg); color: var(--c-text-2);
  border: 1px solid var(--c-border); border-radius: 20px;
  padding: 3px 10px;
}

.hist-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--c-border); position: relative; }
.hist-row:last-child { border-bottom: none; }
.hist-row-dep { padding-left: 36px; background: #FAFAFA; }
.hist-row-dep::before {
  content: ''; position: absolute;
  left: 20px; top: 10px; bottom: 10px;
  width: 2px; border-radius: 1px; background: var(--c-border);
}
.hist-val { font-size: 14px; font-weight: 600; color: var(--c-text); white-space: nowrap; }
.hist-val-yes { color: var(--c-primary); }
.hist-val-no { color: var(--c-text-3); }

/* ── Misc ────────────────────────────────────────────────────────── */
