:root {
    --primary: #6d5efc;
    --primary-dark: #5644e8;
    --primary-light: #efeaff;
    --accent: #ff6fb0;
    --gradient: linear-gradient(135deg, #6d5efc 0%, #8b5cf6 50%, #ff6fb0 130%);
    --bg: #f3f2fb;
    --surface: #ffffff;
    --border: #e7e4f5;
    --text: #201c3d;
    --muted: #736f92;
    --danger: #e0355f;
    --danger-bg: #fde8ee;
    --success: #17a673;
    --success-bg: #e5f8f1;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(32, 28, 61, 0.06);
    --shadow: 0 8px 24px -8px rgba(78, 63, 173, 0.18);
    --shadow-lg: 0 20px 45px -12px rgba(78, 63, 173, 0.28);
    --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }

::selection { background: var(--primary); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d6d1f0; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #c2baea; background-clip: padding-box; }

html {
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background:
        radial-gradient(1100px 500px at 100% -10%, rgba(255, 111, 176, 0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 0%, rgba(109, 94, 252, 0.12), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    width: 100%;
}

img { max-width: 100%; }

a { color: var(--primary); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-dark); text-decoration: underline; }

h2 {
    font-weight: 700;
    letter-spacing: -0.01em;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.brand:hover { text-decoration: none; filter: brightness(1.08); }

.search-form {
    flex: 1;
    display: flex;
    max-width: 480px;
    position: relative;
}

.search-form input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    background: #f8f8fd;
    border-radius: 999px 0 0 999px;
    outline: none;
    font-size: 0.9rem;
    font-family: inherit;
    transition: box-shadow .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}

.search-form input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.search-form button {
    padding: 10px 18px;
    border: none;
    background: var(--gradient);
    color: #fff;
    border-radius: 0 999px 999px 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
    transition: filter .15s var(--ease), transform .15s var(--ease);
}

.search-form button:hover { filter: brightness(1.06); }
.search-form button:active { transform: scale(0.97); }

.user-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 18px;
    white-space: nowrap;
}

.user-nav a {
    color: var(--muted);
    font-weight: 500;
    font-size: 0.88rem;
    padding: 6px 10px;
    border-radius: 999px;
    transition: background .15s var(--ease), color .15s var(--ease);
}

.user-nav a:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    text-decoration: none;
}

.user-name {
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    padding: 5px 12px;
    background: var(--primary-light);
    border-radius: 999px;
}

.content {
    max-width: 1100px;
    margin: 28px auto;
    padding: 0 20px 60px;
    animation: fadeUp .35s var(--ease);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 22px;
}

.inline-form {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin: 0;
}

.toolbar .inline-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .18s var(--ease), transform .18s var(--ease);
}

.toolbar .inline-form:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.toolbar .inline-form input[type="text"] {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.toolbar .inline-form input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: -8px 0 20px;
    font-size: 0.85rem;
    color: var(--muted);
    box-shadow: var(--shadow-sm);
}

.upload-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.upload-progress-bar > div {
    height: 100%;
    width: 0;
    background: var(--gradient);
    border-radius: 4px;
    transition: width 0.15s ease-out;
}

#uploadProgressLabel {
    white-space: nowrap;
    font-weight: 500;
}

button, .button {
    background: var(--gradient);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    display: inline-block;
    box-shadow: 0 2px 8px -2px rgba(109, 94, 252, 0.45);
    transition: filter .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
}

button:hover, .button:hover {
    filter: brightness(1.07);
    text-decoration: none;
    box-shadow: 0 6px 16px -4px rgba(109, 94, 252, 0.5);
    transform: translateY(-1px);
}

button:active, .button:active { transform: translateY(0) scale(0.98); }

.actions form button {
    background: none;
    color: var(--muted);
    padding: 4px 8px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: none;
}

.actions form button:hover {
    color: var(--danger);
    text-decoration: underline;
    background: none;
    box-shadow: none;
    transform: none;
}

.breadcrumb {
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.breadcrumb a { font-weight: 500; }

.file-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.file-table th, .file-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.92rem;
}

.file-table th {
    background: #faf9ff;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.file-table tbody tr { transition: background .15s var(--ease); }
.file-table tbody tr:hover { background: #faf9ff; }

.file-table tr:last-child td { border-bottom: none; }

.item-link { color: var(--text); font-weight: 600; }
.item-link:hover { color: var(--primary); }

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.actions a { font-size: 0.85rem; font-weight: 500; }

.rename-input {
    width: 140px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.rename-ext {
    color: var(--muted);
    font-size: 0.85rem;
    margin-left: -6px;
}

.empty, .hint {
    color: var(--muted);
    font-style: normal;
    text-align: center;
}

.hint { text-align: left; font-size: 0.85rem; }

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 4px solid transparent;
    animation: fadeUp .3s var(--ease);
}

.flash.success { background: var(--success-bg); color: var(--success); border-left-color: var(--success); }
.flash.error { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); }

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(900px 500px at 15% 10%, rgba(255, 111, 176, 0.35), transparent 60%),
        radial-gradient(900px 600px at 85% 90%, rgba(109, 94, 252, 0.45), transparent 60%),
        linear-gradient(160deg, #201c3d 0%, #362a76 55%, #5644e8 100%);
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    padding: 24px;
}

.auth-box {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: fadeUp .4s var(--ease);
}

.auth-box h1 {
    margin: 0 0 6px;
    font-size: 1.4rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.auth-box h2 { margin: 0 0 24px; font-weight: 600; color: var(--muted); font-size: 1rem; }

.auth-box form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: left;
}

.auth-box label { font-size: 0.82rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }

.auth-box input {
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.auth-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.auth-box button { margin-top: 8px; padding: 12px; font-size: 0.9rem; }

.auth-box p { font-size: 0.88rem; color: var(--muted); }

.share-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 600px;
    box-shadow: var(--shadow-sm);
}

.share-box h3 { margin: 20px 0 10px; font-size: 0.95rem; }
.share-box h3:first-child { margin-top: 0; }

.share-list { list-style: none; padding: 0; margin: 0; }

.share-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.share-list input[type="text"] {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-family: inherit;
}

/* ------------------------------------------------------------ */
/* Editor de planilhas (sheet_edit.php / sheet_public.php)       */
/* ------------------------------------------------------------ */

.sheet-page {
    max-width: none;
}

.sheet-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.sheet-back {
    white-space: nowrap;
    font-weight: 600;
}

.sheet-rename-form {
    flex: 0 1 auto;
}

.sheet-title-input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 700;
    min-width: 220px;
    font-family: inherit;
}

.sheet-title-readonly {
    font-size: 1rem;
    font-weight: 600;
}

.sheet-status {
    color: var(--muted);
    font-size: 0.85rem;
    min-width: 90px;
}

.sheet-status-error {
    color: var(--danger);
}

.sheet-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sheet-actions button {
    font-size: 0.85rem;
    padding: 7px 12px;
}

.sheet-readonly-hint {
    margin: 0 0 10px;
    text-align: left;
}

.sheet-help {
    text-align: left;
    font-size: 0.8rem;
    margin-top: 10px;
}

.sheet-formula-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
}

.sheet-cell-ref {
    font-weight: 700;
    color: var(--primary-dark);
    min-width: 40px;
    font-size: 0.85rem;
}

.sheet-formula-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

.sheet-grid-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.sheet-grid {
    position: relative;
    overflow: auto;
    max-height: 70vh;
    outline: none;
}

.sheet-table {
    border-collapse: collapse;
    table-layout: fixed;
}

.sheet-table th,
.sheet-table td {
    border: 1px solid var(--border);
    padding: 0;
    font-size: 0.85rem;
}

.sheet-table thead th {
    position: sticky;
    top: 0;
    background: #faf9ff;
    color: var(--muted);
    font-weight: 700;
    width: 96px;
    min-width: 96px;
    height: 28px;
    z-index: 2;
}

.sheet-table th.sheet-corner {
    position: sticky;
    left: 0;
    top: 0;
    z-index: 3;
    width: 44px;
    min-width: 44px;
}

.sheet-table tbody th {
    position: sticky;
    left: 0;
    background: #faf9ff;
    color: var(--muted);
    font-weight: 700;
    width: 44px;
    min-width: 44px;
    z-index: 1;
}

.sheet-cell {
    width: 96px;
    min-width: 96px;
    height: 26px;
    padding: 3px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: cell;
    user-select: none;
}

.sheet-cell.cell-number {
    text-align: right;
}

.sheet-cell.cell-error {
    color: var(--danger);
    font-weight: 600;
}

.sheet-cell.selected {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    background: var(--primary-light);
}

/* Formatação de célula aplicada via barra (assets/js/sheet.js render()) */
.sheet-cell.cell-bordered {
    border: 2px solid var(--text);
}

.sheet-cell.cell-wrap {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    height: auto;
}

.sheet-cell-editor {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid var(--primary);
    padding: 2px 5px;
    font-size: 0.85rem;
    font-family: inherit;
    background: #fff;
    z-index: 5;
    outline: none;
    box-shadow: var(--shadow);
}

.sheet-cell-select {
    box-sizing: border-box;
    font-size: 0.85rem;
    font-family: inherit;
}

/* Intervalo selecionado (arrastar/shift+clique/shift+seta) — o foco em si
   usa .selected (acima); .in-range marca as demais células do intervalo. */
.sheet-cell.in-range {
    background: #ece8fd;
}

/* Célula com validação de dados (vira <select> ao editar, ver sheet.js). */
.sheet-cell.cell-has-validation {
    box-shadow: inset 0 -2px 0 var(--primary);
}

/* Fixar 1ª linha/coluna (menu Ver) — sticky é aplicado inline por
   sheet.js render(); aqui só garante o contraste visual. */
.sheet-table th.sheet-frozen-row,
.sheet-table th.sheet-frozen-col,
.sheet-table td.sheet-frozen-row,
.sheet-table td.sheet-frozen-col {
    background: #fff;
    box-shadow: 0 1px 0 var(--border);
}

/* Linha oculta por filtro (menu Dados > Criar um filtro). */
.sheet-table tr.sheet-row-hidden {
    display: none;
}

/* Botão de filtro (▾) no cabeçalho da coluna quando um filtro está ativo. */
.sheet-filter-btn {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.7rem;
    padding: 2px;
    line-height: 1;
    box-shadow: none;
}

.sheet-filter-btn:hover {
    color: var(--primary);
    background: none;
    transform: translateY(-50%);
}

.sheet-filter-menu {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    z-index: 30;
    min-width: 200px;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.sheet-filter-menu-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.sheet-filter-menu-actions button {
    font-size: 0.8rem;
    padding: 4px 10px;
}

.sheet-filter-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.sheet-filter-menu li {
    font-size: 0.85rem;
    padding: 2px 0;
}

.sheet-filter-menu li label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.sheet-filter-menu-footer {
    margin-top: 8px;
    text-align: right;
}

/* ---- Barra de menu (Arquivo/Editar/Ver/Inserir/Formatar/Dados/Ferramentas/Ajuda) ---- */

.sheet-menubar {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    user-select: none;
}

.sheet-menu {
    position: relative;
}

.sheet-menu-btn {
    background: none;
    border: none;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    box-shadow: none;
    transition: background .15s var(--ease);
}

.sheet-menu-btn:hover,
.sheet-menu.open .sheet-menu-btn {
    background: var(--primary-light);
    transform: none;
    box-shadow: none;
}

.sheet-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    min-width: 240px;
    z-index: 25;
}

.sheet-menu-dropdown.open {
    display: block;
    animation: fadeUp .15s var(--ease);
}

.sheet-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
    border-radius: 0;
}

.sheet-menu-item:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    transform: none;
}

.sheet-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* ---- Diálogos modais (localizar/substituir, link, função, formatação
   condicional, validação de dados, atalhos, sobre) ---- */

.sheet-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(32, 28, 61, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeUp .15s var(--ease);
}

.sheet-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 420px;
    max-height: 82vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.sheet-modal h3 {
    margin: 0 0 16px;
    font-size: 1.05rem;
    font-weight: 700;
}

.sheet-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.9rem;
}

.sheet-modal-body label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

.sheet-modal-body label.sheet-modal-checkbox {
    flex-direction: row;
    align-items: center;
    color: var(--text);
}

.sheet-modal-body input[type="text"],
.sheet-modal-body select,
.sheet-modal-body textarea {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    outline: none;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.sheet-modal-body input[type="text"]:focus,
.sheet-modal-body select:focus,
.sheet-modal-body textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.sheet-modal-body input[type="color"] {
    width: 60px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.sheet-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.sheet-shortcuts-list {
    margin: 0;
    padding-left: 18px;
    font-size: 0.85rem;
    line-height: 1.7;
}

/* A barra de formatação da planilha (sheet_edit.php) reaproveita as mesmas
   classes de botão/ícone/seletor de cor do editor de documentos (doc-icon-btn,
   doc-color-btn, doc-font-size, doc-toolbar-sep, is-active — ver acima, na
   seção "Editor de documentos de texto") para não duplicar CSS. */

@media print {
    .sheet-menubar, .sheet-toolbar, .sheet-formula-bar, .doc-format-toolbar, .hint {
        display: none !important;
    }
    main.content {
        padding: 0;
    }
    .sheet-grid-wrap {
        border: none;
    }
    .sheet-grid {
        max-height: none;
        overflow: visible;
    }
}

/* ------------------------------------------------------------ */
/* Editor de documentos de texto (doc_edit.php)                  */
/* ------------------------------------------------------------ */

.doc-page {
    max-width: none;
}

.doc-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.doc-format-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 10px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

/* Botões de ícone no estilo "flat": sem borda visível em repouso,
   fundo arredondado ao passar o mouse ou quando o comando está ativo
   na seleção atual (ver DocEditor.prototype.updateToolbarState no doceditor.js). */
.doc-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #4b4570;
    cursor: pointer;
    box-shadow: none;
    transition: background .15s var(--ease), color .15s var(--ease);
}

.doc-icon-btn svg {
    width: 19px;
    height: 19px;
    fill: currentColor;
    stroke: none;
    overflow: visible;
}

.doc-icon-btn:hover {
    background: var(--primary-light);
    transform: none;
    box-shadow: none;
}

.doc-icon-btn.is-active {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.doc-text-btn {
    font-size: 0.95rem;
}

.doc-format-toolbar select {
    background: transparent;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 6px 6px;
    font-size: 0.85rem;
    max-width: 150px;
    height: 32px;
    font-family: inherit;
}

.doc-format-toolbar select:hover {
    background: var(--primary-light);
    border-color: var(--border);
}

.doc-font-size {
    display: flex;
    align-items: center;
    gap: 0;
    border-radius: var(--radius-sm);
    padding: 0 2px;
}

.doc-font-size button {
    border: none;
    width: 22px;
    height: 32px;
    padding: 0;
    background: transparent;
    border-radius: var(--radius-sm);
    color: #4b4570;
    cursor: pointer;
    box-shadow: none;
}

.doc-font-size button:hover {
    background: var(--primary-light);
    transform: none;
}

.doc-font-size input {
    width: 34px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text);
    height: 28px;
    font-family: inherit;
}

.doc-font-size input:hover,
.doc-font-size input:focus {
    border-color: var(--border);
    outline: none;
}

.doc-color-btn {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: #4b4570;
    overflow: hidden;
}

.doc-color-btn:hover {
    background: var(--primary-light);
}

.doc-color-letter {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1;
}

.doc-color-btn svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.doc-color-bar {
    display: block;
    width: 18px;
    height: 3px;
    border-radius: 1px;
    margin-top: 2px;
}

.doc-color-btn input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

.doc-toolbar-sep {
    width: 1px;
    align-self: stretch;
    margin: 4px 6px;
    background: var(--border);
}

.doc-page-wrap {
    display: flex;
    justify-content: center;
    background: linear-gradient(180deg, #eeecfb 0%, #f3f2fb 100%);
    border-radius: var(--radius);
    padding: 34px 16px;
}

.doc-editable {
    background: #fff;
    box-shadow: var(--shadow-lg);
    border-radius: 4px;
    width: 100%;
    max-width: 820px;
    min-height: 70vh;
    padding: 60px 70px;
    box-sizing: border-box;
    outline: none;
    line-height: 1.6;
    font-size: 1rem;
}

.doc-editable h1 { font-size: 1.8rem; margin: 0.6em 0 0.3em; }
.doc-editable h2 { font-size: 1.4rem; margin: 0.6em 0 0.3em; }
.doc-editable h3 { font-size: 1.15rem; margin: 0.6em 0 0.3em; }
.doc-editable p { margin: 0 0 0.9em; }
.doc-editable ul, .doc-editable ol { margin: 0 0 0.9em; padding-left: 1.5em; }
.doc-editable table { border-collapse: collapse; margin: 0 0 0.9em; }
.doc-editable table td { border: 1px solid var(--border); padding: 6px 10px; }
.doc-editable a { color: var(--primary); }
.doc-editable hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }

/* Ver > Mostrar marcas de formatação — pilcrow (¶) no fim de cada bloco.
   Só uma preferência visual da sessão (assets/js/doceditor.js toggleFormattingMarks),
   não é salva no documento. */
.doc-editable.show-marks p::after,
.doc-editable.show-marks h1::after,
.doc-editable.show-marks h2::after,
.doc-editable.show-marks h3::after,
.doc-editable.show-marks li::after {
    content: '¶';
    color: var(--muted);
    opacity: 0.6;
    margin-left: 3px;
}

/* Inserir > Quebra de página — marcador não-editável (contenteditable="false"),
   vira <w:br w:type="page"/> de verdade no .docx (ver includes/docx_io.php). */
.doc-page-break {
    border-top: 2px dashed #b8b2da;
    text-align: center;
    color: var(--muted);
    font-size: 0.75rem;
    margin: 20px 0;
    padding-top: 4px;
    cursor: default;
    user-select: none;
}

/* Impressão (botão "Imprimir" da barra): esconde a interface do app e mostra só o texto. */
@media print {
    .topbar, .sheet-menubar, .doc-toolbar, .doc-format-toolbar, .doc-page > .hint {
        display: none !important;
    }
    main.content {
        padding: 0;
    }
    .doc-page-wrap {
        background: none;
        padding: 0;
    }
    .doc-page-break {
        border: none;
        height: 0;
        margin: 0;
        page-break-after: always;
        break-after: page;
    }
    .doc-editable {
        box-shadow: none;
        padding: 0;
        max-width: 100%;
        min-height: 0;
    }
}

/* ------------------------------------------------------------ */
/* Editor de Office online (office_edit.php / office_public.php) */
/* ------------------------------------------------------------ */

.office-page {
    max-width: none;
}

.office-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.office-frame {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    height: 82vh;
    box-shadow: var(--shadow-sm);
}

.office-frame iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ------------------------------------------------------------ */
/* Responsivo                                                    */
/* ------------------------------------------------------------ */

@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
    .search-form { order: 3; max-width: none; flex-basis: 100%; }
    .user-nav { gap: 10px; flex-wrap: wrap; row-gap: 6px; }
    .content { padding: 0 14px 40px; margin: 18px auto; }

    /* Tabelas de listagem (file-table) têm 3 ou 4 colunas dependendo da
       página (index.php, admin.php, shared.php, trash.php, search.php,
       shared_folder.php). A 1ª coluna (nome/item) e a última (Ações)
       são sempre as mais importantes — esconder por posição fixa
       (nth-child) quebrava a coluna Ações em tabelas de 3 colunas, pois
       ali ela cai na 3ª posição. Por isso escondemos tudo que não for
       a primeira nem a última coluna, o que funciona para qualquer
       quantidade de colunas. */
    .file-table th:not(:first-child):not(:last-child),
    .file-table td:not(:first-child):not(:last-child) { display: none; }

    .file-table .actions { justify-content: flex-end; }

    .auth-page { padding: 16px; }
    .auth-box { padding: 28px 22px; }

    .share-list li { flex-wrap: wrap; row-gap: 8px; }
    .share-list input[type="text"] { flex-basis: 100%; }

    .doc-editable { padding: 36px 24px; }
}

@media (max-width: 480px) {
    .topbar { padding: 8px 12px; gap: 8px; }
    .brand { font-size: 1rem; }
    .user-nav { gap: 6px; }
    .user-nav a, .user-name { font-size: 0.8rem; padding: 5px 8px; }
    .content { padding: 0 10px 32px; }
    .toolbar .inline-form { padding: 8px 10px; flex-wrap: wrap; max-width: 100%; }
    .toolbar .inline-form input[type="file"] { max-width: 100%; }
    .rename-input { width: 100px; }
    .sheet-menubar, .doc-toolbar, .sheet-toolbar, .office-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .doc-format-toolbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .auth-box { padding: 24px 16px; }
}
