:root {
    --bg: #f7f5ef;
    --surface: #ffffff;
    --surface-soft: #fbfaf7;
    --text: #1f2a2e;
    --muted: #667579;
    --primary: #176b73;
    --primary-dark: #0f5157;
    --primary-soft: #e7f2f2;
    --accent: #c8a35a;
    --border: #e3ded3;
    --success: #177c54;
    --danger: #b93b3b;
    --warning: #9a6818;
    --shadow: 0 14px 38px rgba(31, 42, 46, 0.08);
    --radius-lg: 24px;
    --radius-md: 16px;
    --bottom-nav-height: 76px;
}

* { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(23, 107, 115, 0.03) 1px, transparent 1px),
        linear-gradient(rgba(23, 107, 115, 0.026) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, #000 0%, transparent 80%);
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a,
select {
    -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.auth-page {
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.auth-card {
    width: min(470px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: clamp(24px, 5vw, 36px);
}

.brand-badge,
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-dark);
    background: var(--primary-soft);
    border: 1px solid #cfe4e4;
    border-radius: 999px;
    padding: 7px 12px;
    font-weight: 850;
    font-size: 13px;
}

.brand-badge::before,
.eyebrow::before {
    content: "";
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--accent);
}

h1, h2, h3 { margin: 12px 0; line-height: 1.12; }
h1 { font-size: clamp(28px, 8vw, 46px); letter-spacing: -1px; }
h2 { font-size: clamp(22px, 6vw, 34px); letter-spacing: -0.6px; }
h3 { font-size: 19px; }
p { color: var(--muted); line-height: 1.65; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(247, 245, 239, 0.94);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(226, 221, 211, 0.92);
}

.header-inner {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: max-content;
    font-size: 21px;
    font-weight: 900;
    color: var(--primary-dark);
    letter-spacing: -0.4px;
}

.logo::before {
    content: "✦";
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 11px;
    color: var(--surface);
    background: var(--primary);
    font-size: 15px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
}

.nav a {
    color: var(--muted);
    font-weight: 850;
    padding: 10px 13px;
    border-radius: 12px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav a:hover,
.nav a.active,
.nav .nav-cta {
    background: var(--primary);
    color: #fff;
}

.hero-panel,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.hero-panel {
    margin: 34px 0 22px;
    padding: clamp(24px, 5vw, 46px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: relative;
    overflow: hidden;
}

.hero-panel::after,
.appointment-request-panel::after {
    content: "";
    position: absolute;
    width: 190px;
    height: 190px;
    right: -70px;
    top: -70px;
    border: 28px solid rgba(23, 107, 115, 0.065);
    border-radius: 50%;
}

.hero-panel > *,
.panel > * { position: relative; z-index: 1; }

.panel {
    padding: clamp(22px, 4vw, 34px);
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
}

.page-grid { padding-top: 34px; }

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.form-stack,
.form-grid {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-width, .form-actions { grid-column: 1 / -1; }

label {
    display: block;
    color: var(--text);
    font-weight: 850;
    margin-bottom: 8px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    background-color: var(--surface-soft);
    border-radius: 14px;
    min-height: 52px;
    padding: 13px 14px;
    color: var(--text);
    outline: none;
    font-size: 16px;
}

select {
    appearance: none;
    padding-right: 44px;
    background-image: linear-gradient(45deg, transparent 50%, var(--primary) 50%), linear-gradient(135deg, var(--primary) 50%, transparent 50%);
    background-position: calc(100% - 20px) 23px, calc(100% - 14px) 23px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

textarea {
    min-height: 118px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(23, 107, 115, 0.13);
    background-color: #fff;
}

input:disabled {
    opacity: 1;
    color: var(--muted);
}

.date-input-wrap { position: relative; }
.date-input-wrap input { padding-right: 56px; }

.field-icon-button {
    position: absolute;
    right: 7px;
    top: 7px;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.field-help {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 13px 18px;
    font-weight: 900;
    cursor: pointer;
    transition: 0.18s ease;
    text-align: center;
    user-select: none;
}

.btn-primary {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 10px 22px rgba(23, 107, 115, 0.16);
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.99); }

.btn-secondary {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-color: #cfe4e4;
}

.alert {
    border-radius: 14px;
    padding: 13px 15px;
    margin: 16px 0;
    font-weight: 750;
    line-height: 1.45;
}

.alert-error { background: #fff0ee; color: var(--danger); border: 1px solid #f0cbc5; }
.alert-success { background: #edf8f2; color: var(--success); border: 1px solid #c6ead6; }

.appointment-list { display: grid; gap: 14px; }

.appointment-card {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 18px;
}

.appointment-card strong { font-size: 18px; }
.appointment-card p { margin: 6px 0; }
.appointment-card small { color: var(--muted); line-height: 1.45; display: block; }

.status {
    white-space: nowrap;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 900;
    background: #eef0ef;
    color: var(--muted);
}

.status-pending { background: #fff6e4; color: var(--warning); }
.status-active { background: var(--primary-soft); color: var(--primary-dark); }
.status-cancelled,
.status-rejected { background: #fff0ee; color: var(--danger); }
.status-completed { background: #edf8f2; color: var(--success); }

.empty-state {
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 22px;
    padding: 34px;
    background: var(--surface-soft);
}

.muted { color: var(--muted); }

@media (max-width: 900px) {
    .container { width: min(100% - 28px, 760px); }

    .header-inner {
        min-height: 68px;
    }

    .logo { font-size: 20px; }

    .nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        max-width: 62vw;
        scrollbar-width: none;
    }

    .nav::-webkit-scrollbar { display: none; }
    .nav a { white-space: nowrap; }
}

@media (max-width: 760px) {
    body:not(.auth-page) {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px);
    }

    .container { width: calc(100% - 24px); }

    .site-header {
        position: sticky;
        top: 0;
    }

    .header-inner {
        min-height: 64px;
        justify-content: center;
    }

    .logo::before {
        width: 32px;
        height: 32px;
        border-radius: 10px;
    }

    .site-header .nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        max-width: none;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
        border-radius: 0;
        background: rgba(247, 245, 239, 0.96);
        border-top: 1px solid rgba(226, 221, 211, 0.92);
        box-shadow: none;
        overflow: visible;
        backdrop-filter: blur(14px);
    }

    .nav a {
        min-height: 48px;
        padding: 7px 6px;
        border-radius: 12px;
        font-size: 12px;
        line-height: 1.15;
        white-space: normal;
        text-align: center;
    }

    .nav a[href="logout.php"] { color: var(--danger); }
    .nav a[href="logout.php"].active,
    .nav a[href="logout.php"]:hover { background: #fff0ee; color: var(--danger); }

    .hero-panel {
        margin: 18px 0 16px;
        padding: 24px;
        display: grid;
        gap: 16px;
    }

    .hero-panel .btn,
    .form-actions .btn,
    .empty-state .btn {
        width: 100%;
    }

    .hero-panel::after,
    .appointment-request-panel::after {
        width: 150px;
        height: 150px;
        right: -72px;
        top: -72px;
        border-width: 22px;
    }

    .page-grid { padding-top: 18px; }

    .panel {
        padding: 22px;
        margin-bottom: 18px;
        border-radius: 22px;
    }

    .section-title,
    .appointment-card {
        align-items: stretch;
        flex-direction: column;
    }

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

    .appointment-card {
        padding: 16px;
        gap: 12px;
    }

    .appointment-card strong { font-size: 17px; }

    .status {
        width: fit-content;
        max-width: 100%;
    }

    .empty-state {
        padding: 28px 18px;
    }
}

@media (max-width: 430px) {
    .container { width: calc(100% - 18px); }

    .auth-page { padding-left: 12px; padding-right: 12px; }

    .auth-card {
        border-radius: 22px;
        padding: 22px;
    }

    .brand-badge,
    .eyebrow {
        font-size: 12px;
        padding: 6px 10px;
    }

    h1 { font-size: clamp(27px, 9vw, 34px); }
    h2 { font-size: clamp(22px, 7vw, 28px); }
    p { line-height: 1.58; }

    .panel,
    .hero-panel {
        padding: 20px;
        border-radius: 20px;
    }

    input,
    select,
    textarea,
    .btn {
        border-radius: 13px;
    }

    .site-header .nav {
        left: 0;
        right: 0;
        border-radius: 0;
        padding-left: 6px;
        padding-right: 6px;
    }

    .nav a {
        font-size: 11.5px;
        min-height: 50px;
        padding-left: 4px;
        padding-right: 4px;
    }
}
