:root {
    --bg: #f4efe7;
    --bg-soft: #fbf8f3;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-strong: #ffffff;
    --surface-soft: rgba(246, 239, 228, 0.88);
    --line: rgba(87, 63, 45, 0.14);
    --line-strong: rgba(87, 63, 45, 0.24);
    --text: #2d241e;
    --text-soft: #66584d;
    --primary: #8a4b2a;
    --primary-dark: #6e3a1d;
    --secondary: #2d6a5f;
    --success: #246b4f;
    --success-bg: #e7f6ee;
    --error: #9a2d2d;
    --error-bg: #fdecec;
    --shadow: 0 18px 50px rgba(91, 67, 50, 0.12);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body.app-body {
    margin: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(138, 75, 42, 0.14), transparent 30%),
        radial-gradient(circle at top right, rgba(45, 106, 95, 0.14), transparent 24%),
        linear-gradient(180deg, #fcfaf6 0%, var(--bg) 100%);
}

.app-background {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(138, 75, 42, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(138, 75, 42, 0.035) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.08));
}

.app-shell {
    position: relative;
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px;
    margin-bottom: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(255, 251, 246, 0.9);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.topbar__brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.topbar__brand strong {
    font-size: 1.1rem;
    letter-spacing: 0.04em;
}

.topbar__eyebrow,
.eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary);
}

.topbar__nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar__nav a,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: rgba(138, 75, 42, 0.09);
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.topbar__nav a:hover,
.button-link:hover {
    transform: translateY(-1px);
    background: rgba(138, 75, 42, 0.15);
    border-color: rgba(138, 75, 42, 0.16);
}

.topbar__logout {
    background: rgba(45, 106, 95, 0.1);
}

.page-heading,
.hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

h1,
h2,
h3,
legend {
    margin: 0 0 10px;
    color: var(--text);
    line-height: 1.1;
}

h1 {
    font-size: clamp(2rem, 3vw, 3rem);
}

h2 {
    margin-top: 24px;
    font-size: 1.45rem;
}

h3,
legend {
    font-size: 1rem;
    letter-spacing: 0.03em;
}

p,
li,
label,
td,
th {
    color: var(--text-soft);
}

a {
    color: var(--primary-dark);
}

a:hover {
    color: var(--primary);
}

.panel {
    padding: 24px;
    margin-bottom: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.panel-soft {
    background: linear-gradient(135deg, rgba(255, 250, 244, 0.95), rgba(244, 239, 231, 0.78));
}

.panel-form {
    max-width: 860px;
}

.panel-compact {
    max-width: 520px;
}

.action-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.auth-card {
    width: min(520px, 100%);
    margin: 10vh auto 0;
}

.auth-card__intro {
    margin-bottom: 18px;
}

.grid-cards,
.stats-grid {
    display: grid;
    gap: 18px;
}

.grid-cards {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin-bottom: 18px;
}

.feature-card,
.stat-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(246, 239, 228, 0.9));
    box-shadow: var(--shadow);
}

.feature-card {
    display: block;
    padding: 22px;
    text-decoration: none;
}

.feature-card strong,
.stat-card strong {
    display: block;
    color: var(--text);
}

.feature-card p,
.stat-card p {
    margin-bottom: 0;
}

.feature-card__tag,
.stat-card span {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--secondary);
}

.stat-card {
    padding: 18px 20px;
}

.stat-card strong {
    font-size: 1.2rem;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.flash,
p[style*="color:green"],
p[style*="color:red"] {
    margin: 0 0 18px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-weight: 700;
}

.flash-success,
p[style*="color:green"] {
    color: var(--success);
    background: var(--success-bg);
    border-color: rgba(36, 107, 79, 0.16);
}

.flash-error,
p[style*="color:red"] {
    color: var(--error);
    background: var(--error-bg);
    border-color: rgba(154, 45, 45, 0.16);
}

form {
    margin: 0 0 18px;
}

fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.55);
}

hr {
    margin: 28px 0;
    border: 0;
    border-top: 1px solid var(--line);
}

input,
textarea,
select,
button {
    width: 100%;
    max-width: 420px;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    font: inherit;
}

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

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(138, 75, 42, 0.4);
    box-shadow: 0 0 0 4px rgba(138, 75, 42, 0.1);
}

button,
.button-link-secondary {
    width: auto;
    max-width: none;
    border: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 12px 24px rgba(138, 75, 42, 0.22);
}

button:hover,
.button-link-secondary:hover {
    background: linear-gradient(135deg, #9d5933, #7d4120);
}

.button-link-secondary {
    background: linear-gradient(135deg, var(--secondary), #235147);
    color: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    background: var(--surface-strong);
    border-radius: 18px;
}

.table-panel {
    overflow-x: auto;
}

.table-panel-wide {
    padding: 18px;
}

.panel-fullbleed,
.planilha-fullbleed {
    width: calc(100vw - 32px);
    max-width: none;
    margin-left: calc(50% - 50vw + 16px);
    margin-right: calc(50% - 50vw + 16px);
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(87, 63, 45, 0.08);
    vertical-align: top;
}

th {
    background: #f1e4d4;
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

tr:hover td {
    background: rgba(246, 239, 228, 0.5);
}

.table-section td {
    background: #ede0cf;
    color: var(--text);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

table form {
    margin: 0;
}

.table-panel input,
.table-panel select,
.table-panel textarea {
    max-width: none;
}

.table-panel button {
    min-width: 96px;
}

.schedule-table {
    min-width: 980px;
    text-align: center;
}

.schedule-table--monthly {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

col.schedule-table__group-col {
    width: 42px;
}

col.schedule-table__label-col {
    width: 190px;
}

col.schedule-table__event-col {
    width: 180px;
}

.schedule-table--monthly th,
.schedule-table--monthly td {
    white-space: nowrap;
    word-break: normal;
}

.schedule-table th,
.schedule-table td {
    text-align: center;
}

.schedule-table tr:first-child th,
.schedule-table tr:nth-child(2) th {
    background: #6e3a1d;
    color: #fff;
}

.schedule-table tr:nth-child(3) th {
    background: #b5483d;
    color: #fff;
}

.agenda-cards {
    display: none;
    gap: 14px;
    margin-bottom: 18px;
}

.agenda-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(246, 239, 228, 0.88));
    box-shadow: var(--shadow);
}

.agenda-card h3 {
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.agenda-card p {
    margin: 0 0 8px;
}

.agenda-card__team {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.agenda-card__team > strong {
    display: block;
    margin-bottom: 10px;
    color: var(--text);
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.agenda-card__team ul {
    display: grid;
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.agenda-card__team li,
.team-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 10px;
    border: 1px solid rgba(87, 63, 45, 0.1);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.62);
}

.agenda-card__team li::marker {
    content: "";
}

.agenda-card__team li span,
.team-list strong {
    color: var(--text);
    font-weight: 800;
}

.agenda-card__team li small,
.team-list span {
    color: var(--text-soft);
    font-size: 0.82rem;
    text-align: right;
}

.agenda-card__team .is-current,
.team-list .is-current {
    border-color: rgba(45, 106, 95, 0.32);
    background: rgba(45, 106, 95, 0.12);
}

.agenda-card__team .is-current span,
.team-list .is-current strong {
    color: var(--secondary);
}

.team-list {
    display: grid;
    gap: 8px;
    min-width: 220px;
}

.agenda-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.agenda-card__calendar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 10px 12px;
    border-radius: 18px;
    background: rgba(138, 75, 42, 0.08);
}

.agenda-card__calendar-day {
    color: var(--text);
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
}

.agenda-card__calendar-month {
    margin-top: 4px;
    color: var(--primary-dark);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.agenda-card__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.agenda-card__weekday {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(45, 106, 95, 0.12);
    color: var(--secondary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.agenda-card--rjm {
    background: linear-gradient(160deg, rgba(240, 248, 255, 0.98), rgba(223, 239, 255, 0.94));
    border-color: rgba(29, 78, 216, 0.14);
}

.agenda-card--ensaio {
    background: linear-gradient(160deg, rgba(255, 245, 245, 0.98), rgba(254, 226, 226, 0.96));
    border-color: rgba(185, 28, 28, 0.14);
}

.agenda-card--visita {
    background: linear-gradient(160deg, rgba(255, 251, 235, 0.98), rgba(254, 243, 199, 0.96));
    border-color: rgba(180, 83, 9, 0.16);
}

.agenda-card--rjm .agenda-card__calendar,
.schedule-table__event--rjm {
    background: rgba(191, 219, 254, 0.75);
}

.agenda-card--ensaio .agenda-card__calendar,
.schedule-table__event--ensaio {
    background: rgba(254, 202, 202, 0.72);
}

.agenda-card--visita .agenda-card__calendar {
    background: rgba(253, 230, 138, 0.72);
}

.schedule-table__event {
    transition: background-color 0.2s ease;
}

.schedule-table__event--rjm {
    color: #1e3a8a;
}

.schedule-table__event--ensaio {
    color: #991b1b;
}

@media (max-width: 900px) {
    .app-shell {
        width: min(100% - 20px, 1180px);
        margin-top: 12px;
    }

    .topbar,
    .page-heading,
    .hero,
    .action-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar__nav {
        width: 100%;
    }

    .topbar__nav a,
    .button-link {
        flex: 1 1 calc(50% - 10px);
        justify-content: center;
    }
}

@media (max-width: 640px) {
    body.app-body {
        font-size: 15px;
    }

    .panel,
    .topbar {
        padding: 18px;
        border-radius: 18px;
    }

    .topbar__nav a,
    .button-link,
    button {
        width: 100%;
        flex-basis: 100%;
    }

    input,
    textarea,
    select {
        max-width: none;
    }

    th,
    td {
        padding: 12px;
    }

    .panel-fullbleed,
    .planilha-fullbleed {
        width: calc(100vw - 12px);
        margin-left: calc(50% - 50vw + 6px);
        margin-right: calc(50% - 50vw + 6px);
    }

    .agenda-cards {
        display: grid;
    }

    .agenda-cards + .panel.table-panel {
        display: none;
    }

    .agenda-card__calendar {
        min-width: 64px;
    }

    .agenda-card__calendar-day {
        font-size: 1.55rem;
    }

    .agenda-card__team {
        margin-top: 12px;
        padding-top: 12px;
    }

    .agenda-card__team > strong {
        font-size: 0.76rem;
    }

    .agenda-card__team ul {
        gap: 7px;
    }

    .agenda-card__team li {
        min-height: 30px;
        padding: 7px 9px;
        border-radius: 10px;
    }

    .agenda-card__team li span {
        font-size: 0.82rem;
    }

    .agenda-card__team li small {
        max-width: 52%;
        font-size: 0.66rem;
        line-height: 1.15;
        text-transform: uppercase;
    }
}
