:root {
  /* Paleta TFF */
  --lime: #CFD500;
  --black: #000000;
  --white: #FFFFFF;
  --gray: #CBCBCB;

  /* Tonos derivados de la paleta (para fondos, bordes y legibilidad) */
  --bg: #F4F4F4;
  --surface: var(--white);
  --ink: var(--black);
  --ink-2: #262626;
  --muted: #5E5E5E;
  --line: #E4E4E4;
  --line-2: var(--gray);
  --lime-soft: #F4F6CC;
  --lime-ring: rgba(207, 213, 0, .45);
  --danger: #C62828;
  --danger-soft: #FDECEC;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .05);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .18);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: var(--ink); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; }

/* ---------- Botones e inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--lime); color: var(--black); }
.btn-primary:hover:not(:disabled) { background: var(--black); color: var(--lime); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--black); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #9F1F1F; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--lime-soft); color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; gap: 0; } }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px;
  font: inherit; color: var(--ink); background: var(--white); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--black); box-shadow: 0 0 0 3px var(--lime-ring); }
.input-wrap { position: relative; }
.input-wrap .icon-btn { position: absolute; right: 4px; top: 4px; }
.input.has-toggle { padding-right: 96px; }
.pwd-toggle {
  position: absolute; right: 5px; top: 5px; height: 30px; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.pwd-toggle:hover { background: var(--lime-soft); color: var(--black); }
.pwd-toggle svg { width: 16px; height: 16px; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #F5C2C2; }

/* ---------- Login ---------- */
body.auth {
  display: flex; flex-direction: column; min-height: 100vh;
  background:
    radial-gradient(1000px 520px at 0% -10%, rgba(207, 213, 0, .35) 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(203, 203, 203, .6) 0%, transparent 55%),
    var(--white);
}
body.auth.admin-mode {
  background:
    radial-gradient(1000px 520px at 0% -10%, rgba(207, 213, 0, .22) 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(203, 203, 203, .14) 0%, transparent 55%),
    var(--black);
}
.auth-main { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px;
  padding: 32px; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.auth-card h1 { font-size: 22px; margin: 22px 0 4px; text-align: center; }
.auth-card p.muted { margin: 0 0 22px; text-align: center; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px;
  background: var(--black); color: var(--lime); font-weight: 800; font-size: 13px; letter-spacing: .02em;
}
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
.badge-admin {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--black); background: var(--lime); padding: 4px 8px; border-radius: 999px; margin-left: auto;
}
.auth-footer { text-align: center; padding: 20px; color: var(--muted); font-size: 13px; }
.admin-mode .auth-footer, .admin-mode .auth-footer a { color: var(--gray); }
.admin-mode .auth-card { border-color: #222; }
.copy-link {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  color: inherit; font-size: 15px; vertical-align: middle; transition: background .15s, color .15s;
}
.copy-link:hover { background: var(--lime); color: var(--black); text-decoration: none; }
.back-link { display: block; margin-top: 18px; text-align: center; font-size: 13px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 24px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar.dark { background: var(--black); border-color: #1A1A1A; color: var(--white); }
.topbar.dark .brand small { color: var(--gray); }
.topbar.dark .brand-mark { background: var(--lime); color: var(--black); }
.topbar .brand { text-decoration: none; color: inherit; }
.topbar nav { display: flex; gap: 4px; margin-left: 16px; }
.topbar nav a {
  padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 600; text-decoration: none;
}
.topbar.dark nav a { color: var(--gray); }
.topbar nav a:hover { background: rgba(203, 203, 203, .25); text-decoration: none; }
.topbar nav a.active, .topbar.dark nav a.active { background: var(--lime); color: var(--black); }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--black); color: var(--lime); font-weight: 700; font-size: 13px;
}
.topbar.dark .avatar { background: var(--lime); color: var(--black); }
.user-chip .who { line-height: 1.2; }
.user-chip .who small { display: block; color: var(--muted); font-size: 12px; }
.topbar.dark .icon-btn { color: var(--gray); }
.topbar.dark .icon-btn:hover { background: #1A1A1A; color: var(--lime); }

/* ---------- Layout ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; }
.page-head .sub { margin-top: 4px; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 11px; color: var(--muted); width: 16px; height: 16px; }
.search .input { padding-left: 34px; width: 240px; height: 38px; }

/* ---------- Proyectos (carpetas) ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.folder {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  color: inherit; text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; cursor: pointer;
}
.folder:hover { transform: translateY(-2px); border-color: var(--black); text-decoration: none; box-shadow: 0 8px 24px rgba(0, 0, 0, .08); }
.folder { font-weight: 400; }
.folder-top { display: flex; align-items: flex-start; gap: 12px; }
.folder-icon { width: 44px; height: 44px; flex: none; }
.folder h3 { font-size: 16px; line-height: 1.3; word-break: break-word; }
.folder .desc { color: var(--muted); font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.folder .menu-btn { margin-left: auto; margin-top: -4px; margin-right: -6px; }
.progress { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: #EFEFEF; }
.progress span { display: block; height: 100%; }
.progress .p-done { background: var(--lime); }
.progress .p-doing { background: var(--black); }
.progress .p-todo { background: var(--gray); }
.folder .stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.folder .foot { border-top: 1px solid var(--line); padding-top: 10px; font-size: 12px; color: var(--muted); }
.folder-new {
  display: grid; place-items: center; min-height: 170px; border: 2px dashed var(--line-2); border-radius: 14px;
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; gap: 8px;
}
.folder-new:hover { border-color: var(--black); color: var(--black); background: var(--lime-soft); }
.folder-new div { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

.dropdown {
  position: fixed; z-index: 60; min-width: 170px; background: var(--white); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px;
}
.dropdown button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px;
  background: transparent; font: inherit; color: var(--ink-2); cursor: pointer; text-align: left;
}
.dropdown button:hover { background: var(--lime-soft); }
.dropdown button.danger { color: var(--danger); }
.dropdown button.danger:hover { background: var(--danger-soft); }

/* ---------- Detalle de proyecto ---------- */
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.crumbs a { color: var(--muted); font-weight: 400; }
.title-row { display: flex; align-items: center; gap: 12px; }
.title-row .folder-icon { width: 38px; height: 38px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--white); border: 1px solid var(--line); color: var(--ink-2);
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select.input { width: auto; height: 38px; min-width: 160px; }
.toolbar .spacer { flex: 1; }

.table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  overflow: auto; max-height: calc(100vh - 290px); min-height: 220px;
}
table.sheet { width: 100%; min-width: 1552px; border-collapse: separate; border-spacing: 0; }
.sheet th {
  position: sticky; top: 0; z-index: 2; background: var(--black); color: var(--white) !important; text-align: left; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; padding: 12px 10px; border-bottom: 1px solid var(--black);
  white-space: nowrap;
}
.sheet th.sortable { cursor: pointer; user-select: none; }
.sheet th.sortable:hover { color: var(--lime) !important; }
.sheet td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sheet tr:last-child td { border-bottom: 0; }
.sheet tbody tr:hover td { background: #FAFAFA; }
.sheet tr.is-new td { animation: flash 1.4s ease; }
@keyframes flash { from { background: var(--lime-soft); } to { background: transparent; } }
.sheet tr.is-target td { animation: target 2.6s ease; }
@keyframes target { 0%, 60% { background: var(--lime-soft); box-shadow: inset 0 2px 0 var(--lime), inset 0 -2px 0 var(--lime); } 100% { background: transparent; } }

.cell-input, .cell-text {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: transparent; font: inherit; color: var(--ink);
  padding: 7px 8px; outline: none; transition: border-color .15s, background .15s, box-shadow .15s;
}
.cell-input:hover, .cell-text:hover { border-color: var(--line-2); background: var(--white); }
.cell-input:focus, .cell-text:focus { border-color: var(--black); background: var(--white); box-shadow: 0 0 0 3px var(--lime-ring); }
.cell-text { resize: none; min-height: 38px; line-height: 1.45; overflow: hidden; display: block; }
.cell-text.scroll { overflow-y: auto; }
.counter { display: block; text-align: right; font-size: 11px; color: var(--muted); margin-top: 2px; padding-right: 4px; font-variant-numeric: tabular-nums; }
.counter.warn { color: var(--black); font-weight: 600; }
.counter.full { color: var(--danger); font-weight: 600; }
.week { display: block; font-size: 11px; color: var(--muted); padding-left: 9px; margin-top: 2px; }

select.status {
  appearance: none; -webkit-appearance: none; width: 100%; border: 1px solid transparent; border-radius: 999px;
  font: inherit; font-weight: 600; font-size: 13px; padding: 6px 28px 6px 12px; cursor: pointer; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23000000' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select.status:focus { box-shadow: 0 0 0 3px var(--lime-ring); }
select.status[data-status="Por iniciar"] { background-color: #E6E6E6; color: var(--black); }
select.status[data-status="En progreso"] {
  background-color: var(--black); color: var(--white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
select.status[data-status="Terminado"] { background-color: var(--lime); color: var(--black); }
select.status option { background: var(--white); color: var(--black); }

/* Pills de responsables */
.pills-field {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 38px; padding: 5px 6px;
  border: 1px solid var(--line); border-radius: 8px; cursor: text; transition: border-color .15s, background .15s;
}
.pills-field:hover { border-color: var(--line-2); background: var(--white); }
.pills-field.focus { border-color: var(--black); background: var(--white); box-shadow: 0 0 0 3px var(--lime-ring); }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--lime); color: var(--black); font-size: 12px; font-weight: 600; max-width: 100%;
}
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill button {
  display: grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%;
  background: transparent; color: inherit; cursor: pointer; padding: 0;
}
.pill button:hover { background: var(--black); color: var(--lime); }
.pill button svg { width: 12px; height: 12px; }
.pills-field input { flex: 1; min-width: 90px; border: 0; outline: none; font: inherit; background: transparent; padding: 4px; }

.picker-menu {
  position: fixed; z-index: 70; background: var(--white); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 260px; overflow-y: auto; min-width: 220px;
}
.picker-menu .opt {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px;
}
.picker-menu .opt.active { background: var(--lime-soft); color: var(--black); }
.picker-menu .opt .avatar { width: 24px; height: 24px; font-size: 10px; }
.picker-menu .opt.create { color: var(--black); font-weight: 700; }
.picker-menu .none { padding: 8px 10px; color: var(--muted); font-size: 13px; }

.meta { font-size: 12px; line-height: 1.4; padding-top: 6px; }
.meta strong { display: block; color: var(--ink); font-weight: 600; }
.meta span { color: var(--muted); }
.save-state { display: block; font-size: 11px; margin-top: 4px; min-height: 14px; }
.save-state.saving { color: var(--muted); }
.save-state.saved { color: var(--ink-2); font-weight: 600; }
.save-state.error { color: var(--danger); }

.add-row td { padding: 0; }
.add-row button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 14px 16px; border: 0; background: transparent;
  color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; text-align: left;
}
.add-row button:hover { color: var(--black); background: var(--lime-soft); }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button {
  padding: 10px 14px; border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--black); border-color: var(--lime); border-bottom-width: 3px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 16px; background: #F7F7F7; border-bottom: 1px solid var(--line); }
.list td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.list tr:last-child td { border-bottom: 0; }
.list .name-cell { display: flex; align-items: center; gap: 10px; font-weight: 600; }
code.username { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: #F1F1F1; padding: 2px 6px; border-radius: 6px; }
.field small.muted { font-size: 12px; }
.list .row-actions { text-align: right; white-space: nowrap; }
.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-admin { background: var(--black); color: var(--lime); }
.tag-user { background: #E6E6E6; color: var(--black); }
.tag-on { background: var(--lime); color: var(--black); }
.tag-off { background: var(--danger-soft); color: var(--danger); }

/* ---------- Modal y toasts ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .5); display: grid; place-items: center;
  padding: 16px; animation: fade .15s ease;
}
.modal { width: 100%; max-width: 460px; background: var(--white); border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.modal header { display: flex; align-items: center; padding: 18px 20px 6px; }
.modal header h2 { font-size: 18px; }
.modal header .icon-btn { margin-left: auto; }
.modal .body { padding: 12px 20px 4px; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches label { position: relative; cursor: pointer; }
.swatches input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--white); box-shadow: 0 0 0 1px var(--line-2); }
.swatches input:checked + span { box-shadow: 0 0 0 2px var(--black); }
.swatches input:focus-visible + span { outline: 2px solid var(--lime); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check.remember { margin: -2px 0 16px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--black); cursor: pointer; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px; border-radius: 10px; background: var(--black); color: var(--white); box-shadow: var(--shadow-lg);
  font-size: 13px; max-width: 360px; animation: pop .2s ease;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--black); border-left: 4px solid var(--lime); }

.btn-install { height: 34px; padding: 0 12px; flex: none; }
.sync-pill, .user-chip, .topbar .brand { flex: none; }

/* El círculo de iniciales nunca se deforma, aunque el texto de al lado sea largo. */
.avatar { flex: none; aspect-ratio: 1; }

/* ---------- Encabezado: campana y menú de usuario ---------- */
.tb-pop { position: relative; flex: none; }
.bell { position: relative; width: 38px; height: 38px; color: var(--ink-2); }
.bell svg { width: 20px; height: 20px; }
.bell-badge {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--lime); color: var(--black); border: 2px solid var(--white);
  font-size: 10px; font-weight: 800; line-height: 14px; text-align: center;
}
.topbar.dark .bell { color: var(--gray); }
.topbar.dark .bell-badge { border-color: var(--black); }
.avatar-btn { padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; flex: none; }
.avatar-btn:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

.tb-panel {
  position: absolute; right: 0; top: calc(100% + 12px); z-index: 50; background: var(--white); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.user-panel { width: 260px; padding: 8px; }
.user-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-head .avatar { width: 40px; height: 40px; font-size: 14px; background: var(--black); color: var(--lime); }
.user-head strong { display: block; font-size: 14px; }
.user-head small { color: var(--muted); font-size: 12px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 8px;
  background: none; font: inherit; color: var(--ink-2); cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--lime-soft); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }

.notif-panel { width: 380px; max-height: min(520px, 75vh); display: flex; flex-direction: column; overflow: hidden; }
.notif-panel header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.link-btn.small { margin: 0; padding: 2px 0; font-size: 12px; }
.notif-list { overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line);
  background: none; font: inherit; text-align: left; cursor: pointer; color: var(--ink-2);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: #FAFAFA; }
.notif-item.unread { background: var(--lime-soft); color: var(--ink); }
.notif-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: transparent; }
.notif-item.unread .notif-dot { background: var(--black); }
.notif-body { min-width: 0; }
.notif-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; line-height: 1.45; }
.notif-meta { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.topbar.dark .btn-install { background: transparent; color: var(--lime); border-color: #333; }

/* ---------- Sincronización sin conexión ---------- */
.sync-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--white); color: var(--ink); font: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.sync-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); }
.sync-pill .short { display: none; }
.sync-pill.off { background: var(--black); color: var(--white); border-color: var(--black); }
.sync-pill.off::before { background: var(--gray); }
.sync-pill.warn { background: var(--lime); border-color: var(--black); }
.sync-pill.warn::before { background: var(--black); }
.topbar.dark .sync-pill:not(.off):not(.warn) { background: transparent; color: var(--white); border-color: #333; }
.offline-banner {
  position: sticky; top: 60px; z-index: 19; padding: 10px 24px; background: var(--black); color: var(--white);
  font-size: 13px; border-bottom: 3px solid var(--lime);
}
.offline-banner strong { color: var(--lime); }
.meta-note { display: block; font-style: normal; font-size: 11px; margin-top: 4px; color: var(--muted); }
.meta-note.pending {
  display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--lime-soft);
  color: var(--black); font-weight: 700; border: 1px dashed var(--black);
}
.th-note { font-size: 10px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--gray); }

.modal.modal-wide { max-width: 620px; }
.modal .body { max-height: 70vh; overflow-y: auto; }
.conflict-intro { margin: 0 0 14px; color: var(--ink-2); line-height: 1.5; }
fieldset.conflict { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; margin: 0 0 12px; }
fieldset.conflict legend { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 0 6px; }
.conflict-opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  margin-top: 8px; cursor: pointer;
}
.conflict-opt:has(input:checked) { border-color: var(--black); background: var(--lime-soft); }
.conflict-opt input { margin-top: 3px; accent-color: var(--black); }
.conflict-opt b { display: block; }
.conflict-opt small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.conflict-opt .val { display: block; white-space: pre-wrap; word-break: break-word; font-size: 13px; }

/* ---------- Celular y tablet ---------- */
@media (max-width: 760px) {
  .topbar {
    padding: 0 12px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
    gap: 8px; height: calc(56px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  }
  .topbar .brand > div, .topbar .who, .topbar #logoutBtn { display: none; }
  .notif-panel { position: fixed; left: 8px; right: 8px; width: auto; top: calc(64px + env(safe-area-inset-top)); }
  .user-panel { width: min(280px, calc(100vw - 16px)); }
  .topbar nav { margin-left: 4px; gap: 2px; }
  .topbar nav a { padding: 7px 9px; font-size: 13px; }
  .btn-install span { display: none; }
  .offline-banner { top: calc(56px + env(safe-area-inset-top)); padding: 10px 12px; }
  .sync-pill { padding: 0 10px; }
  .sync-pill .long { display: none; }
  .sync-pill .short { display: inline; }
  .btn-install { width: 34px; padding: 0; }
  .page { padding: 18px 12px calc(40px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 22px; }
  .page-head .actions { width: 100%; margin-left: 0; }
  .page-head .actions .search { flex: 1; }
  .search .input { width: 100%; }
  .grid { grid-template-columns: 1fr; }

  /* Evita el zoom automático de iOS al enfocar campos */
  .input, .cell-input, .cell-text, .pills-field input, select.status { font-size: 16px; }

  .toolbar .search { flex: 1 1 100%; }
  .toolbar select.input { flex: 1; min-width: 0; }
  #addTop { width: 100%; }

  /* La tabla de actividades se convierte en tarjetas */
  .table-wrap { max-height: none; min-height: 0; overflow: visible; background: transparent; border: 0; box-shadow: none; border-radius: 0; }
  table.sheet { min-width: 0; display: block; }
  .sheet colgroup, .sheet thead { display: none; }
  .sheet tbody { display: block; }
  .sheet tbody tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; position: relative;
    background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--lime);
    border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; box-shadow: var(--shadow);
  }
  .sheet td { display: block; padding: 6px 0; border: 0; min-width: 0; }
  .sheet tbody tr:hover td { background: transparent; }
  .sheet td[data-label]::before {
    content: attr(data-label); display: block; margin: 0 0 3px 2px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  }
  .sheet td:nth-child(n+3) { grid-column: 1 / -1; }
  .sheet td.cell-actions { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
  .sheet td.cell-actions::before { display: none; }
  .cell-input, .cell-text, .pills-field { border-color: var(--line-2); background: var(--white); }
  .meta { padding-top: 0; }
  .sheet tr.add-row, #emptyRow { display: block; padding: 0; border: 0; box-shadow: none; background: transparent; }
  .sheet tr.add-row td, #emptyRow td { padding: 0; }
  .add-row button {
    justify-content: center; border: 2px dashed var(--line-2); border-radius: 14px; background: var(--white);
  }

  .card { overflow-x: auto; }
  table.list { min-width: 640px; }
  .tabs { overflow-x: auto; }
  .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}

/* App instalada (modo standalone): respeta el notch */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top)); }
}

/* ---------- Recuperar contraseña ---------- */
.link-btn {
  display: block; margin: 16px auto 0; padding: 4px 6px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: underline;
  text-decoration-color: var(--lime); text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.link-btn:hover { text-decoration-color: var(--black); }
.recover-result .input.recovered {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; font-weight: 600;
  background: var(--lime-soft); border-color: var(--black); letter-spacing: .02em;
}
.recover-actions { display: flex; gap: 10px; }
.recover-actions .btn { flex: 1; }
