:root {
    --blue: #0f4c81;
    --blue-light: #1b5e9c;
    --blue-dark: #0a3a6b;
    --bg: #f8fafc;
    --card: #ffffff;
    --muted: #64748b;
    --work-bg: #3b82f6;
    --off-bg: #10b981;
    --extra-bg: #f59e0b;
    --today-color: #ef4444;
    --ink: #111827;
    --line: #e2e8f0;
    /* Dias marcados: fundo suave + texto na cor do estado */
    --work-soft: #dbeafe;
    --work-ink: #1e40af;
    --off-soft: #d1fae5;
    --off-ink: #047857;
    --extra-soft: #fef3c7;
    --extra-ink: #92400e;
    --start-bg: #1e3a8a;
    --end-bg: #064e3b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --sidebar-width: 300px;
    --ad-sidebar-width: 250px;
}


* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink, #111827);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    line-height: 1.5;
}

/* ===== HEADER ===== */
header {
    width: 100%;
    background: linear-gradient(135deg, var(--blue-dark), var(--blue));
    color: #fff;
    padding: 1px 16px;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin:1px auto;
    width: 100%;
}

header h1 {
    margin: 0;
    font-size: clamp(18px, 3vw, 28px);
    font-weight: 700;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.desktop-buttons {
    display: flex;
    gap: 12px;
}

.header-btn {
    background: var(--blue-light);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.header-btn.hide-on-other-pages,
.calendar-action-btn.hide-on-other-pages {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    width: 0;
    padding: 0;
    margin: 0;
    border: 0;
}
.calendar-action-btn.hide-on-other-pages,
.year-nav.hide-on-other-pages {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    width: 0;
    padding: 0;
    margin: 0;
    border: 0;
}

/* ===== MENU DE ESCALAS SALVAS ===== */
.save-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 1000;
    display: none;
    flex-direction: column;
    min-width: 180px;
    margin-top: 8px;
}

.save-menu.show {
    display: flex;
}

.save-menu button {
    background: none;
    border: none;
    padding: 10px 16px;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.save-menu button:hover {
    background: #f5f5f5;
}

/* ===== LAYOUT PRINCIPAL ===== */
.main-wrapper {
    display: flex;
    width: 100%;
    max-width: 1400px;
    gap: 20px;
    padding: 20px 16px;
}

.wrap {
    flex: 1;
    display: flex;
    gap: 20px;
    align-items: flex-start;
    position: relative;
    order: 1;
}

.main-content {
    flex: 1;
}

/* ===== SIDEBAR DE ANÚNCIOS ===== */
.ad-sidebar {
    width: var(--ad-sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    order: 2;
}

.ad-container {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    border: 1px solid #f1f5f9;
}

.ad-container h3 {
    margin: 0 0 15px 0;
    color: var(--blue);
    font-size: 1.1rem;
    font-weight: 700;
}

.ad-placeholder {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.ad-placeholder.large {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-placeholder.small {
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== SIDEBAR DE GERAR ESCALA ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
    display: none;
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    height: auto;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.sidebar.open {
    display: block;
}

.sidebar h2 {
    margin: 0 0 16px 0;
    font-size: 1.3rem;
    color: var(--blue);
    font-weight: 700;
}

.sidebar label {
    display: block;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 500;
}

.sidebar input[type="number"],
.sidebar input[type="date"] {
    width: 100%;
    padding: 12px;
    margin-top: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fafafa;
}

.sidebar input:focus {
    outline: none;
    border-color: var(--blue);
    background: #fff;
}

.sidebar button {
    width: 100%;
    padding: 14px;
    margin-top: 16px;
    border-radius: 8px;
    border: 0;
    background: linear-gradient(135deg, var(--blue), var(--blue-light));
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ===== OVERLAY ===== */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
}

.overlay.active {
    display: block;
}

/* ===== CALENDÁRIOS PRINCIPAIS ===== */
.calendars {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
    align-content: start;
    width: 100%;
}

.month {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #f1f5f9;
}

.month .head {
    background: linear-gradient(90deg, var(--blue), var(--blue-light));
    color: #fff;
    padding: 2px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

.month .grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    padding: 0cqb;
    font-size: 0.7rem;
}

.month .grid .w {
    text-align: center;
    padding: 1px 2px;
    font-weight: 700;
    color: var(--muted);
    background: #fafafa;
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.65rem;
}

.month .grid .cell {
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #f1f5f9;
    cursor: pointer;
    padding: 1px;
    user-select: none;
    font-weight: 500;
    position: relative;
    font-size: 0.7rem;
}

.month .grid .cell.empty {
    background: transparent;
    cursor: default;
    border: 0;
}

/* Estados dos dias */
.cell.work {
    background: var(--work-bg);
    color: #fff;
    font-weight: 600;
}

.cell.off {
    background: var(--off-bg);
    color: #fff;
    font-weight: 600;
}

.cell.extra {
    background: var(--extra-bg);
    color: #fff;
    font-weight: 600;
}

.cell.start {
    background: var(--start-bg);
    color: #fff;
    font-weight: 700;
}

.cell.end {
    background: var(--end-bg);
    color: #fff;
    font-weight: 700;
}

.cell.today {
    color: var(--today-color);
    font-weight: 700;
}

/* Indicadores */
.holiday-indicator {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
}

.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    margin-bottom: 8px;
    font-weight: 500;
}

.cell:hover .tooltip {
    opacity: 1;
}

/* ===== NAVEGAÇÃO DE ANO ===== */
.year-nav {
    display: flex;
    align-items: center;
    justify-content: center;
}


.year-display {
    color: #fafafc ;
    min-width: auto ;
    text-align: center;
    margin: 0;
    letter-spacing: -2px;
    font-size: clamp(18px, 3vw, 28px);
    font-weight: 700;
}

/* ===== AÇÕES DO CALENDÁRIO ===== */
.calendar-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.calendar-action-btn {
    background: var(--blue-light);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex
;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}


/* Botão de escala para mobile */
.mobile-scale-btn {
    display: none !important;
}

/* ===== RODAPÉ E LEGENDA ===== */
.calendar-footer {
    margin-top: 30px;
    padding: 24px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    border: 1px solid #f1f5f9;
}

.legend {
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--muted);
}

.legend .row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.color-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: inline-block;
}

/* ===== SIDEBAR DIREITA (DATA E CONTADORES) ===== */
.current-date {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    border: 1px solid #f1f5f9;
    text-align: center;
    cursor: pointer;
}

.current-date h3 {
    margin: 0 0 10px 0;
    color: var(--blue);
    font-size: 1.1rem;
    font-weight: 700;
}

.date-display {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--today-color);
    padding: 10px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.1);
}

.counter-sidebar {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    border: 1px solid #f1f5f9;
}

.counter-sidebar h3 {
    margin: 0 0 15px 0;
    color: var(--blue);
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
}

.counter-display {
    font-size: 1rem;
    color: #333;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.counter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.counter-value {
    font-weight: 700;
    color: var(--blue);
}

/* ===== PÁGINA DE MÊS INDIVIDUAL ===== */
.month-page {
    display: none;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

.month-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--blue);
    flex-wrap: wrap;
    gap: 15px;
}

.month-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: var(--blue);
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    text-align: center;
}

.month-nav-btn {
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 8px;
    /* width: clamp(40px, 10vw, 50px);
    height: clamp(40px, 10vw, 50px); */
    cursor: pointer;
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.month-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
    width: 100%;
}

.month-action-btn {
    background: linear-gradient(135deg, var(--blue), var(--blue-light));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 140px;
    justify-content: center;
}

.large-month {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
    width: 100%;
}

.large-month .grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    padding: 12px;
    background: #f1f1f1;
}

.large-month .grid .w {
    text-align: center;
    padding: 14px 6px;
    font-weight: 700;
    color: var(--muted);
    background: #fafafa;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
}

.large-month .grid .w .long-text {
    display: block;
}

.large-month .grid .w .short-text {
    display: none;
}

.large-month .grid .cell {
    min-height: clamp(60px, 15vw, 110px);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    background: white;
    cursor: pointer;
    padding: 8px 4px;
    user-select: none;
    font-weight: 500;
    position: relative;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
}

.large-month .grid .cell.empty {
    background: transparent;
    cursor: default;
}

.large-month .grid .cell .day-number {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-weight: 600;
    margin-bottom: 4px;
}

.large-month .cell.work {
    background: var(--work-bg);
    color: #fff;
    font-weight: 600;
}

.large-month .cell.off {
    background: var(--off-bg);
    color: #fff;
    font-weight: 600;
}

.large-month .cell.extra {
    background: var(--extra-bg);
    color: #fff;
    font-weight: 600;
}

.large-month .cell.today .day-number {
    color: #fff;
    font-weight: 700;
    background: var(--today-color);
    border-radius: 50%;
    min-width: 1.9em;
    height: 1.9em;
    line-height: 1.9em;
    text-align: center;
    padding: 0 0.2em;
}

.holiday-indicator-large {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
}

/* ===== NOTAS ===== */
.notes-link {
    width: 100%;
    flex: 1;
    min-height: 20px;
    font-size: 0.7rem;
    border: 1px dashed #ccc;
    border-radius: 4px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.9);
    margin-top: auto;
    cursor: pointer;
    text-align: center;
    color: var(--muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.notes-link:hover {
    background: var(--blue-light);
    color: white;
    border-color: var(--blue-light);
}

.notes-link.has-notes {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--work-bg);
    color: var(--blue);
    font-weight: 600;
}

.notes-link.has-notes::before {
    content: "📝 ";
}

.notes-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.notes-modal.show {
    display: flex;
}

.notes-modal-content {
    background: var(--card);
    padding: 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.notes-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.notes-modal-title {
    font-size: 1.4rem;
    color: var(--blue);
    font-weight: 700;
    margin: 0;
}

.notes-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
    padding: 5px;
    border-radius: 4px;
}

.notes-modal-textarea {
    width: 100%;
    min-height: 150px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 20px;
}

.notes-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ===== MENU MOBILE DE ESCALA ===== */
.scale-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.scale-overlay.show {
    display: block;
}

.scale-mobile-menu {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 20px;
    z-index: 1000;
    min-width: 280px;
    max-width: 90vw;
}

.scale-mobile-menu.show {
    display: block;
}

.scale-mobile-menu h3 {
    margin: 0 0 16px 0;
    color: var(--blue);
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
}

.scale-mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scale-mobile-btn {
    background: linear-gradient(135deg, var(--blue), var(--blue-light));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.scale-mobile-btn.secondary {
    background: #666;
}

/* ===== MENU FIXO INFERIOR ===== */
.bottom-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--blue-dark);
    border-top: 1px solid #e2e8f0;
    padding: 8px 12px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
}

.bottom-menu-content {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    gap: 5px;
}

.bottom-menu-btn {
    background: var(--blue-light);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 60px;
    max-width: 80px;
    transition: all 0.3s ease;
    text-align: center;
}

.bottom-menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 76, 129, 0.3);
}

.bottom-menu-btn span {
    font-size: 1.2rem;
}

.bottom-menu-btn:active {
    transform: translateY(0);
}

.bottom-menu-btn .btn-text {
    font-size: 0.65rem;
}

/* Esconde os botões de ação originais quando o menu fixo está ativo */
.bottom-menu-active .calendar-actions,
.bottom-menu-active .month-actions {
    display: none !important;
}

/* ===== ESTADOS ESPECIAIS ===== */
.generating {
    pointer-events: none;
    position: relative;
}

.generating::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9998;
}

.generating::after {
    content: "Gerando...";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--blue);
    color: white;
    padding: 14px 28px;
    border-radius: 10px;
    z-index: 9999;
    font-weight: 600;
}

/* Classes utilitárias */
.hide-on-save {
    display: none !important;
}

.generating-pdf .month-actions {
    display: none !important;
}

/* =====================================================================
   RESPONSIVIDADE
   Ordem: base fluida (qualquer tela) → tablets → celulares (visual de
   "ano inteiro" estilo iPhone) → celular deitado → preferências do sistema.
   ===================================================================== */

:root {
    --hdr-h: 48px;   /* altura do cabeçalho no celular */
    --bar-h: 56px;   /* altura do menu inferior no celular */
    --ink: #111827;  /* cor do texto no visual limpo */
}

html {
    min-height: 100%;
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
}

/* Elementos de apoio */
#currentDateContainer { display: none !important; }

button { touch-action: manipulation; } /* sem atraso nem zoom em toque duplo */

/* ----- Cabeçalho: nunca estoura a largura ----- */
.header-container {
    flex-wrap: wrap;
    gap: 6px 12px;
    min-height: 52px;
}

/* ----- Navegação de ano (setas do cabeçalho) ----- */
#prevYearBtn,
#nextYearBtn {
    width: 40px;
    min-width: 40px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    box-shadow: none;
    color: #f1f3f5;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

#prevYearBtn span,
#nextYearBtn span { display: none; }

#prevYearBtn::before { content: "‹"; }
#nextYearBtn::before { content: "›"; }

#prevYearBtn::before,
#nextYearBtn::before {
    color: #e5e7e0;
    font-size: 26px;
    font-weight: 400;
    line-height: 1;
}

#prevYearBtn:hover,
#nextYearBtn:hover { background: rgba(255, 255, 255, 0.15); }

#prevYearBtn:active,
#nextYearBtn:active { background: rgba(255, 255, 255, 0.25); }

/* ----- Página do mês: título e botões ----- */
.month-header {
    padding: 0 10px 8px;
    border-bottom: 1px solid #dbe5ee;
}

.month-title {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: clamp(10px, 3vw, 25px);
    font-size: clamp(1.25rem, 4vw, 2.3rem);
}

.month-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #eaf2f8;
    color: var(--blue);
    border: 1px solid #cbddea;
    font-size: 0;
    box-shadow: none;
    transition: background 0.2s ease, transform 0.2s ease;
}

#prevMonthBtn::before,
#nextMonthBtn::before {
    font-size: 1.6rem;
    line-height: 1;
}

#prevMonthBtn::before { content: "‹"; }
#nextMonthBtn::before { content: "›"; }

.month-nav-btn:hover { background: var(--blue); color: #fff; }
.month-nav-btn:active { transform: scale(0.94); }

/* ----- Calendário anual: colunas fluidas ----- */
.calendars {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 215px), 1fr));
}

/* ----- Ano em destaque: só aparece no celular (ver bloco mais abaixo) ----- */
.year-title { display: none; }

/* ----- Dia de hoje: bolinha vermelha com número branco, como no iOS ----- */
.month .grid .cell.today {
    background-image: radial-gradient(circle closest-side, var(--today-color) 96%, transparent 100%);
    color: #fff;
    font-weight: 800;
}

/* ----- Escalas salvas ----- */
.saved-schedule-row { display: flex; align-items: center; gap: 6px; }
.saved-schedule-row .saved-schedule-load {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.saved-schedule-row .saved-schedule-delete {
    width: auto;
    flex: none;
    font-size: 0.8rem;
    padding: 8px 10px;
}

.notes-modal-textarea { font-size: 16px; } /* evita zoom automático no iOS */

/* ----- Desktop: menu inferior escondido ----- */
@media (min-width: 769px) and (pointer: fine),
       (min-width: 769px) and (min-height: 501px) {
    .bottom-menu { display: none !important; }
    #shareCalendarBtn,
    #clearMarksBtn { display: flex; }
}

/* ----- Telas até 1200px: anúncios descem para baixo do calendário ----- */
@media (max-width: 1200px) {
    .main-wrapper { flex-direction: column; gap: 20px; }

    .ad-sidebar {
        width: 100%;
        order: 3;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .ad-container { flex: 1; min-width: 250px; max-width: 320px; }
}

/* ----- Tablets ----- */
@media (max-width: 1024px) {
    .main-wrapper { padding: 16px 12px; }
    .month-page { padding: 15px; }
    .large-month .grid { padding: 8px; }
    .large-month .grid .cell { min-height: clamp(56px, 10vw, 90px); padding: 6px 3px; }
    .large-month .grid .w { padding: 10px 4px; }
}

/* =====================================================================
   CELULAR (até 768px): o ano inteiro cabe na tela, no estilo do
   calendário do iPhone. Sem rolagem na tela principal: arrastar para
   cima ou para o lado troca o ano.
   ===================================================================== */
@media (max-width: 768px),
       (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
    html, body { overscroll-behavior: none; }

    body {
        padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
    }

    /* Tela principal e página do mês ocupam exatamente a altura disponível */
    body[data-page="main"],
    body[data-page="month"] {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    /* ----- Cabeçalho compacto ----- */
    header { padding: 0 12px; }

    .header-container {
        flex-wrap: nowrap;
        min-height: var(--hdr-h);
        margin: 0 auto;
    }

    header img { height: 30px !important; width: auto; }
    header h1 { font-size: 1rem; white-space: nowrap; }
    header > .header-container > div:first-child { gap: 8px !important; min-width: 0; }

    #yearNav { display: none; } /* no celular o ano fica grande, abaixo do cabeçalho */

    /* ----- Ano em destaque (como no calendário do iPhone) ----- */
    .year-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 2px 4px;
        border-bottom: 1px solid #e5e7eb;
        flex: none;
    }

    .year-title-text {
        font-size: clamp(1.9rem, 9vw, 2.6rem);
        font-weight: 800;
        line-height: 1.1;
        letter-spacing: -0.5px;
        color: var(--today-color);
    }

    .year-title-nav { display: flex; gap: 2px; }

    .year-title-nav button {
        width: 40px;
        height: 40px;
        border: 0;
        background: none;
        color: #9ca3af;
        font-size: 1.9rem;
        line-height: 1;
        border-radius: 50%;
        cursor: pointer;
    }

    .year-title-nav button:active { background: #f3f4f6; }

    .desktop-buttons,
    #shareCalendarBtn,
    #clearMarksBtn { display: none !important; }

    /* ----- Menu inferior no estilo "tab bar" do iOS ----- */
    .bottom-menu {
        display: block !important;
        background: rgba(255, 255, 255, 0.94);
        -webkit-backdrop-filter: saturate(180%) blur(14px);
        backdrop-filter: saturate(180%) blur(14px);
        border-top: 1px solid #dbe5ee;
        box-shadow: none;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    }

    .bottom-menu-content { gap: 2px; }

    .bottom-menu-btn {
        background: transparent;
        color: var(--blue);
        min-width: 0;
        max-width: none;
        min-height: 48px;
        padding: 4px 2px;
        gap: 2px;
        justify-content: center;
        border-radius: 10px;
    }

    .bottom-menu-btn:hover { transform: none; box-shadow: none; }
    .bottom-menu-btn:active { background: #eaf2f8; }
    .bottom-menu-btn svg { width: 24px; height: 24px; flex: none; }
    .bottom-menu-btn .btn-text { font-size: 0.68rem; font-weight: 600; }

    /* ----- Tela principal ----- */
    #mainPage {
        flex-direction: column;
        gap: 6px;
        padding: 6px 12px 6px;
        gap: 4px;
        height: calc(100vh - env(safe-area-inset-top, 0px) - var(--hdr-h) - var(--bar-h) - env(safe-area-inset-bottom, 0px));
        height: calc(100dvh - env(safe-area-inset-top, 0px) - var(--hdr-h) - var(--bar-h) - env(safe-area-inset-bottom, 0px));
        max-width: none;
    }

    /* Contadores viram uma faixa que também serve de legenda */
    .ad-sidebar { order: 0; width: 100%; flex: none; display: block; }
    .ad-container { display: none; }

    .counter-sidebar {
        padding: 0 2px;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: none;
    }

    .counter-sidebar h3 { display: none; }

    .counter-display {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        font-size: 0.75rem;
    }

    .counter-item {
        flex: 1;
        justify-content: center;
        gap: 4px;
        padding: 0;
        border: 0;
        white-space: nowrap;
    }

    .counter-item::before {
        content: "";
        width: 9px;
        height: 9px;
        border-radius: 3px;
        flex: none;
    }

    .counter-item:nth-child(1)::before { background: var(--work-bg); }
    .counter-item:nth-child(2)::before { background: var(--off-bg); }
    .counter-item:nth-child(3)::before { background: var(--extra-bg); }

    .counter-item > span:first-child {
        font-weight: 600;
        color: var(--muted);
    }

    .counter-display::after {
        content: "Feriado";
        flex: none;
        font-size: 0.7rem;
        color: var(--muted);
        padding-left: 11px;
        background: radial-gradient(circle at 4px 50%, #ef4444 3px, transparent 3.5px) no-repeat;
    }

    .wrap { order: 1; flex: 1; min-height: 0; width: 100%; align-items: stretch; }
    .main-content { flex: 1; min-width: 0; min-height: 0; display: flex; }
    .calendar-footer { display: none; }

    /* ----- Ano inteiro: 3 colunas × 4 linhas, sem bordas (visual iPhone) ----- */
    .calendars {
        flex: 1;
        min-height: 0;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-template-rows: repeat(4, minmax(0, 1fr));
        gap: 10px 12px;
        align-content: stretch;
        touch-action: none; /* o gesto de arrastar é tratado pelo script */
    }

    .month {
        background: transparent;
        box-shadow: none;
        border: 0;
        border-radius: 0;
        overflow: visible;
        min-height: 0;
    }

    .month .head {
        background: none;
        color: var(--ink);
        text-align: left;
        font-size: clamp(0.95rem, 4.6vw, 1.3rem);
        font-weight: 800;
        line-height: 1.15;
        padding: 0 2px 3px;
        cursor: pointer;
    }

    .month .head.current { color: var(--today-color); }

    .month .grid {
        flex: 1;
        min-height: 0;
        grid-template-rows: repeat(6, minmax(0, 1fr));
        font-size: clamp(8px, 2.75vw, 12px);
        color: var(--ink);
    }

    .month .grid .w { display: none; } /* a visão anual do iPhone não mostra dias da semana */

    .month .grid .cell {
        min-height: 0;
        padding: 0;
        margin: 0.5px;
        border: 0;
        border-radius: 4px;
        font-size: inherit;
        font-weight: 500;
    }

    .month .grid .cell.work,
    .month .grid .cell.off,
    .month .grid .cell.extra { font-weight: 700; }

    /* Hoje: bolinha vermelha com número branco (círculo perfeito em qualquer proporção de célula) */
    .month .grid .cell.today {
        background-image: radial-gradient(circle closest-side, var(--today-color) 96%, transparent 100%);
        color: #fff;
        font-weight: 800;
    }

    .holiday-indicator {
        top: auto;
        bottom: 1px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        width: 3px;
        height: 3px;
    }

    .tooltip { display: none !important; } /* dicas de mouse não existem no toque */

    /* ----- Página do mês: preenche a tela ----- */
    body[data-page="month"] .month-page {
        display: flex !important;
        flex-direction: column;
        height: calc(100vh - env(safe-area-inset-top, 0px) - var(--hdr-h) - var(--bar-h) - env(safe-area-inset-bottom, 0px));
        height: calc(100dvh - env(safe-area-inset-top, 0px) - var(--hdr-h) - var(--bar-h) - env(safe-area-inset-bottom, 0px));
        min-height: 0;
        padding: 6px 10px 6px;
    }

    #monthPage .month-actions { display: none !important; }
    .month-header { margin-bottom: 6px; gap: 0; }

    .large-month { flex: 1; min-height: 0; display: flex; touch-action: none; }

    .large-month .grid {
        flex: 1;
        padding: 0;
        gap: 1px;
        grid-template-rows: auto repeat(var(--weeks, 6), minmax(0, 1fr));
        border-radius: 10px;
        overflow: hidden;
    }

    .large-month .grid .w { padding: 6px 2px; font-size: 0.78rem; }
    .large-month .grid .w .long-text { display: none; }
    .large-month .grid .w .short-text { display: block; }

    .large-month .grid .cell {
        min-height: 0;
        padding: 4px 3px;
        overflow: hidden;
    }

    .large-month .grid .cell .day-number { font-size: 1rem; margin-bottom: 2px; }

    .notes-link {
        font-size: 0.6rem;
        padding: 2px 3px;
        min-height: 16px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .holiday-indicator-large { width: 6px; height: 6px; top: 3px; right: 3px; }

    /* ----- Janelas ----- */
    .notes-modal-content { width: calc(100% - 24px); max-height: 90vh; max-height: 90dvh; padding: 18px; }
    .notes-modal-textarea { min-height: 120px; }
    .notes-modal-actions { flex-direction: column; }
    .notes-modal-actions .header-btn { width: 100%; justify-content: center; }

    .sidebar { width: min(86vw, var(--sidebar-width)); }
}

/* Tablets pequenos e celulares grandes: números e títulos maiores */
@media (min-width: 600px) and (max-width: 768px) {
    .month .head { font-size: 1.15rem; }
    .month .grid { font-size: clamp(11px, 2vw, 14px); }
    .counter-display { font-size: 0.85rem; }
}

/* Celulares muito estreitos */
@media (max-width: 400px) {
    header h1 { display: none; } /* a logo já identifica o app */
    #mainPage { padding-left: 8px; padding-right: 8px; }
    .calendars { column-gap: 8px; }
    .month .grid { font-size: 9px; }
    .counter-display { font-size: 0.7rem; }
}

/* =====================================================================
   CELULAR DEITADO: 4 colunas × 3 linhas; a tela pode rolar se faltar altura
   ===================================================================== */
@media (max-width: 950px) and (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
    :root { --hdr-h: 42px; --bar-h: 46px; }

    body[data-page="main"],
    body[data-page="month"] { height: auto; overflow: auto; }

    header img { height: 26px !important; }
    .year-display { font-size: 1.4rem; }

    #mainPage { height: auto; min-height: calc(100dvh - var(--hdr-h) - var(--bar-h)); }

    .calendars {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-template-rows: repeat(3, minmax(0, 1fr));
        min-height: 250px;
        gap: 4px 14px;
    }

    .year-title-text { font-size: 1.5rem; }
    .year-title-nav { display: none; }
    .year-title { padding-bottom: 2px; }
    .counter-sidebar { padding: 0 2px; }
    #mainPage { padding-top: 4px; gap: 3px; }
    .month .head { font-size: 0.8rem; }
    .month .grid { font-size: 8px; }

    .bottom-menu { padding: 3px 8px; }
    .bottom-menu-btn { flex-direction: row; min-height: 38px; justify-content: center; gap: 6px; }
    .bottom-menu-btn span { font-size: 1.1rem; }
    .bottom-menu-btn .btn-text { font-size: 0.75rem; }

    body[data-page="month"] .month-page { height: auto; min-height: 0; }
    .large-month .grid .cell { min-height: 44px; }
    .large-month .grid { grid-template-rows: auto; }
}

/* =====================================================================
   Preferências do sistema
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
    * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* =====================================================================
   FOLHA DO PDF (fica fora da tela e só existe durante o compartilhamento).
   Medidas fixas em px: o PDF sai igual em qualquer aparelho.
   ===================================================================== */
.export-sheet {
    position: fixed;
    left: -10000px;
    top: 0;
    width: 794px;
    padding: 36px 40px 28px;
    background: #fff;
    color: #111827;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    line-height: 1.3;
}

.export-head { padding-bottom: 12px; margin-bottom: 20px; border-bottom: 2px solid var(--blue); }
.export-title { font-size: 32px; font-weight: 800; color: var(--blue); margin: 0; }
.export-subtitle { font-size: 16px; color: var(--muted); margin: 2px 0 0; }

.export-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 26px; }
.export-month-name { font-size: 16px; font-weight: 800; margin-bottom: 4px; }

.export-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.export-grid .w { font-size: 9px; font-weight: 700; color: #8a94a3; text-align: center; padding-bottom: 2px; }

.export-grid .cell {
    position: relative;
    height: 22px;
    margin: 0.5px;
    border: 0;
    border-radius: 4px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    cursor: default;
}

.export-grid .cell.empty { background: none; }
.export-grid .cell.work { background: var(--work-bg); color: #fff; font-weight: 700; }
.export-grid .cell.off { background: var(--off-bg); color: #fff; font-weight: 700; }
.export-grid .cell.extra { background: var(--extra-bg); color: #fff; font-weight: 700; }
.export-grid .holiday-indicator { top: 2px; right: 2px; width: 4px; height: 4px; }

.export-legend { display: flex; gap: 20px; align-items: center; margin-top: 22px; font-size: 12px; color: var(--muted); }
.export-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }
.export-legend i.work { background: var(--work-bg); }
.export-legend i.off { background: var(--off-bg); }
.export-legend i.extra { background: var(--extra-bg); }
.export-legend i.holiday { background: #ef4444; border-radius: 50%; width: 7px; height: 7px; vertical-align: 1px; }

.export-footer { margin-top: 16px; padding-top: 10px; border-top: 1px solid #e5e7eb; text-align: center; font-size: 12px; color: var(--muted); }


/* =====================================================================
   MELHORIAS: componentes novos
   ===================================================================== */
[hidden] { display: none !important; }

/* ----- Dias marcados (visual leve) ----- */
.cell, .month .grid .cell {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body.painting { cursor: crosshair; }

/* Pontinho: este dia tem nota */
.cell.has-note::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--blue-light);
}

/* ----- Resumo da escala ----- */
.scale-summary {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 10px 14px;
    background: var(--card);
    border-radius: 10px;
    border-left: 4px solid var(--muted);
    box-shadow: var(--shadow);
}

.scale-summary[data-kind="board"] { border-left-color: var(--work-bg); }
.scale-summary[data-kind="off"] { border-left-color: var(--off-bg); }

.scale-summary-main { font-size: 1rem; color: var(--ink); font-weight: 700; }
.scale-summary-sub { font-size: 0.85rem; color: var(--muted); }

.scale-summary-desktop { margin-bottom: 14px; }
.scale-summary-mobile { display: none; }

/* ----- Botão "Hoje" ----- */
.today-btn {
    border: 0;
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    background: rgba(239, 68, 68, 0.12);
    color: var(--today-color);
}

.today-btn-header {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-left: 10px;
}

.today-btn-month { display: block; margin: 8px auto 0; }

.year-title-nav .today-btn { width: auto; height: 32px; font-size: 0.85rem; margin-right: 6px; color: var(--today-color); }

/* ----- Aviso com "Desfazer" ----- */
#toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 16px);
    max-width: min(92vw, 460px);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #1f2937;
    color: #fff;
    font-size: 0.88rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1100;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

#toast button {
    background: none;
    border: 0;
    color: #7dd3fc;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    padding: 6px 4px;
    white-space: nowrap;
}

/* ----- Escalas prontas ----- */
.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 4px; }

.sidebar .preset-chip,
.preset-chip {
    width: auto;
    margin: 0;
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: var(--card);
    color: var(--blue);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.sidebar .preset-chip.active,
.preset-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ----- Janelas (período, nome e navio) ----- */
.save-menu-divider { height: 1px; background: var(--line); margin: 6px 4px; }

.form-grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center; margin-bottom: 18px; }
.form-grid label { font-weight: 600; font-size: 0.9rem; color: var(--muted); }

.form-grid input,
.form-grid select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    font-size: 16px;
    background: var(--card);
    color: var(--ink);
}

.modal-hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 14px; }

.notes-modal-actions .header-btn {
    background: var(--blue);
    color: #fff;
    border: 0;
    justify-content: center;
    min-height: 42px;
}

.notes-modal-actions .header-btn:hover { background: var(--blue-dark); }

/* ----- Primeira abertura ----- */
.onboarding {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(15, 23, 42, 0.55);
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.onboarding.show { display: flex; }

.onboarding-card {
    width: min(100%, 420px);
    max-height: 92vh;
    max-height: 92dvh;
    overflow: auto;
    padding: 22px 22px 18px;
    background: var(--card);
    color: var(--ink);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

.ob-dots { display: flex; gap: 6px; margin-bottom: 14px; }
.ob-dots i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.ob-dots i.on { background: var(--blue); }

.ob-step h2 { font-size: 1.3rem; margin: 0 0 4px; color: var(--ink); }
.ob-step p { color: var(--muted); margin: 0 0 14px; font-size: 0.92rem; }

.ob-custom { display: flex; gap: 12px; margin-top: 10px; }
.ob-custom label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }

.ob-custom input,
#obStart {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font: inherit;
    font-size: 16px;
    background: var(--card);
    color: var(--ink);
}

.ob-tips { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 0.9rem; color: var(--ink); }

.ob-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.ob-spacer { flex: 1; }

.ob-primary,
.ob-secondary,
.ob-link { cursor: pointer; font-size: 0.95rem; }

.ob-primary { background: var(--blue); color: #fff; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; }
.ob-secondary { background: none; color: var(--ink); border: 1px solid #cbd5e1; border-radius: 12px; padding: 11px 16px; font-weight: 600; }
.ob-link { background: none; border: 0; color: var(--muted); font-weight: 600; padding: 10px 6px; }

/* ----- Nome e navio no título do PDF ----- */
.export-person { font-size: 15px; font-weight: 600; margin: 2px 0 0; color: #111827; }

/* ----- Mês grande mais leve: lápis discreto; com nota, o começo do texto ----- */
.large-month .notes-link {
    border: 0;
    background: none;
    padding: 2px;
    margin-top: auto;
    font-size: 0.95rem;
    color: var(--muted);
    opacity: 0.4;
    justify-content: flex-end;
    align-items: flex-end;
}

.large-month .notes-link:hover { background: none; color: var(--blue); opacity: 1; }

.large-month .notes-link.has-notes {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    flex: 0 1 auto;
    opacity: 1;
    background: rgba(15, 76, 129, 0.08);
    border-radius: 6px;
    padding: 3px 5px;
    font-size: 0.72rem;
    line-height: 1.25;
    font-weight: 500;
    color: var(--ink);
    text-align: left;
    white-space: normal;
    word-break: break-word;
}

.large-month .notes-link.has-notes::before { content: none; }

/* =====================================================================
   MELHORIAS: celular
   ===================================================================== */
@media (max-width: 768px),
       (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
    :root { --hdr-h: 44px; }

    /* Cabeçalho discreto: sem faixa azul, só a marca */
    header {
        background: none;
        box-shadow: none;
        color: var(--ink);
    }

    header h1 { color: var(--ink); }

    header img {
        background: var(--blue);
        border-radius: 8px;
        padding: 3px 6px;
        height: 30px !important;
    }

    .today-btn-header { display: none !important; }

    /* Resumo da escala: no lugar certo, bem compacto */
    .scale-summary-desktop { display: none; }
    .scale-summary-mobile { display: flex; flex: none; padding: 6px 12px; }
    .scale-summary-main { font-size: 0.92rem; }
    .scale-summary-sub { font-size: 0.8rem; }

    #toast { bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 10px); }

    /* Menu "Escalas e dados": cabe em telas baixas */
    .scale-mobile-menu { max-height: 88vh; max-height: 88dvh; overflow-y: auto; width: min(92vw, 360px); }
    .scale-mobile-actions { gap: 6px; }
    .scale-mobile-btn { padding: 11px 14px; }

    .large-month .notes-link.has-notes { -webkit-line-clamp: 2; font-size: 0.62rem; padding: 2px 4px; }
    .large-month .notes-link { font-size: 0.85rem; }
}

/* Celulares baixos: resumo em uma linha só */
@media (max-height: 700px) and (max-width: 768px) {
    .scale-summary-mobile { flex-direction: row; align-items: baseline; gap: 8px; padding: 4px 10px; }
    .scale-summary-main { font-size: 0.82rem; white-space: nowrap; }
    .scale-summary-sub { font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .year-title-text { font-size: 1.7rem; }
}

@media (max-width: 950px) and (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
    :root { --hdr-h: 40px; }
    .scale-summary-mobile { flex-direction: row; align-items: baseline; gap: 8px; padding: 3px 10px; }
    .scale-summary-main { font-size: 0.78rem; }
    .scale-summary-sub { font-size: 0.72rem; }
}

/* =====================================================================
   MODO ESCURO (segue a configuração do aparelho)
   ===================================================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --card: #131c31;
        --muted: #94a3b8;
        --ink: #e5e7eb;
        --line: #24304d;
        --blue: #4f94e0;
        --blue-light: #3b82c4;
        --blue-dark: #0b2545;
        --today-color: #ff5a52;
        --work-soft: rgba(59, 130, 246, 0.30);
        --work-ink: #bfdbfe;
        --off-soft: rgba(16, 185, 129, 0.28);
        --off-ink: #a7f3d0;
        --extra-soft: rgba(245, 158, 11, 0.30);
        --extra-ink: #fde68a;
    }

    header { background: linear-gradient(135deg, #0b2545, #12335d); }

    .ad-container, .month, .counter-sidebar, .current-date { border-color: var(--line); }
    .ad-placeholder { background: #0f1830; border-color: #2a3a5c; }
    .counter-display { color: var(--ink); }
    .counter-item { border-color: var(--line); }

    .sidebar input[type="number"],
    .sidebar input[type="date"] { background: #0f1830; border-color: var(--line); color: var(--ink); }
    .sidebar input:focus { background: #0f1830; }

    .month .head { background: linear-gradient(90deg, #1b4f8a, #2b6cb0); }
    .month .grid .w { background: #0f1830; border-color: var(--line); }
    .month .grid .cell { border-color: var(--line); color: var(--ink); }

    .save-menu button { color: var(--ink); }
    .save-menu button:hover { background: #1c2744; }
    .save-menu-divider { background: var(--line); }

    .large-month .grid { background: var(--line); }
    .large-month .grid .w { background: #0f1830; }
    .large-month .grid .cell { background: var(--card); color: var(--ink); }
    .large-month .grid .cell.empty { background: transparent; }

    .notes-modal-header { border-color: var(--line); }
    .notes-modal-textarea,
    .form-grid input,
    .form-grid select,
    .ob-custom input,
    #obStart { background: #0f1830; border-color: var(--line); color: var(--ink); }

    .preset-chip, .sidebar .preset-chip { border-color: var(--line); }
    .ob-secondary { border-color: var(--line); }

    .month-header { border-color: var(--line); }
    .month-nav-btn { background: #1c2744; border-color: var(--line); color: var(--blue); }

    .large-month .notes-link.has-notes { background: rgba(79, 148, 224, 0.16); }

    #toast { background: #e5e7eb; color: #111827; }
    #toast button { color: #0b5cad; }

    .scale-mobile-btn.secondary { color: var(--ink); }
}

@media (prefers-color-scheme: dark) and (max-width: 768px),
       (prefers-color-scheme: dark) and (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
    .year-title { border-color: var(--line); }
    .year-title-nav button:active { background: #1c2744; }

    .bottom-menu { background: rgba(19, 28, 49, 0.94); border-color: var(--line); }
    .bottom-menu-btn { color: var(--blue); }
    .bottom-menu-btn:active { background: #1c2744; }

    header img { background: #1b4f8a; }

    /* Visão do ano no celular: nomes dos meses sem barra colorida */
    .month .head { background: none; color: var(--ink); }
    .month .head.current { color: var(--today-color); }
}

/* =====================================================================
   Dias marcados: fundo suave + texto colorido (vem por último para valer em tudo)
   ===================================================================== */
.cell.work,
.large-month .cell.work,
.export-grid .cell.work { background-color: var(--work-soft); color: var(--work-ink); }

.cell.off,
.large-month .cell.off,
.export-grid .cell.off { background-color: var(--off-soft); color: var(--off-ink); }

.cell.extra,
.large-month .cell.extra,
.export-grid .cell.extra { background-color: var(--extra-soft); color: var(--extra-ink); }

/* Hoje continua em destaque, mesmo sobre um dia marcado */
.month .grid .cell.today,
.large-month .cell.today .day-number { color: #fff; }

/* A folha do PDF é sempre clara, mesmo no modo escuro do aparelho */
.export-sheet {
    --card: #ffffff;
    --ink: #111827;
    --muted: #64748b;
    --line: #e2e8f0;
    --work-soft: #dbeafe;
    --work-ink: #1e40af;
    --off-soft: #d1fae5;
    --off-ink: #047857;
    --extra-soft: #fef3c7;
    --extra-ink: #92400e;
    --blue: #0f4c81;
}
