:root {
    --primary-900: #0e2b24;
    --primary-800: #133b31;
    --primary-700: #1b5344;
    --primary-600: #26735b;
    --primary-500: #2d8a6e;
    --primary-100: #e8f5ec;
    --primary-50:  #f2f8f4;

    --bg-page: #f4f7f5;
    --bg-surface: #ffffff;
    --text-main: #19342d;
    --text-muted: #62776c;
    --text-subtle: #879b90;
    --border-color: #e0eae3;
    --border-focus: #26735b;

    --wa-green: #16834f;
    --wa-green-hover: #126e42;
    --mail-bg: #edf4ef;
    --mail-text: #205f40;
    --mail-hover: #e0ece3;

    --danger: #d32f2f;
    --danger-bg: #fff0ed;
    --danger-border: #f8c9c0;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px rgba(19, 59, 49, 0.06);
    --shadow-md: 0 4px 14px rgba(19, 59, 49, 0.08);
    --shadow-lg: 0 10px 25px rgba(19, 59, 49, 0.12);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-page);
}

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

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* HEADER */
header {
    background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-800) 50%, var(--primary-600) 100%);
    color: #ffffff;
    padding: 34px 20px 38px;
    position: relative;
    box-shadow: 0 4px 20px rgba(14, 43, 36, 0.2);
}

.header-container {
    max-width: 720px;
    margin: 0 auto;
    position: relative;
}

.eyebrow {
    font-size: 11.5px;
    letter-spacing: 0.14em;
    font-weight: 750;
    color: #a7dfc7;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

.eyebrow::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
}

h1 {
    font-size: 30px;
    font-weight: 800;
    line-height: 1.15;
    margin: 10px 0 6px;
    letter-spacing: -0.02em;
}

header p {
    color: #e0f3e9;
    font-size: 15px;
    max-width: 520px;
}

.admin-trigger-btn {
    position: absolute;
    right: 0;
    top: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    padding: 9px 15px;
    font-size: 13.5px;
    font-weight: 650;
    cursor: pointer;
    transition: var(--transition);
}

.admin-trigger-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.45);
    transform: translateY(-1px);
}

/* MAIN CONTENT */
main {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 0 18px 48px;
    flex: 1;
}

/* SEARCH BAR */
.search-wrapper {
    margin: -24px 0 22px;
    position: relative;
    z-index: 2;
}

.search-input-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 18px;
    font-size: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    border: 1.5px solid #d3e4d8;
    background: #ffffff;
    box-shadow: 0 6px 20px rgba(19, 59, 49, 0.08);
    border-radius: var(--radius-lg);
    padding: 16px 44px 16px 48px;
    font-size: 16px;
    color: var(--text-main);
    transition: var(--transition);
    outline: none;
}

.search-input:focus {
    border-color: var(--primary-600);
    box-shadow: 0 8px 24px rgba(38, 115, 91, 0.16);
}

.search-clear-btn {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    display: none;
    border-radius: 50%;
}

.search-clear-btn:hover {
    color: var(--text-main);
}

.search-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 4px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* SETORES LIST / DETAILS ACCORDION */
.sectors-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

details.sector-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

details.sector-card:hover {
    border-color: #cbdcd1;
    box-shadow: var(--shadow-md);
}

details.sector-card[open] {
    border-color: #b8d4c3;
    box-shadow: 0 4px 16px rgba(19, 59, 49, 0.08);
}

summary.sector-header {
    padding: 16px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    list-style: none;
    user-select: none;
}

summary.sector-header::-webkit-details-marker {
    display: none;
}

.sector-icon {
    background: var(--primary-100);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    font-size: 22px;
    flex: none;
    transition: var(--transition);
}

details.sector-card[open] .sector-icon {
    background: var(--primary-500);
    color: #fff;
    transform: scale(1.04);
}

.sector-meta {
    flex: 1;
    min-width: 0;
}

.sector-title {
    font-weight: 750;
    font-size: 16px;
    color: var(--text-main);
    line-height: 1.25;
}

.sector-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 3px;
    line-height: 1.35;
}

.sector-chev {
    margin-left: auto;
    color: var(--primary-600);
    font-size: 18px;
    font-weight: bold;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

details.sector-card[open] .sector-chev {
    transform: rotate(180deg);
}

/* CONTACTS INSIDE SECTOR */
.contacts-wrapper {
    padding: 4px 18px 16px;
    background: #fbfdfc;
    border-top: 1px solid #edf3ef;
}

.contact-item {
    border-top: 1px solid #ebf2ed;
    padding: 14px 0 6px;
}

.contact-item:first-child {
    border-top: none;
    padding-top: 10px;
}

.contact-name {
    font-weight: 750;
    font-size: 15.5px;
    color: var(--text-main);
}

.contact-role {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
    white-space: pre-line;
}

.contact-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 11px 0 4px;
}

.action-btn {
    text-decoration: none;
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    font-weight: 650;
    font-size: 13px;
    display: inline-flex;
    gap: 7px;
    align-items: center;
    transition: var(--transition);
}

.action-btn.wa {
    background: var(--wa-green);
    color: #ffffff;
}

.action-btn.wa:hover {
    background: var(--wa-green-hover);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(22, 131, 79, 0.25);
}

.action-btn.mail {
    background: var(--mail-bg);
    color: var(--mail-text);
    overflow-wrap: anywhere;
}

.action-btn.mail:hover {
    background: var(--mail-hover);
    color: var(--primary-900);
    transform: translateY(-1px);
}

/* EMPTY STATE */
.empty-state {
    display: none;
    text-align: center;
    padding: 40px 20px;
    background: #ffffff;
    border: 1px dashed #cbded1;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    margin: 16px 0;
}

.empty-state-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

/* TIPS & FOOTER */
.tips-banner {
    margin-top: 24px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: #e7f2eb;
    border-left: 4px solid var(--primary-600);
    font-size: 13px;
    line-height: 1.55;
    color: #2b5443;
}

.tips-banner b {
    color: var(--primary-900);
}

.footer-section {
    margin: 30px 0 10px;
    text-align: center;
    color: var(--text-subtle);
    font-size: 12px;
    line-height: 1.6;
}

/* MODAL & ADMIN STYLES */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 36, 27, 0.78);
    backdrop-filter: blur(4px);
    z-index: 100;
    overflow-y: auto;
    padding: 20px 14px;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-container {
    max-width: 800px;
    background: #ffffff;
    margin: 20px auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
    padding: 24px 26px;
    color: var(--text-main);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 18px;
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary-900);
    margin-bottom: 4px;
}

.modal-header p {
    color: var(--text-muted);
    font-size: 13.5px;
}

.btn-close {
    background: #eef4f0;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: var(--transition);
}

.btn-close:hover {
    background: #e2ede6;
    color: var(--text-main);
}

/* ADMIN AUTH BOX */
.auth-box {
    max-width: 420px;
    margin: 30px auto;
    text-align: center;
    padding: 24px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fbfdfc;
}

.auth-box h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--primary-800);
}

.auth-box p {
    font-size: 13.5px;
    color: var(--text-muted);
    margin-bottom: 18px;
}

/* BUTTONS */
.btn {
    border: 0;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 650;
    font-size: 13.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn.primary {
    background: var(--primary-700);
    color: #ffffff;
}

.btn.primary:hover {
    background: var(--primary-800);
    transform: translateY(-1px);
}

.btn.light {
    background: var(--primary-50);
    color: var(--primary-800);
    border: 1px solid #cfe0d5;
}

.btn.light:hover {
    background: #e4efe7;
}

.btn.danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.btn.danger:hover {
    background: #feded8;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin: 16px 0;
}

/* ADMIN PANEL CONTROLS */
.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: #f4f8f5;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

/* FORMS & INPUTS */
.admin-form-card {
    background: #f8faf8;
    border: 1.5px solid #d2e4d7;
    border-radius: var(--radius-md);
    padding: 20px;
    margin: 16px 0 24px;
    animation: fadeIn 0.25s ease-out;
}

.form-title {
    font-size: 16px;
    font-weight: 750;
    color: var(--primary-900);
    margin-bottom: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-field.full-width {
    grid-column: 1 / -1;
}

.form-field label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    border: 1px solid #cadcd0;
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-main);
    font-family: inherit;
    transition: var(--transition);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--primary-600);
    box-shadow: 0 0 0 3px rgba(38, 115, 91, 0.15);
}

/* ADMIN ITEMS ACCORDION & LIST */
.admin-sector-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    background: #ffffff;
    overflow: hidden;
}

.admin-sector-header {
    background: #f3f7f4;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.admin-sector-title {
    font-size: 15px;
    font-weight: 750;
    color: var(--primary-900);
}

.admin-contact-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 16px;
    border-bottom: 1px solid #eef3ef;
    gap: 12px;
}

.admin-contact-row:last-child {
    border-bottom: none;
}

.admin-contact-info {
    font-size: 13.5px;
}

.admin-contact-info b {
    color: var(--text-main);
}

.admin-contact-info span {
    color: var(--text-muted);
}

/* TOAST NOTIFICATIONS */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    background: #19342d;
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideUp 0.25s ease-out;
    pointer-events: auto;
}

.toast.success {
    background: #14533b;
    border-left: 4px solid #4ade80;
}

.toast.error {
    background: #6d1b1b;
    border-left: 4px solid #f87171;
}

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

/* DATABASE SETUP NOTICE */
.db-alert-card {
    background: #fff8e6;
    border: 1px solid #f2d28b;
    border-left: 5px solid #d97706;
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin: 20px 0;
    color: #78350f;
}

.db-alert-card h3 {
    font-size: 16px;
    font-weight: 750;
    margin-bottom: 6px;
}

.db-alert-card p {
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.db-alert-card code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

/* RESPONSIVE DESIGN */
@media (max-width: 640px) {
    header {
        padding: 26px 16px 32px;
    }

    h1 {
        font-size: 24px;
    }

    .admin-trigger-btn {
        position: static;
        margin-top: 14px;
        display: inline-flex;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .modal-container {
        padding: 18px 16px;
        margin: 10px auto;
    }

    .admin-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-contact-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .admin-contact-row .btn-row {
        margin: 0;
        width: 100%;
        justify-content: flex-end;
    }
}
