:root {
    --caern-blue: #005ca8;
    --caern-blue-dark: #003f73;
    --caern-cyan: #00a7d8;
    --caern-green: #009f7a;
    --caern-green-soft: #e6f7f2;
    --bg-page: #f4f9fb;
    --bg-surface: #ffffff;
    --bg-soft: #eaf6fb;
    --text-primary: #0b2942;
    --text-secondary: #526b7f;
    --border: #d7e7ef;
    --shadow-soft: 0 14px 34px rgba(0, 92, 168, 0.08);
    --radius-md: 18px;
    --red: #dc2626;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text-primary);
    background: linear-gradient(180deg, rgba(0, 167, 216, 0.08), transparent 170px), var(--bg-page);
}

.material-icons-round { font-size: inherit; line-height: 1; vertical-align: middle; }

.app-navbar {
    min-height: 58px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(0, 92, 168, 0.14);
    box-shadow: 0 6px 18px rgba(0, 63, 115, 0.06);
}

.appbar-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 54px;
}

.app-brand {
    color: var(--caern-blue-dark) !important;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 850;
    letter-spacing: -0.025em;
    white-space: nowrap;
    margin-right: 0;
}

.app-brand strong { color: var(--caern-blue); }

.brand-icon {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--caern-blue), var(--caern-cyan));
    box-shadow: 0 8px 16px rgba(0, 92, 168, 0.22);
    color: #fff;
    font-size: 20px;
}

.quad-toggle-container {
    display: grid;
    grid-template-columns: repeat(4, minmax(118px, 1fr));
    gap: 4px;
    padding: 4px;
    border: 1px solid rgba(0, 92, 168, 0.14);
    border-radius: 17px;
    background: #eef8fb;
}

.appbar-toggle {
    width: min(860px, 72vw);
    flex: 1 1 auto;
}

.toggle-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: #416174;
    font-size: 0.87rem;
    font-weight: 850;
    transition: 0.2s ease;
    white-space: nowrap;
    padding: 0 10px;
}

.toggle-segment:hover { background: rgba(0, 92, 168, 0.08); color: var(--caern-blue-dark); }

.toggle-segment.active {
    background: linear-gradient(135deg, var(--caern-blue), var(--caern-cyan));
    color: #fff;
    box-shadow: 0 8px 18px rgba(0, 92, 168, 0.18);
}

.toggle-icon {
    width: 25px;
    height: 25px;
    display: inline-grid;
    place-items: center;
    border-radius: 9px;
    font-size: 17px;
}

.icon-planilhas { background: rgba(0, 159, 122, 0.13); color: var(--caern-green); }
.icon-paginas { background: rgba(0, 167, 216, 0.13); color: var(--caern-cyan); }
.icon-ferramentas { background: rgba(0, 92, 168, 0.12); color: var(--caern-blue); }
.icon-documentos { background: rgba(0, 63, 115, 0.12); color: var(--caern-blue-dark); }
.toggle-segment.active .toggle-icon { background: rgba(255, 255, 255, 0.18); color: #fff; }

.search-shell {
    width: min(440px, calc(100vw - 32px));
    min-width: 260px;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1030;
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid rgba(0, 167, 216, 0.35);
    border-radius: 999px;
    box-shadow: 0 16px 38px rgba(0, 63, 115, 0.22);
    transition: width 0.22s ease, min-width 0.22s ease, background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
    overflow: hidden;
}

.search-shell.collapsed {
    width: 54px;
    min-width: 54px;
    height: 54px;
    background: linear-gradient(135deg, var(--caern-blue), var(--caern-cyan));
    border-color: transparent;
    box-shadow: 0 15px 32px rgba(0, 92, 168, 0.28);
}

.search-open-button {
    width: 54px;
    height: 54px;
    min-width: 54px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--caern-blue);
}

.search-shell.collapsed .search-open-button { color: #fff; }
.search-leading-icon { font-size: 24px; }

.search-input {
    width: 100%;
    height: 54px;
    border: 0 !important;
    box-shadow: none !important;
    color: var(--text-primary);
    background: transparent !important;
    padding: 0 48px 0 0;
    opacity: 1;
    transition: opacity 0.18s ease;
    font-size: 0.95rem;
}

.search-shell.collapsed .search-input,
.search-shell.collapsed .btn-clear-search {
    width: 0;
    opacity: 0;
    pointer-events: none;
    padding: 0;
}

.search-input::placeholder { color: #7d95a6; }

.btn-clear-search {
    position: absolute;
    right: 8px;
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border-radius: 50%;
    color: #547084;
    background: #edf7fb;
}

.app-content {
    width: calc(100% - 24px);
    max-width: none;
    margin: 0 auto;
    padding: 20px 0 96px;
}

.content-panel {
    width: 100%;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: clamp(10px, 1.6vw, 22px);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.section-kicker {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.74rem;
    font-weight: 800;
    color: var(--caern-blue);
}

.section-heading h2 {
    margin: 0 0 8px;
    font-size: clamp(1.55rem, 2vw, 2.1rem);
    font-weight: 900;
    letter-spacing: -0.045em;
    color: #06233a;
}

.section-description {
    color: var(--text-secondary);
    max-width: 900px;
    line-height: 1.5;
}

#btn-back-home {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-weight: 750;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
}

.resource-card {
    min-height: 252px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    padding: 22px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(14px);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
    outline: none;
}

.resource-card.show { opacity: 1; transform: translateY(0); }
.resource-card:hover, .resource-card:focus-visible { transform: translateY(-5px); box-shadow: 0 18px 35px rgba(16, 32, 51, 0.11); }
.resource-card:focus-visible { border-color: var(--caern-blue); box-shadow: 0 0 0 4px rgba(0, 92, 168, 0.14), 0 18px 35px rgba(16, 32, 51, 0.11); }

.resource-topline, .resource-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.resource-icon {
    width: 52px;
    height: 52px;
    display: inline-grid;
    place-items: center;
    border-radius: 17px;
    font-size: 30px;
}

.section-planilhas .resource-icon { background: rgba(0, 159, 122, 0.12); color: var(--caern-green); }
.section-paginas .resource-icon { background: rgba(0, 167, 216, 0.12); color: var(--caern-cyan); }
.section-ferramentas .resource-icon { background: rgba(0, 92, 168, 0.11); color: var(--caern-blue); }
.section-documentos .resource-icon { background: rgba(0, 63, 115, 0.11); color: var(--caern-blue-dark); }

.resource-section {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

.resource-card h3 {
    margin: 0;
    font-size: 1.12rem;
    line-height: 1.25;
    font-weight: 850;
    letter-spacing: -0.02em;
}

.resource-card p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.93rem;
    line-height: 1.5;
}

.resource-badge {
    max-width: calc(100% - 42px);
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 11px;
    border-radius: 999px;
    background: #edf7f9;
    color: #224d63;
    font-size: 0.76rem;
    font-weight: 800;
}

.open-icon {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--caern-blue);
    font-size: 20px;
    flex: 0 0 auto;
}

.pdf-card { padding: 0; overflow: hidden; min-height: 304px; }
.pdf-cover {
    min-height: 124px;
    display: grid;
    place-items: center;
    gap: 7px;
    background: linear-gradient(135deg, #fff1f2, #fee2e2);
    color: var(--red);
    font-size: 46px;
}
.pdf-cover small {
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.pdf-body { padding: 20px; display: grid; gap: 12px; }

.empty-state, .skeleton-card {
    grid-column: 1 / -1;
    border: 1px dashed #bdd7e5;
    border-radius: var(--radius-md);
    background: #f7fbfd;
}

.empty-state {
    display: grid;
    place-items: center;
    text-align: center;
    padding: 52px 18px;
    color: var(--text-secondary);
}
.empty-state .material-icons-round { font-size: 54px; color: #94a3b8; margin-bottom: 12px; }
.empty-state h3 { color: var(--text-primary); font-size: 1.2rem; font-weight: 850; margin: 0 0 6px; }
.empty-state p { margin: 0; max-width: 520px; }
.error-state .material-icons-round { color: var(--red); }

.skeleton-card {
    min-height: 250px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
    background-size: 400% 100%;
    animation: shimmer 1.15s ease infinite;
}

@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

@media (min-width: 1600px) {
    .grid-cards { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
}

@media (max-width: 1120px) {
    .appbar-layout { gap: 10px; }
    .appbar-toggle { width: auto; }
    .quad-toggle-container { grid-template-columns: repeat(4, minmax(44px, 1fr)); }
    .toggle-segment span:last-child { display: none; }
    .toggle-segment { min-width: 42px; padding: 0 8px; }
}

@media (max-width: 680px) {
    .app-navbar { padding-left: 10px !important; padding-right: 10px !important; }
    .appbar-layout { gap: 8px; min-height: 50px; }
    .brand-icon { width: 32px; height: 32px; }
    .app-brand span:last-child { font-size: 0.9rem; }
    .quad-toggle-container { border-radius: 15px; padding: 3px; }
    .toggle-segment { min-height: 34px; border-radius: 12px; padding: 0 5px; }
    .toggle-icon { width: 24px; height: 24px; font-size: 16px; }
    .app-content { width: calc(100% - 14px); padding-top: 12px; }
    .section-heading { flex-direction: column; }
    #btn-back-home { width: 100%; justify-content: center; }
    .grid-cards { grid-template-columns: 1fr; }
    .resource-card { min-height: 232px; padding: 19px; }
    .search-shell { right: 14px; bottom: 14px; }
    .search-shell.collapsed { width: 52px; min-width: 52px; height: 52px; }
    .search-open-button { width: 52px; min-width: 52px; height: 52px; }
}

@media (max-width: 430px) {
    .app-brand span:last-child { display: none; }
    .appbar-toggle { width: 100%; }
}
