:root {
    --primary: #173b32;
    --primary-2: #245247;
    --primary-soft: #edf4f1;
    --accent: #c5a47e;
    --accent-soft: #f6efe7;
    --bg: #f4f7f5;
    --white: #ffffff;
    --text-main: #25352f;
    --text-light: #718078;
    --success: #198754;
    --danger: #b33a3a;
    --danger-soft: #fff0f0;
    --border: #dfe8e3;
    --shadow: 0 22px 70px rgba(20, 56, 46, .10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    min-height: 100vh;
    padding-top: 76px;
    background: radial-gradient(circle at top right, #eef5f1 0, transparent 34%), var(--bg);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    line-height: 1.55;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    min-height: 76px;
    padding: 13px 6%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid rgba(23,59,50,.08);
    backdrop-filter: blur(16px);
    z-index: 1000;
}
.brand { color: var(--primary); text-decoration: none; font: 700 1.42rem 'Playfair Display', serif; letter-spacing: .01em; }
.brand span { color: var(--accent); font-weight: 400; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.back-link { color: var(--text-main); text-decoration: none; font-size: .88rem; font-weight: 700; }
.btn-lock, .btn-top-logout {
    border-radius: 999px;
    padding: 9px 16px;
    font-size: .8rem;
    font-weight: 800;
    transition: .2s ease;
}
.btn-lock { border: 1px solid var(--accent); color: #8c6946; background: transparent; }
.btn-lock:hover { background: var(--accent); color: #fff; }
.btn-top-logout { border: 1px solid #efc8c8; color: var(--danger); background: #fff7f7; }
.btn-top-logout:hover { background: #ffe8e8; }

.hero-banner {
    min-height: 300px;
    padding: 55px 6% 95px;
    display: grid;
    place-items: center;
    text-align: center;
    background: linear-gradient(rgba(19,55,46,.90), rgba(25,66,56,.76)), url('imagens/capa.jpeg') center/cover;
}
.hero-content { max-width: 760px; }
.hero-kicker, .eyebrow { display: inline-block; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero-banner h1 { margin-top: 8px; color: white; font: 700 clamp(2.2rem, 5vw, 3.3rem) 'Playfair Display', serif; }
.hero-banner p { max-width: 680px; margin: 9px auto 0; color: rgba(255,255,255,.82); }

.main-card {
    position: relative;
    z-index: 10;
    width: min(1160px, calc(100% - 28px));
    margin: -68px auto 54px;
    padding: clamp(24px, 4.5vw, 48px);
    border: 1px solid rgba(23,59,50,.05);
    border-radius: 28px;
    background: var(--white);
    box-shadow: var(--shadow);
}
.section-intro, .admin-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.heading { color: var(--primary); font: 700 clamp(1.75rem, 4vw, 2.3rem) 'Playfair Display', serif; }
.subheading { max-width: 720px; margin-top: 5px; color: var(--text-light); }
.secure-badge { flex: 0 0 auto; padding: 8px 12px; border-radius: 999px; background: #edf8f2; color: #23744d; font-size: .75rem; font-weight: 800; }

.form-section { margin-top: 27px; padding-top: 24px; border-top: 1px solid var(--border); }
.form-section:first-of-type { border-top: 0; }
.form-section-title { display: flex; align-items: center; gap: 12px; margin-bottom: 17px; }
.form-section-title strong { display: block; color: var(--primary); font-size: 1rem; }
.form-section-title small { display: block; margin-top: 1px; color: var(--text-light); font-size: .78rem; }
.step-number { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--primary); color: white; font-size: .8rem; font-weight: 800; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field.full { grid-column: 1 / -1; }
.field label, .date-manual-row label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-light);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}
input, select, textarea {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fbfdfc;
    color: var(--text-main);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(197,164,126,.13); background: #fff; }
textarea { min-height: 98px; resize: vertical; }
.field-help { margin-top: 7px; color: var(--text-light); font-size: .76rem; }

.modality-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.modality-card {
    display: flex; align-items: center; gap: 11px;
    padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: white; color: var(--text-main); text-align: left;
    transition: .2s ease;
}
.modality-card:hover { border-color: #c9d7d0; transform: translateY(-1px); }
.modality-card.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.modality-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--primary); color: white; font-weight: 800; }
.modality-card strong, .modality-card small { display: block; }
.modality-card strong { color: var(--primary); font-size: .88rem; }
.modality-card small { margin-top: 2px; color: var(--text-light); font-size: .72rem; }

.availability-box { padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: linear-gradient(180deg, #fbfdfc, #f7faf8); }
.availability-head, .time-area-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.availability-head strong, .time-area-head strong { display: block; color: var(--primary); font-size: .94rem; }
.availability-label { display: block; margin-bottom: 2px; color: var(--text-light); font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.btn-text { border: 0; background: transparent; color: #8c6946; font-size: .78rem; font-weight: 800; }
.btn-text:hover { text-decoration: underline; }
.date-strip { display: grid; grid-template-columns: repeat(5, minmax(108px,1fr)); gap: 9px; margin-top: 14px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.date-card {
    min-width: 108px; padding: 12px 10px; border: 1px solid var(--border); border-radius: 14px; background: white; color: var(--text-main); text-align: left; transition: .18s ease;
}
.date-card:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.date-card.active { border-color: var(--primary); background: var(--primary); color: white; box-shadow: 0 9px 20px rgba(23,59,50,.16); }
.date-card:disabled { opacity: .48; cursor: not-allowed; }
.date-card .day-name { display: block; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.date-card .day-date { display: block; margin-top: 2px; font-size: 1.08rem; font-weight: 800; }
.date-card .day-slots { display: block; margin-top: 5px; font-size: .68rem; opacity: .78; }
.date-manual-row { display: grid; grid-template-columns: 180px minmax(180px, 280px); align-items: end; gap: 14px; margin-top: 13px; }
.date-manual-row label { margin: 0 0 12px; }
.time-area { margin-top: 18px; padding-top: 17px; border-top: 1px dashed #d7e2dc; }
.availability-count { padding: 5px 9px; border-radius: 999px; background: var(--accent-soft); color: #896744; font-size: .7rem; font-weight: 800; }
.time-slots { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; min-height: 44px; }
.time-slot {
    min-width: 80px; padding: 10px 13px; border: 1px solid #cfdcd5; border-radius: 11px; background: white; color: var(--primary); font-weight: 800; transition: .18s ease;
}
.time-slot:hover { border-color: var(--primary); background: var(--primary-soft); }
.time-slot.active { border-color: var(--primary); background: var(--primary); color: white; box-shadow: 0 7px 16px rgba(23,59,50,.16); }
.availability-empty, .availability-loading { width: 100%; padding: 14px; border-radius: 12px; background: #f1f5f3; color: var(--text-light); font-size: .82rem; text-align: center; }
.availability-loading { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:.65; } 50% { opacity:1; } }

.termos-box { margin-top: 22px; padding: 16px; border: 1px solid #ead9c4; border-radius: 14px; background: #fffaf4; }
.termos-box label { display: flex; align-items: flex-start; gap: 10px; color: #7e5f40; font-size: .82rem; cursor: pointer; }
.termos-box input { width: auto; margin-top: 3px; accent-color: var(--primary); }
.btn-primary { width: 100%; margin-top: 20px; padding: 16px 20px; border: 0; border-radius: 14px; background: var(--primary); color: white; box-shadow: 0 11px 25px rgba(23,59,50,.19); font-weight: 800; transition: .2s ease; }
.btn-primary:hover { transform: translateY(-1px); background: var(--primary-2); }
.btn-primary:disabled { opacity: .6; transform: none; }
.btn-whatsapp { background: #20975a; }
.btn-whatsapp:hover { background: #197d4a; }

.modal { display: none; position: fixed; inset: 0; z-index: 2000; align-items: center; justify-content: center; padding: 18px; background: rgba(14,34,28,.9); }
.modal.open { display: flex; }
.modal-content { width: min(410px, 100%); padding: 31px; border-radius: 22px; background: white; box-shadow: 0 30px 80px rgba(0,0,0,.28); text-align: center; }
.modal-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 13px; border-radius: 15px; background: var(--primary); color: white; font: 700 .9rem 'Playfair Display', serif; }
.modal-content h2 { color: var(--primary); font: 700 1.7rem 'Playfair Display', serif; }
.modal-content p { margin: 6px 0 16px; color: var(--text-light); font-size: .86rem; }
.modal-error { min-height: 21px; margin-top: 7px; color: var(--danger); font-size: .8rem; }
.btn-link { margin-top: 11px; border: 0; background: transparent; color: var(--text-light); font-weight: 700; }

#adminDashboard { display: none; }
.admin-hero { padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.admin-header-actions, .admin-actions, .schedule-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-util, .btn-danger-soft, .btn-save-schedule, .btn-small {
    padding: 9px 12px; border-radius: 10px; font-size: .78rem; font-weight: 800; transition: .18s ease;
}
.btn-util, .btn-small { border: 1px solid var(--border); background: white; color: var(--text-main); }
.btn-util:hover, .btn-small:hover { border-color: var(--accent); }
.btn-danger-soft { border: 1px solid #f0c5c5; background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: #ffe3e3; }
.btn-save-schedule { border: 1px solid var(--primary); background: var(--primary); color: white; }
.btn-save-schedule:hover { background: var(--primary-2); }

.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin: 22px 0; }
.card-stat { padding: 17px; border: 1px solid var(--border); border-radius: 16px; background: linear-gradient(180deg,#fff,#f8fbf9); }
.stat-label { display: block; color: var(--text-light); font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.card-stat strong { display: block; margin: 2px 0; color: var(--primary); font: 700 2rem 'Playfair Display', serif; }
.card-stat small { color: var(--text-light); font-size: .7rem; }

.admin-tabs { display: flex; gap: 7px; margin-bottom: 16px; padding: 5px; border: 1px solid var(--border); border-radius: 13px; background: #f5f8f6; width: fit-content; }
.admin-tab { padding: 9px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--text-light); font-size: .78rem; font-weight: 800; }
.admin-tab.active { background: white; color: var(--primary); box-shadow: 0 3px 12px rgba(23,59,50,.08); }
.admin-view { display: none; }
.admin-view.active { display: block; }
.panel-card { padding: 20px; border: 1px solid var(--border); border-radius: 18px; background: #fff; }
.panel-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.panel-card-head h3 { color: var(--primary); font: 700 1.24rem 'Playfair Display', serif; }
.panel-card-head p { margin-top: 2px; color: var(--text-light); font-size: .8rem; }
.admin-toolbar { display: grid; grid-template-columns: minmax(220px,1fr) 170px auto; gap: 9px; margin-bottom: 14px; }
.admin-toolbar input, .admin-toolbar select { padding: 10px 11px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 13px; }
table { width: 100%; min-width: 900px; border-collapse: collapse; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--border); vertical-align: top; text-align: left; font-size: .82rem; }
th { background: #f5f8f6; color: var(--text-light); font-size: .68rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.patient-name { color: var(--primary); font-weight: 800; }
.patient-details { color: var(--text-light); font-size: .73rem; }
.patient-objective { max-width: 260px; color: var(--text-light); white-space: normal; }
.appointment-cell { color: var(--primary); font-weight: 700; white-space: nowrap; }
.status-select { min-width: 125px; padding: 7px; font-size: .76rem; }
.action-link { display: inline-block; padding: 7px 9px; border-radius: 8px; background: #e9f8ef; color: #167942; text-decoration: none; font-size: .74rem; font-weight: 800; }
.empty-state { padding: 24px; color: var(--text-light); text-align: center; }
.row-cancelled { opacity: .56; }
.row-cancelled .appointment-cell { text-decoration: line-through; }
.appointment-cards { display: none; }

.schedule-panel { padding: 20px; }
.schedule-head { margin-bottom: 10px; }
.schedule-summary { margin: 13px 0 15px; padding: 10px 12px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); font-size: .78rem; font-weight: 700; }
.schedule-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.schedule-day { padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: #fbfdfc; box-shadow: 0 5px 16px rgba(20,65,53,.035); }
.schedule-day.closed { background: #f6f7f6; opacity: .82; }
.schedule-day-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.schedule-day-title strong { display: block; color: var(--primary); font-size: .9rem; }
.schedule-day-title small { display: block; color: var(--text-light); font-size: .68rem; }
.day-toggle { padding: 6px 10px; border: 1px solid #bdd8ca; border-radius: 999px; background: #ecf7f1; color: #246846; font-size: .68rem; font-weight: 800; }
.schedule-day.closed .day-toggle { border-color: #dfcaca; background: #fff0f0; color: #9b4a4a; }
.schedule-chips { display: flex; flex-wrap: wrap; gap: 7px; min-height: 34px; }
.schedule-chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid #d5e1db; border-radius: 999px; background: white; color: var(--primary); font-size: .73rem; font-weight: 800; }
.schedule-chip button { width: 17px; height: 17px; border: 0; border-radius: 50%; background: #eef2f0; color: #6f7e77; font-size: .7rem; line-height: 1; }
.schedule-add { display: flex; gap: 7px; margin-top: 11px; }
.schedule-add input { padding: 8px 9px; }
.schedule-add button { flex: 0 0 auto; padding: 8px 11px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent-soft); color: #846344; font-size: .72rem; font-weight: 800; }
.schedule-closed-message { padding: 9px; border-radius: 9px; background: #f1f3f2; color: var(--text-light); font-size: .72rem; text-align: center; }


.btn-reserve { width: 100%; margin-top: 4px; background: linear-gradient(135deg,var(--primary),#285f50); box-shadow: 0 14px 28px rgba(18,67,55,.18); }
.booking-success { margin-top: 14px; display: flex; align-items: flex-start; gap: 13px; padding: 16px; border: 1px solid #b9dec9; border-radius: 15px; background: #effaf4; color: #205e43; }
.booking-success[hidden] { display: none !important; }
.booking-success-icon { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #218b58; color: #fff; font-size: 1rem; font-weight: 900; }
.booking-success strong { display: block; margin: 1px 0 4px; font-size: .9rem; }
.booking-success p { margin: 0 0 3px; font-size: .78rem; font-weight: 650; }
.booking-success small { display: block; color: #527465; font-size: .7rem; line-height: 1.45; }

.schedule-builder { margin: 14px 0; padding: 18px; border: 1px solid #d9e6e0; border-radius: 17px; background: linear-gradient(180deg,#fbfdfc,#f5faf7); }
.schedule-builder-copy h4 { margin: 3px 0 4px; color: var(--primary); font-size: 1rem; }
.schedule-builder-copy p { margin: 0; color: var(--text-light); font-size: .75rem; line-height: 1.45; }
.builder-kicker { color: #9a724b; font-size: .62rem; font-weight: 900; letter-spacing: .12em; }
.builder-days { display: flex; flex-wrap: wrap; gap: 7px; margin: 15px 0 9px; }
.builder-day { min-width: 48px; padding: 9px 12px; border: 1px solid #d5e1db; border-radius: 11px; background: white; color: #64766e; font-size: .72rem; font-weight: 850; transition: .18s ease; }
.builder-day.active { border-color: #1f7053; background: #e9f6ef; color: #175940; box-shadow: inset 0 0 0 1px #1f7053; }
.builder-shortcuts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 13px; }
.btn-mini { padding: 6px 9px; border: 1px solid #c9d9d1; border-radius: 999px; background: #fff; color: #315f50; font-size: .66rem; font-weight: 800; }
.btn-mini.ghost { color: #7e746c; border-style: dashed; }
.builder-controls { display: grid; grid-template-columns: 1fr 1fr 1fr minmax(160px,auto); gap: 9px; align-items: end; }
.builder-controls label { display: grid; gap: 5px; color: #5e7169; font-size: .65rem; font-weight: 800; }
.builder-controls input, .builder-controls select { width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #d8e2dd; border-radius: 10px; background: #fff; color: var(--primary); font: inherit; }
.btn-add-range { min-height: 42px; padding: 9px 14px; border: 0; border-radius: 10px; background: var(--primary); color: white; font-size: .74rem; font-weight: 850; }
.builder-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 11px; padding-top: 11px; border-top: 1px dashed #d6e1dc; }
.builder-presets > span { color: var(--text-light); font-size: .67rem; font-weight: 800; }
.preset-range { padding: 7px 10px; border: 1px solid #ead7c2; border-radius: 999px; background: #fff8f0; color: #825f3e; font-size: .67rem; font-weight: 850; }

.toast { visibility: hidden; opacity: 0; position: fixed; left: 50%; bottom: 24px; z-index: 3000; max-width: min(460px,calc(100% - 28px)); padding: 12px 18px; border-radius: 999px; background: #233b34; color: white; transform: translate(-50%,12px); text-align: center; font-size: .82rem; font-weight: 800; transition: .24s ease; box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.toast.show { visibility: visible; opacity: 1; transform: translate(-50%,0); }
.toast.error { background: #9b3434; }
.toast.success { background: #1e8754; }
footer { padding: 20px 20px 35px; color: var(--text-light); text-align: center; font-size: .75rem; }

@media (max-width: 900px) {
    .date-strip { grid-template-columns: repeat(5, 108px); }
    .stats { grid-template-columns: 1fr 1fr; }
    .admin-toolbar { grid-template-columns: 1fr; }
    .schedule-grid { grid-template-columns: 1fr; }
    .schedule-actions { justify-content: flex-start; }
}

@media (max-width: 680px) {
    body { padding-top: 68px; }
    .topbar { min-height: 68px; padding: 11px 17px; }
    .brand { font-size: 1.08rem; }
    .back-link { display: none; }
    .btn-lock, .btn-top-logout { padding: 8px 11px; font-size: .7rem; }
    .hero-banner { min-height: 240px; padding: 42px 18px 72px; }
    .hero-banner h1 { font-size: 2rem; }
    .main-card { width: min(100% - 18px, 1160px); margin-top: -48px; padding: 20px 16px 24px; border-radius: 20px; }
    .section-intro, .admin-hero, .panel-card-head, .schedule-head { flex-direction: column; }
    .secure-badge { align-self: flex-start; }
    .grid, .modality-picker { grid-template-columns: 1fr; }
    .field.full { grid-column: auto; }
    .availability-box { padding: 14px; }
    .date-manual-row { grid-template-columns: 1fr; gap: 4px; }
    .date-manual-row label { margin-bottom: 4px; }
    .stats { gap: 8px; }
    .card-stat { padding: 13px; }
    .card-stat strong { font-size: 1.65rem; }
    .admin-tabs { width: 100%; }
    .admin-tab { flex: 1; }
    .panel-card { padding: 14px; }
    .table-wrap { display: none; }
    .appointment-cards { display: grid; gap: 10px; }
    .appointment-card { padding: 13px; border: 1px solid var(--border); border-radius: 13px; background: #fbfdfc; }
    .appointment-card.cancelled { opacity: .62; }
    .appointment-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
    .appointment-card h4 { color: var(--primary); font-size: .88rem; }
    .appointment-card .meta { margin-top: 4px; color: var(--text-light); font-size: .72rem; }
    .appointment-card .objective { margin: 10px 0; color: var(--text-light); font-size: .76rem; }
    .appointment-card-actions { display: grid; grid-template-columns: 1fr auto; gap: 7px; align-items: center; }
    .appointment-card-actions select { padding: 8px; font-size: .74rem; }
    .appointment-card-actions .action-link { text-align: center; padding: 9px; }
    .schedule-actions, .admin-header-actions { width: 100%; }
    .schedule-actions > *, .admin-header-actions > * { flex: 1 1 auto; }
    .schedule-add { display: grid; grid-template-columns: 1fr auto; }
    .builder-controls { grid-template-columns: 1fr 1fr; }
    .builder-controls label:nth-child(3) { grid-column: 1 / 2; }
    .btn-add-range { grid-column: 2 / 3; }
    .builder-days { display: grid; grid-template-columns: repeat(4,1fr); }
    .builder-day { min-width: 0; width: 100%; }
}
