/* Control Horari PWA v31
   Estils unificats per capçalera, jornada i targetes base. */
:root {
  color-scheme: light dark;
  --bg: #f4f4f5;
  --surface: #ffffff;
  --soft: #f1f5f9;
  --text: #0a0a0a;
  --muted: #64748b;
  --border: #d4d4d8;
  --primary: #111111;
  --primary-text: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --danger-text: #ffffff;
  --warning: #facc15;
  --warning-soft: #fef3c7;
  --warning-text: #111111;
  --ok: #16a34a;
  --radius: 18px;
  --gap: 14px;
  --tap: 62px;
  --shadow: 0 10px 28px rgba(0, 0, 0, .10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #050505;
    --surface: #111111;
    --soft: #1f2937;
    --text: #ffffff;
    --muted: #cbd5e1;
    --border: #343434;
    --primary: #ffffff;
    --primary-text: #000000;
    --danger-soft: #450a0a;
    --warning-soft: #3f2f06;
    --shadow: 0 14px 34px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }
html, body { min-height: 100%; background: var(--bg); overflow-x: hidden; }
body {
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 20px;
  line-height: 1.38;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; }
button:disabled { opacity: .45; cursor: not-allowed; }
.hidden { display: none !important; }

/* Base layout */
.app-view { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: grid;
  gap: var(--gap);
}
.app-screen { display: none; gap: var(--gap); }
.app-screen.active { display: grid; }
.card, .stat-card, .warning-card, .notice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .04);
}
.card, .form-grid, .login-form, .manual-body, .settings-actions,
.history-list, .task-list, .day-details, .segment-list, .material-mini-list,
.home-active-task, .active-task-panel, .task-start-panel, .photo-actions, .notice-card {
  display: grid;
  gap: var(--gap);
}
.warning-card {
  background: var(--warning);
  color: var(--warning-text);
  font-weight: 900;
}
.warning-card.small-warning { font-size: 18px; }
.notice-card {
  min-height: 86px;
  place-content: center;
  text-align: center;
  font-weight: 950;
  line-height: 1.22;
}
.notice-card strong { font-size: clamp(24px, 6vw, 34px); line-height: 1.05; }
.notice-card span {
  display: block;
  min-height: 2.44em;
  white-space: pre-line;
  color: inherit;
  opacity: .92;
  font-size: clamp(18px, 4.8vw, 24px);
}
.notice-card.state-running { background: var(--danger-soft); border-color: var(--danger); color: var(--text); }
.notice-card.state-paused { background: var(--warning-soft); border-color: #eab308; color: var(--text); }
.notice-card.state-idle { background: var(--surface); color: var(--text); }
.muted, .tiny-note, .history-sub, .task-sub, .material-sub { color: var(--muted); font-size: 18px; line-height: 1.45; }
.tiny-note { margin: 8px 0 0; }
.left-note { text-align: left; }
.eyebrow { display: none; }

/* Login */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(480px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 28px; padding: 22px; box-shadow: var(--shadow); }
.brand-block { display: grid; gap: 10px; justify-items: center; text-align: center; margin-bottom: 18px; }
.brand-logo { width: 84px; height: 84px; border-radius: 24px; display: grid; place-items: center; background: var(--primary); color: var(--primary-text); font-size: 44px; font-weight: 1000; }
.brand-block h1 { margin: 0; font-size: 32px; line-height: 1; }

/* Header reutilitzable: dos blocs iguals visualment */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  color: #fff;
  background: #111;
}
.app-header.running-header { background: var(--danger); color: var(--danger-text); }
.app-header.paused-header { background: var(--warning); color: var(--warning-text); }
.app-header.idle-header { background: #111; color: #fff; }
@media (prefers-color-scheme: dark) { .app-header.idle-header { background: #fff; color: #000; } }
.menu-toggle {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, .18);
  color: currentColor;
  border: 1px solid rgba(255, 255, 255, .35);
  font-size: 27px;
  line-height: 1;
}
.app-header.paused-header .menu-toggle,
.app-header.idle-header .menu-toggle { background: rgba(0, 0, 0, .10); border-color: rgba(0, 0, 0, .22); }
.status-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.status-cell {
  min-width: 0;
  display: grid;
  gap: 1px;
  line-height: 1.08;
  padding: 3px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
}
.app-header.paused-header .status-cell,
.app-header.idle-header .status-cell { background: rgba(0, 0, 0, .08); }
.status-cell span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  opacity: .82;
  font-style: italic;
}
.status-cell strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 21px;
  font-weight: 1000;
  letter-spacing: -.01em;
}
.connection-icon {
  justify-self: end;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  text-indent: -999px;
  overflow: hidden;
  border: 2px solid currentColor;
  background: var(--danger);
}
.connection-icon.online { background: var(--ok); }
.connection-icon.offline { background: var(--danger); }
.nav-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 10px;
  right: 10px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.nav-link { min-height: 54px; border-radius: 14px; background: var(--soft); color: var(--text); font-weight: 950; text-align: left; padding: 0 16px; }
.nav-link.active { background: var(--primary); color: var(--primary-text); }

/* Títols i mètriques */
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); margin-bottom: 10px; }
.section-title h2, .section-title h3 { margin: 0; font-size: 32px; line-height: 1.05; }
.centered-title { justify-content: center; text-align: center; margin: 0; }
.centered-title h2 { width: 100%; font-size: clamp(30px, 7.2vw, 44px); font-weight: 1000; letter-spacing: -.02em; }
.work-card { display: grid; gap: 16px; min-height: 190px; }
.day-work-card { text-align: center; }
.work-card.state-running { background: var(--danger-soft); border-color: var(--danger); }
.work-card.state-paused { background: var(--warning-soft); border-color: #eab308; }
.metric-row { display: grid; grid-template-columns: minmax(100px, .75fr) minmax(0, 1.25fr); align-items: center; gap: 14px; }
.metric { min-width: 0; display: grid; gap: 5px; }
.metric-left { justify-items: start; text-align: left; }
.metric-right { justify-items: end; text-align: right; }
.big-value {
  display: block;
  color: var(--text);
  font-size: clamp(46px, 12.5vw, 76px);
  line-height: 1.08;
  font-weight: 1000;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.metric-left .big-value { font-size: clamp(40px, 11vw, 64px); }
.metric span, label, .summary-row span {
  color: var(--muted);
  font-weight: 900;
  font-style: italic;
}
.metric span { font-size: clamp(21px, 5.4vw, 32px); line-height: 1.15; }
.screen-state-title {
  text-align: center;
  font-size: clamp(26px, 6.4vw, 38px);
  line-height: 1.12;
  font-weight: 1000;
}
.centered-copy { text-align: center; max-width: 56ch; margin-inline: auto; }
.actions.single, .finish-panel { display: grid; gap: var(--gap); }
.actions.single button, .finish-panel button { width: 100%; }
.timer, .small-timer { font-variant-numeric: tabular-nums; font-weight: 1000; line-height: 1.08; }
.timer { font-size: 40px; }
.small-timer { flex: 0 0 auto; font-size: clamp(28px, 7.2vw, 42px) !important; padding: 8px 11px; border-radius: 14px; background: var(--soft); border: 1px solid var(--border); }

/* Tasca principal i resums */
.task-card-main { min-height: clamp(430px, 62vh, 680px); grid-template-rows: auto minmax(0, 1fr); }
.home-task-start { display: flex; flex-direction: column; gap: var(--gap); min-height: 100%; }
.home-task-start > button { margin-top: auto; }
.summary-list { gap: 10px; padding: 4px 0; }
.summary-row { min-width: 0; display: flex; align-items: baseline; gap: 10px; line-height: 1.2; }
.summary-row span { flex: 0 0 auto; font-size: clamp(21px, 5vw, 28px); }
.summary-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: clamp(25px, 6.4vw, 38px); font-weight: 1000; letter-spacing: -.02em; line-height: 1.15; }
.timer-row { justify-content: space-between; align-items: center; gap: 14px; margin-top: 3px; }
.photo-count { color: var(--muted); font-size: 19px; font-weight: 850; font-style: italic; }
.task-topline { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); }
.task-topline h3 { margin: 0; font-size: 28px; }

/* Formularis i botons */
label { display: grid; gap: 9px; font-size: 22px; line-height: 1.25; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  background: var(--soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(120, 120, 120, .2); }
input, select { min-height: var(--tap); padding: 12px 14px; font-size: 23px; line-height: 1.3; }
textarea { min-height: 126px; padding: 13px 14px; font-size: 23px; line-height: 1.42; resize: vertical; }
.form-grid.two-cols { grid-template-columns: 1fr 1fr; }
.form-grid.three-cols { grid-template-columns: repeat(3, 1fr); }
.form-grid > *, .manual-time-grid > * { min-width: 0; }
button, .primary, .danger, .secondary, .ghost { min-height: var(--tap); border-radius: 16px; padding: 12px 16px; font-size: 22px; font-weight: 950; }
.full { width: 100%; }
.huge { min-height: 72px; font-size: 26px; }
.primary { background: var(--primary); color: var(--primary-text); }
.danger { background: var(--danger) !important; color: var(--danger-text) !important; }
.secondary { background: var(--soft); color: var(--text); border: 1px solid var(--border); }
.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.danger-outline { color: var(--danger); border-color: var(--danger); }
.small { min-height: 48px; font-size: 19px; padding: 8px 12px; }
.actions, .task-actions, .manual-shortcuts, .calendar-nav { display: grid; gap: var(--gap); }
.calendar-nav { grid-template-columns: auto auto; }

/* Llistes, estat i calendari */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.stat-card { display: grid; gap: 4px; }
.stat-card span, .detail-box span { color: var(--muted); font-size: 18px; font-weight: 900; font-style: italic; }
.stat-card strong { font-size: 28px; font-weight: 1000; }
.history-empty { color: var(--muted); padding: 12px; border: 1px dashed var(--border); border-radius: 14px; font-size: 19px; }
.history-item, .task-item, .segment-item, .material-mini-item, .detail-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  background: var(--soft);
  border: 1px solid var(--border);
}
.history-main, .task-main, .material-mini-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.history-main span, .task-main span { font-size: 21px; font-weight: 1000; }
.task-item.open { border-color: var(--danger); }
.history-item { text-align: center; }
.history-main { flex-wrap: wrap; justify-content: center; text-align: center; }
.status-pill.closed { background: var(--soft); color: var(--text); border-color: var(--border); }
.status-pill { display: inline-grid; place-items: center; min-height: 36px; padding: 6px 12px; border-radius: 999px; background: var(--soft); color: var(--text); border: 1px solid var(--border); font-size: 16px; font-weight: 1000; }
.status-pill.active { background: var(--danger); color: var(--danger-text); border-color: var(--danger); }
.status-pill.local { background: var(--warning); color: var(--warning-text); border-color: #eab308; }
.status-pill.ok, .status-pill.local.ok { background: var(--ok); color: white; border-color: var(--ok); }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-weekdays span { text-align: center; color: var(--muted); font-weight: 1000; font-size: 15px; }
.calendar-day { min-height: 72px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 6px; display: grid; align-content: start; gap: 3px; text-align: left; }
.calendar-day.outside { opacity: .35; }
.calendar-day.selected { outline: 3px solid var(--primary); }
.calendar-day.worked { background: var(--warning-soft); }
.calendar-day.open { border-color: var(--danger); }
.calendar-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.calendar-day.empty { visibility: hidden; pointer-events: none; }
.calendar-day .day-number { font-size: 18px; font-weight: 1000; }
.calendar-day .day-hours, .calendar-day .day-small { font-size: 13px; color: var(--muted); font-weight: 900; }
.detail-summary, .future-allocation { display: grid; gap: 10px; }
.detail-total { font-size: 40px; font-weight: 1000; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
summary { font-size: 26px; font-weight: 1000; cursor: pointer; }
.toast { position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 100; display: none; padding: 14px 16px; border-radius: 16px; background: var(--primary); color: var(--primary-text); font-size: 20px; font-weight: 900; box-shadow: var(--shadow); }
.toast.show, .toast.visible { display: block; }



/* v19: components comuns per Jornada, Tasques, Correccions i Calendari */
.compact-card { display: grid; gap: var(--gap); }
.compact-card .section-title { margin-bottom: 0; }
.compact-card .section-title h2 { font-size: clamp(28px, 6.5vw, 38px); }
.info-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 14px;
  background: var(--soft);
  border: 1px solid var(--border);
  color: var(--text);
}
.info-card strong { font-size: 22px; font-weight: 1000; }
.info-card span { color: var(--muted); font-size: 18px; font-weight: 850; line-height: 1.35; }
.compact-stats { margin-bottom: 4px; }
.timeline-box { display: grid; gap: 8px; }
.timeline-labels, .timeline-legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
  font-style: italic;
}
.timeline-track {
  position: relative;
  min-height: 54px;
  border-radius: 14px;
  background: var(--soft);
  border: 1px solid var(--border);
  overflow: hidden;
}
.timeline-bar {
  position: absolute;
  min-width: 8px;
  border-radius: 999px;
}
.timeline-bar.work {
  top: 12px;
  height: 12px;
  background: var(--danger);
}
.timeline-bar.task {
  bottom: 12px;
  height: 12px;
  background: var(--warning);
}
.task-selected-summary { display: grid; gap: 8px; }
.compact-detail-grid .detail-box { min-width: 0; }
.compact-detail-grid .detail-box strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-total-box {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--soft);
  border: 1px solid var(--border);
}
.task-total-box span { color: var(--muted); font-weight: 900; font-style: italic; }
.task-total-box strong { font-size: clamp(30px, 7vw, 44px); font-weight: 1000; font-variant-numeric: tabular-nums; }
.segment-list:empty, .task-list:empty { min-height: 24px; }
.manual-card .manual-body { margin-top: 0; }

@media (max-width: 520px) {
  body { font-size: 18px; }
  .app-shell { padding: 8px; }
  .app-header { grid-template-columns: 42px minmax(0, 1fr) 14px; min-height: 56px; padding-left: 8px; padding-right: 8px; }
  .menu-toggle { width: 42px; height: 42px; min-height: 42px; }
  .status-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
  .status-cell span { font-size: 13px; }
  .status-cell strong { font-size: 18px; }
  .card, .stat-card, .warning-card, .notice-card { padding: 12px; border-radius: 17px; }
  .metric-row { grid-template-columns: minmax(96px, .75fr) minmax(0, 1.25fr); }
  .big-value { font-size: clamp(44px, 12.5vw, 64px); }
  .metric-left .big-value { font-size: clamp(38px, 10.8vw, 56px); }
  .metric span { font-size: clamp(20px, 5.3vw, 28px); }
  .summary-row strong { font-size: 30px; line-height: 1.18; }
  .summary-row span { font-size: 23px; }
  .small-timer { font-size: 34px !important; }
  .form-grid.two-cols, .form-grid.three-cols, .stats-grid, .detail-grid { grid-template-columns: 1fr; }
  textarea { min-height: 118px; }
}

@media (max-width: 360px) {
  .status-cell span { font-size: 12px; }
  .status-cell strong { font-size: 16px; }
  .big-value { font-size: 40px; }
  .metric-left .big-value { font-size: 34px; }
  .metric span { font-size: 20px; }
  button, input, select, textarea { font-size: 20px; }
  .summary-row strong { font-size: 26px; line-height: 1.2; }
  .summary-row span { font-size: 20px; }
  .small-timer { font-size: 30px !important; }
}

/* v22: ajustos finals i administració */
.centered-text { text-align: center; }
.link-button { display: inline-grid; place-items: center; text-decoration: none; text-align: center; }
.task-file-actions { margin-top: 4px; }
.calendar-day.holiday { background: var(--soft); border-style: dashed; }
.calendar-day.holiday .day-small { color: var(--ok); }
.holiday-card .section-title { margin-bottom: 0; }

.admin-body {
  font-size: 15px;
  line-height: 1.35;
  background: var(--bg);
  color: var(--text);
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.admin-header h1 { margin: 0; font-size: 32px; }
.admin-header p { margin: 4px 0 0; color: var(--muted); max-width: 78ch; }
.admin-kicker { text-transform: uppercase; letter-spacing: .08em; font-weight: 900; font-size: 12px; }
.admin-shell { width: min(1500px, 100%); margin: 0 auto; padding: 22px; display: grid; gap: 18px; }
.admin-card, .admin-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 18px rgba(0,0,0,.04);
}
.admin-card h2 { margin: 0; font-size: 22px; }
.admin-card p, .admin-note { color: var(--muted); margin: 6px 0 0; }
.admin-controls { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.admin-actions button, .admin-actions .file-drop, .admin-header .link-button, .admin-section-title button { min-height: 42px; font-size: 14px; border-radius: 10px; padding: 9px 12px; }
.file-drop { display: inline-grid; place-items: center; cursor: pointer; border: 1px solid var(--border); background: var(--primary); color: var(--primary-text); font-weight: 900; }
.file-drop input { display: none; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.admin-stat { display: grid; gap: 4px; }
.admin-stat span { color: var(--muted); font-weight: 850; }
.admin-stat strong { font-size: 28px; font-weight: 1000; }
.admin-section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; text-align: left; }
th { position: sticky; top: 0; background: var(--soft); font-size: 13px; font-weight: 1000; z-index: 1; }
td { font-size: 13px; white-space: pre-line; }
tr.level-vermell td:first-child { color: var(--danger); font-weight: 1000; }
tr.level-groc td:first-child { color: #a16207; font-weight: 1000; }
tr.level-info td:first-child { color: var(--muted); font-weight: 1000; }
.empty-table { color: var(--muted); text-align: center; padding: 20px; }

@media (max-width: 800px) {
  .admin-header, .admin-controls { display: grid; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
}
.connection-icon.syncing { background: var(--warning); }
.connection-icon.error { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 25%, transparent); }


/* v31: ajustos iPhone idle + correccions + registre legal */
#homeScreen.fit-idle-home {
  gap: 8px;
}
#homeScreen.fit-idle-home .card {
  padding: 10px 12px;
}
#homeScreen.fit-idle-home .work-card {
  min-height: 0;
}
#homeScreen.fit-idle-home .metric-row {
  min-height: 84px;
}
#homeScreen.fit-idle-home .big-value {
  font-size: clamp(40px, 15vw, 66px);
  line-height: .94;
}
#homeScreen.fit-idle-home .metric span,
#homeScreen.fit-idle-home label {
  font-size: 18px;
}
#homeScreen.fit-idle-home input {
  min-height: 50px;
  padding-block: 9px;
}
#homeScreen.fit-idle-home .task-card-main {
  min-height: 0;
}
#homeScreen.fit-idle-home .home-task-start {
  gap: 10px;
  min-height: 236px;
}
#homeScreen.fit-idle-home .home-task-start > button {
  margin-top: auto;
}
@media (max-height: 760px) {
  #homeScreen.fit-idle-home { gap: 6px; }
  #homeScreen.fit-idle-home .task-card-main { padding-bottom: 8px; }
  #homeScreen.fit-idle-home .form-grid.two-cols { gap: 8px; }
  #homeScreen.fit-idle-home .home-task-start { min-height: 220px; }
}
@media (max-height: 700px) {
  #homeScreen.fit-idle-home .metric-row { min-height: 76px; }
  #homeScreen.fit-idle-home .big-value { font-size: clamp(36px, 13.5vw, 58px); }
  #homeScreen.fit-idle-home .centered-title h2 { font-size: clamp(26px, 6.5vw, 34px); }
  #homeScreen.fit-idle-home .home-task-start { min-height: 200px; }
  #homeScreen.fit-idle-home button { min-height: 56px; }
}
.manual-time-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.manual-time-grid label { min-width: 0; max-width: 100%; }
.manual-time-grid input { width: 100%; min-width: 0; max-width: 100%; }
@media (max-width: 520px) {
  .manual-time-grid { grid-template-columns: 1fr; overflow: visible; }
}
.attachment-list {
  display: grid;
  gap: 8px;
  width: 100%;
}
.attachment-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--soft);
  color: var(--text);
  text-decoration: none;
}
.attachment-item img,
.attachment-icon {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--surface);
  font-weight: 1000;
}
.attachment-item strong,
.attachment-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-item span { color: var(--muted); font-size: 16px; }

/* v31 legal register */
.legal-list { display: grid; gap: 12px; }
.legal-item { border: 1px solid var(--border); border-radius: 14px; padding: 12px; background: var(--surface-soft); }
.legal-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 1rem; }
.legal-head strong { font-size: 1.2rem; }
.legal-head span { color: var(--muted); font-style: italic; }
.legal-kpis { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.legal-kpis span { border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; background: var(--surface); font-size: .92rem; }
.legal-item details { margin-top: 8px; }
.legal-item summary { cursor: pointer; font-weight: 700; }
.legal-item h4 { margin: 12px 0 6px; }
.legal-item ul { margin: 0; padding-left: 18px; }
.legal-item li { margin: 6px 0; }
.legal-item li span { color: var(--muted); }

/* v31: editor gran per camps llargs, icona corporativa i estat de sincronització */
.brand-logo.image-logo {
  object-fit: contain;
  background: transparent;
  color: transparent;
  padding: 0;
  border-radius: 22px;
}

.connection-icon.pending { background: var(--warning); }
.connection-icon.syncing {
  background: var(--warning);
  animation: syncPulse 1s ease-in-out infinite;
}
.connection-icon.error { background: var(--danger); }
@keyframes syncPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.72); opacity: .65; }
}

.text-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
}
.text-editor-overlay.hidden { display: none !important; }
.text-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .42);
  backdrop-filter: blur(2px);
}
.text-editor-panel {
  position: relative;
  width: min(720px, 96vw);
  height: min(78vh, 760px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: scale(.985);
  opacity: 0;
  animation: textEditorIn .13s ease-out forwards;
}
.text-editor-title {
  color: var(--muted);
  font-size: 18px;
  font-weight: 950;
  font-style: italic;
  text-align: center;
}
.text-editor-panel textarea {
  min-height: 0;
  height: 100%;
  resize: none;
  font-size: clamp(24px, 5.6vw, 34px);
  line-height: 1.38;
  padding: 16px;
  border-radius: 16px;
}
@keyframes textEditorIn {
  to { transform: scale(1); opacity: 1; }
}

@media (max-width: 520px) {
  .text-editor-panel {
    width: 96vw;
    height: 76vh;
    padding: 10px;
  }
  .text-editor-panel textarea { font-size: 27px; }
}

/* v31: inici més compacte quan encara no hi ha tasca oberta */
.task-card-main:not(.has-active-task) {
  min-height: clamp(300px, 42vh, 430px);
}
.task-card-main.has-active-task {
  min-height: clamp(520px, 70vh, 780px);
}

/* v31: evita obertura accidental de l'editor gran durant scroll */
.large-editor-source {
  -webkit-user-select: none;
  user-select: none;
  cursor: text;
}
.large-editor-source:focus {
  outline: 2px solid var(--border-strong);
  outline-offset: 2px;
}
