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

    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background: #eef2f7;
      color: #1a202c;
      min-height: 100vh;
    }

    /* ── Header ── */
    header {
      background: linear-gradient(135deg, #1e3a5f 0%, #1d4ed8 100%);
      color: white;
      padding: 22px 24px;
      text-align: center;
      box-shadow: 0 2px 10px rgba(0,0,0,0.25);
      position: relative;
    }
    header h1 {
      font-size: 1.55rem;
      font-weight: 800;
      letter-spacing: 2.5px;
      text-transform: uppercase;
    }
    header p {
      margin-top: 5px;
      font-size: 0.88rem;
      opacity: 0.72;
      letter-spacing: 1px;
    }

    /* ── Botão admin no header ── */
    .header-actions {
      position: absolute;
      top: 14px;
      right: 18px;
      display: flex;
      gap: 8px;
      align-items: center;
    }
    .header-btn {
      background: rgba(255,255,255,0.12);
      color: white;
      border: 1px solid rgba(255,255,255,0.2);
      border-radius: 20px;
      padding: 6px 14px;
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      font-family: inherit;
      letter-spacing: 0.5px;
      transition: background .2s;
    }
    .header-btn:hover { background: rgba(255,255,255,0.22); }

    /* ── Tabs ── */
    .tabs {
      background: #172554;
      display: flex;
      justify-content: center;
    }
    .tab-btn {
      padding: 13px 40px;
      border: none;
      background: transparent;
      color: rgba(255,255,255,0.55);
      font-size: 0.87rem;
      font-weight: 600;
      letter-spacing: 0.5px;
      cursor: pointer;
      border-bottom: 3px solid transparent;
      transition: color .2s, border-color .2s;
      font-family: inherit;
      text-transform: uppercase;
    }
    .tab-btn:hover { color: rgba(255,255,255,0.88); }
    .tab-btn.active { color: white; border-bottom-color: #60a5fa; }

    /* ── Container ── */
    .container {
      max-width: 980px;
      margin: 0 auto;
      padding: 28px 20px;
    }
    .page { display: none; }
    .page.active { display: block; }
    .page[hidden], [hidden] { display: none !important; }

    /* ── Controls ── */
    .controls {
      display: flex;
      align-items: center;
      gap: 16px;
      margin-bottom: 26px;
      background: white;
      padding: 16px 20px;
      border-radius: 12px;
      box-shadow: 0 1px 5px rgba(0,0,0,0.07);
      flex-wrap: wrap;
    }
    .cg { display: flex; align-items: center; gap: 8px; }
    .controls label {
      font-size: 0.76rem;
      font-weight: 700;
      color: #64748b;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    .controls select {
      padding: 7px 10px;
      border: 1.5px solid #e2e8f0;
      border-radius: 8px;
      font-size: 0.9rem;
      color: #1e293b;
      background: #f8fafc;
      cursor: pointer;
      transition: border-color .2s, background .2s;
      font-family: inherit;
    }
    .controls select:hover { border-color: #94a3b8; }
    .controls select:focus { outline: none; border-color: #1d4ed8; background: white; }
    .tool-btn {
      border: 1.5px solid #bfdbfe;
      background: #eff6ff;
      color: #1d4ed8;
      border-radius: 8px;
      padding: 8px 12px;
      font-size: 0.82rem;
      font-weight: 700;
      cursor: pointer;
      font-family: inherit;
    }
    .tool-btn:hover { background: #dbeafe; }

    /* ── Section ── */
    .section { margin-bottom: 28px; }

    .sec-head {
      background: linear-gradient(90deg, #1e3a8a, #1d4ed8);
      color: white;
      padding: 11px 16px;
      font-size: 0.74rem;
      font-weight: 700;
      letter-spacing: 1.8px;
      text-transform: uppercase;
      border-radius: 10px 10px 0 0;
    }

    /* ── Table ── */
    .tbl-wrap {
      background: white;
      border-radius: 0 0 10px 10px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.06);
      overflow-x: auto;
    }
    table { width: 100%; min-width: 520px; border-collapse: collapse; }
    thead th {
      background: #eff6ff;
      color: #1e40af;
      font-size: 0.71rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.9px;
      padding: 10px 12px;
      border-bottom: 2px solid #bfdbfe;
      text-align: center;
    }
    tbody tr { transition: background .12s; }
    tbody tr:hover { background: #f8fafc; }
    tbody tr:not(:last-child) td { border-bottom: 1px solid #f1f5f9; }
    tbody td { padding: 4px 6px; vertical-align: middle; }

    tbody td input {
      width: 100%;
      padding: 7px 9px;
      border: 1.5px solid transparent;
      border-radius: 6px;
      font-size: 0.87rem;
      font-family: inherit;
      color: #1e293b;
      background: transparent;
      text-align: center;
      transition: border-color .15s, background .15s;
    }
    tbody td input:hover:not(:disabled) { border-color: #e2e8f0; background: #f8fafc; }
    tbody td input:focus  { outline: none; border-color: #93c5fd; background: #eff6ff; }
    tbody td input:disabled {
      cursor: default;
      color: #1e293b;
      background: transparent !important;
      border-color: transparent !important;
    }

    .col-d { width: 70px; }
    .col-t { width: 120px; }
    .col-x { width: 42px; text-align: center; }

    /* Remove button */
    .btn-del {
      width: 28px; height: 28px;
      border: none; border-radius: 6px;
      background: transparent;
      color: #cbd5e1;
      font-size: 17px;
      cursor: pointer;
      transition: background .15s, color .15s;
      display: flex; align-items: center; justify-content: center;
      margin: auto;
    }
    .btn-del:hover { background: #fee2e2; color: #ef4444; }

    /* Add row button */
    .btn-add {
      width: 100%;
      padding: 10px;
      border: none;
      border-top: 2px dashed #bfdbfe;
      background: white;
      color: #3b82f6;
      font-size: 0.81rem;
      font-weight: 600;
      cursor: pointer;
      font-family: inherit;
      letter-spacing: 0.3px;
      transition: background .15s, color .15s;
    }
    .btn-add:hover { background: #eff6ff; color: #1d4ed8; }

    /* Arranjos cells */
    .arr-month-h {
      width: 140px;
      border-right: 2px solid #bfdbfe;
    }
    .num-c { display: none; }
    .mes-c {
      font-weight: 600;
      color: #334155;
      padding-left: 16px !important;
      border-right: 2px solid #e2e8f0;
    }

    /* ── Toast ── */
    #toast {
      position: fixed;
      bottom: 22px; right: 22px;
      background: #15803d;
      color: white;
      padding: 10px 18px;
      border-radius: 10px;
      font-size: 0.84rem;
      font-weight: 600;
      box-shadow: 0 4px 14px rgba(0,0,0,0.14);
      opacity: 0;
      transform: translateY(6px);
      transition: opacity .25s, transform .25s;
      pointer-events: none;
      z-index: 999;
      max-width: 320px;
    }
    #toast.on { opacity: 1; transform: translateY(0); }
    #toast.err { background: #b91c1c; }
    #toast.busy { background: #1d4ed8; }
    .save-status {
      display: inline-block;
      margin-top: 8px;
      padding: 3px 12px;
      border-radius: 20px;
      background: rgba(255,255,255,0.12);
      color: rgba(255,255,255,0.78);
      font-size: 0.68rem;
      font-weight: 700;
      letter-spacing: 1px;
      text-transform: uppercase;
    }
    .save-status.saving { background: rgba(96,165,250,0.28); color: white; }
    .save-status.saved { background: rgba(34,197,94,0.22); color: white; }
    .save-status.error { background: rgba(239,68,68,0.25); color: white; }
    #updateApp {
      position: fixed;
      left: 50%;
      bottom: 18px;
      transform: translateX(-50%);
      z-index: 10000;
      border: none;
      border-radius: 999px;
      background: #172554;
      color: white;
      padding: 11px 18px;
      box-shadow: 0 10px 30px rgba(15,23,42,0.25);
      font-family: inherit;
      font-size: 0.86rem;
      font-weight: 800;
      cursor: pointer;
    }
    #updateApp:hover { background: #1d4ed8; }

    /* ── Loading ── */
    #loadingOverlay {
      position: fixed;
      inset: 0;
      background: rgba(238,242,247,0.95);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 14px;
      z-index: 8888;
      transition: opacity .3s;
    }
    #loadingOverlay.hide { opacity: 0; pointer-events: none; }
    #loadingOverlay span { font-size: 0.85rem; color: #64748b; font-weight: 600; letter-spacing: 0.5px; }
    .spinner {
      width: 38px; height: 38px;
      border: 4px solid #bfdbfe;
      border-top-color: #1d4ed8;
      border-radius: 50%;
      animation: spin .75s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* ── Badge de perfil ── */
    .role-badge {
      display: inline-block;
      margin-top: 8px;
      padding: 3px 12px;
      border-radius: 20px;
      font-size: 0.7rem;
      font-weight: 700;
      letter-spacing: 1px;
      text-transform: uppercase;
    }
    .role-badge.admin { background: rgba(255,255,255,0.22); color: white; }
    .role-badge.user  { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.75); }

    /* ── Modal de login ── */
    #loginModal {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.65);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 9999;
      padding: 16px;
    }
    #loginModal.on { display: flex; }
    #backupModal {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.65);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 9998;
      padding: 16px;
    }
    #backupModal.on { display: flex; }
    .backup-box {
      background: white;
      border-radius: 14px;
      width: min(620px, 100%);
      max-height: 82vh;
      overflow: hidden;
      box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }
    .modal-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 18px;
      border-bottom: 1px solid #e2e8f0;
    }
    .modal-head h2 {
      font-size: 0.95rem;
      letter-spacing: 1px;
      text-transform: uppercase;
      color: #1e3a5f;
    }
    .icon-btn {
      border: none;
      background: transparent;
      color: #64748b;
      cursor: pointer;
      font-size: 1.4rem;
      line-height: 1;
      width: 32px;
      height: 32px;
      border-radius: 8px;
    }
    .icon-btn:hover { background: #f1f5f9; color: #1e293b; }
    .backup-list {
      padding: 12px;
      max-height: calc(82vh - 62px);
      overflow: auto;
    }
    .backup-item {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      align-items: center;
      padding: 12px;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      margin-bottom: 10px;
      background: #f8fafc;
    }
    .backup-meta {
      color: #334155;
      font-size: 0.86rem;
      line-height: 1.35;
    }
    .backup-meta small {
      display: block;
      color: #94a3b8;
      margin-top: 2px;
    }
    .backup-restore {
      border: none;
      background: #1d4ed8;
      color: white;
      border-radius: 8px;
      padding: 8px 12px;
      font-family: inherit;
      font-weight: 700;
      cursor: pointer;
    }
    .backup-restore:hover { background: #1e40af; }
    .login-box {
      background: white;
      border-radius: 16px;
      padding: 36px 32px;
      width: 340px;
      max-width: 100%;
      box-shadow: 0 20px 60px rgba(0,0,0,0.3);
      text-align: center;
    }
    .login-icon { font-size: 2.4rem; margin-bottom: 12px; }
    .login-box h2 {
      font-size: 1.05rem;
      font-weight: 800;
      color: #1e3a5f;
      letter-spacing: 1px;
      text-transform: uppercase;
      margin-bottom: 4px;
    }
    .login-box p {
      font-size: 0.82rem;
      color: #94a3b8;
      margin-bottom: 22px;
    }
    .login-box input {
      width: 100%;
      padding: 11px 14px;
      border: 2px solid #e2e8f0;
      border-radius: 10px;
      font-size: 0.95rem;
      font-family: inherit;
      color: #1e293b;
      outline: none;
      transition: border-color .2s;
      margin-bottom: 12px;
    }
    .login-box input:focus { border-color: #1d4ed8; }
    .login-box input.erro  { border-color: #ef4444; animation: shake .3s; }
    .login-actions { display: flex; gap: 10px; margin-top: 4px; }
    .login-actions button {
      flex: 1;
      padding: 11px;
      border: none;
      border-radius: 10px;
      font-size: 0.88rem;
      font-weight: 700;
      cursor: pointer;
      font-family: inherit;
      transition: opacity .2s, background .2s;
    }
    .btn-primary {
      background: linear-gradient(135deg, #1e3a5f, #1d4ed8);
      color: white;
    }
    .btn-primary:hover { opacity: .9; }
    .btn-primary:disabled { opacity: .5; cursor: wait; }
    .btn-secondary {
      background: #f1f5f9;
      color: #475569;
    }
    .btn-secondary:hover { background: #e2e8f0; }
    .login-divider {
      display: flex;
      align-items: center;
      gap: 10px;
      margin: 16px 0 12px;
      color: #94a3b8;
      font-size: 0.72rem;
      letter-spacing: 1px;
      text-transform: uppercase;
    }
    .login-divider::before, .login-divider::after {
      content: '';
      flex: 1;
      height: 1px;
      background: #e2e8f0;
    }
    .btn-google {
      width: 100%;
      padding: 11px;
      border: 1.5px solid #e2e8f0;
      border-radius: 10px;
      background: white;
      color: #1e293b;
      font-size: 0.9rem;
      font-weight: 600;
      cursor: pointer;
      font-family: inherit;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      transition: background .15s, border-color .15s;
    }
    .btn-google:hover { background: #f8fafc; border-color: #cbd5e1; }
    .btn-google svg { width: 18px; height: 18px; flex-shrink: 0; }
    #loginErr {
      margin-top: 12px;
      font-size: 0.8rem;
      color: #ef4444;
      min-height: 16px;
    }
    @keyframes shake {
      0%,100% { transform: translateX(0); }
      25%      { transform: translateX(-6px); }
      75%      { transform: translateX(6px); }
    }

    /* ── Drag handle (desktop) ── */
    .col-drag-h { width: 28px; }
    .col-drag {
      width: 28px;
      text-align: center;
      color: #cbd5e1;
      cursor: grab;
      font-size: 1.15rem;
      user-select: none;
      padding: 4px 2px !important;
    }
    .col-drag:active { cursor: grabbing; }
    tr.dragging { opacity: 0.35; }
    tr.drag-over td { background: #dbeafe !important; }

    /* ── Mobile reorder buttons (escondidos no desktop) ── */
    .mob-reorder { display: none; }
    .btn-mv {
      width: 22px; height: 22px;
      border: none; border-radius: 5px;
      background: transparent;
      color: #94a3b8;
      font-size: 14px;
      cursor: pointer;
      display: inline-flex; align-items: center; justify-content: center;
      padding: 0;
    }
    .btn-mv:hover:not(:disabled) { background: #eff6ff; color: #1d4ed8; }
    .btn-mv:disabled { opacity: .25; cursor: default; }

    @media (max-width: 600px) {
      .col-drag, .col-drag-h { display: none !important; }
      header h1 { font-size: 1.1rem; }
      header { padding-top: 50px; }
      .header-actions { top: 10px; right: 10px; }
      .tab-btn { padding: 11px 18px; font-size: 0.78rem; }
      .container { padding: 14px 10px; }
      table { min-width: unset; }
      .tbl-wrap { overflow: hidden; }
      thead { display: none; }
      table.arr-table thead { display: table-header-group; }

      /* ── Programa Mensal — cartão ── */
      tbody:not(#bArr) tr {
        display: block;
        border-bottom: 2px solid #e2e8f0;
        padding: 10px 4px;
      }
      tbody:not(#bArr) tr:last-child { border-bottom: none; }
      tbody:not(#bArr) tr:hover { background: none; }

      tbody:not(#bArr) td {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 10px;
        border: none !important;
        width: auto !important;
      }
      tbody:not(#bArr) td::before {
        content: attr(data-label);
        font-size: 0.7rem;
        font-weight: 700;
        color: #94a3b8;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        min-width: 90px;
        flex-shrink: 0;
      }
      tbody:not(#bArr) td.col-x { justify-content: flex-end; gap: 4px; }
      tbody:not(#bArr) td.col-x::before { display: none; }
      tbody:not(#bArr) td input { text-align: left; font-size: 0.9rem; flex: 1; }

      .mob-reorder { display: inline-flex; gap: 2px; margin-right: 4px; }

      /* ── Arranjos Anual — igual ao desktop ── */
      #bArr tr { display: table-row; padding: 0; }
      #bArr td { display: table-cell; padding: 6px 8px !important; width: auto !important; }
      #bArr td::before { display: none; }
      #bArr .num-c { display: none !important; }
      #bArr .mes-c { font-size: 0.85rem; padding-left: 12px !important; }
      #bArr td:last-child input { text-align: left; font-size: 0.85rem; }
      .backup-item { grid-template-columns: 1fr; }
    }

    @media print {
      #loadingOverlay, #toast, #updateApp, .header-actions, .tabs, .controls,
      .btn-add, .col-x, .col-drag, .col-drag-h, #loginModal, #backupModal,
      .save-status { display: none !important; }
      body { background: white; color: black; }
      header {
        background: white;
        color: black;
        box-shadow: none;
        padding: 0 0 12px;
      }
      .container { max-width: none; padding: 0; }
      .page { display: none !important; }
      #page-prog { display: block !important; }
      .section { break-inside: avoid; margin-bottom: 18px; }
      .sec-head {
        background: #e5e7eb;
        color: black;
        border-radius: 0;
      }
      .tbl-wrap { box-shadow: none; border-radius: 0; }
      tbody td input {
        border: none;
        color: black;
        padding: 4px;
      }
    }
