/* ==========================================================================
   Edu Santos Assessoria Musical — sistema de interface
   Paleta derivada da identidade visual: espresso, champagne, areia e dourado.
   ========================================================================== */

:root {
    --espresso: #2b2622;
    --espresso-2: #39322c;
    --espresso-3: #4a423b;
    --ink: #2b2622;
    --muted: #6b625a;
    --ivory: #f8f5f1;
    --surface: #ffffff;
    --sand: #f1ebe4;
    --champagne: #d9cbbe;
    --line: #e5ddd3;
    --line-strong: #d3c7b9;
    --gold: #c9a77c;
    --gold-soft: #e9dcc9;
    --gold-strong: #8a6a45;

    --on-dark: #efe8df;
    --on-dark-muted: #b5a898;

    --success: #3f6b4e;  --success-bg: #e8f0ea;
    --warning: #8a5a12;  --warning-bg: #f6ecd9;
    --danger: #9b3b32;   --danger-bg: #f7e5e2;
    --info: #44586e;     --info-bg: #e6ebf0;

    --font-sans: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-serif: "Cormorant Garamond", "Cormorant", Georgia, "Times New Roman", serif;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgb(43 38 34 / 6%);
    --shadow: 0 1px 2px rgb(43 38 34 / 5%), 0 8px 24px -12px rgb(43 38 34 / 18%);
    --focus: 0 0 0 3px rgb(201 167 124 / 55%);

    --sidebar-w: 268px;
    --topbar-h: 64px;
    --gutter: clamp(16px, 3vw, 36px);
    --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--ivory);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--gold-strong); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
    width: 20px; height: 20px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 100;
    padding: 10px 16px; background: var(--espresso); color: var(--on-dark);
    border-radius: var(--radius-sm); text-decoration: none;
}
.skip-link:focus { top: 12px; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

.eyebrow {
    font-size: 11px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase;
    color: var(--gold-strong);
}

/* ---------- Marca tipográfica ---------- */
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; }
.brand__strings { display: flex; gap: 3px; height: 34px; align-items: stretch; }
.brand__strings i {
    width: 1px; background: linear-gradient(180deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent);
}
.brand__strings i:nth-child(2), .brand__strings i:nth-child(3) { margin-block: -3px; }
.brand__text { display: flex; flex-direction: column; line-height: 1; }
.brand__name {
    font-family: var(--font-serif); font-weight: 500; font-size: 23px; letter-spacing: .08em; text-transform: uppercase;
}
.brand__tag {
    margin-top: 6px; font-size: 9.5px; font-weight: 400; letter-spacing: .32em; text-transform: uppercase; opacity: .8;
}
.brand--lg .brand__strings { height: 64px; gap: 5px; }
.brand--lg .brand__name { font-size: 40px; }
.brand--lg .brand__tag { font-size: 12px; margin-top: 10px; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 20px;
    font-size: 14px; font-weight: 500; letter-spacing: .02em; text-decoration: none;
    border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn--primary { background: var(--espresso); color: var(--on-dark); }
.btn--primary:hover { background: var(--espresso-3); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--sand); }
.btn--block { width: 100%; }
.btn[aria-busy="true"] { cursor: progress; opacity: .8; }
.btn[aria-busy="true"]::before {
    content: ""; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-button {
    display: inline-grid; place-items: center; width: 44px; height: 44px;
    background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer; color: inherit;
}
.icon-button:hover { background: rgb(0 0 0 / 5%); }

/* ---------- Formulários ---------- */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field__label { font-size: 13px; font-weight: 500; }
.field__input {
    width: 100%; min-height: 46px; padding: 10px 14px;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field__input:hover { border-color: var(--muted); }
.field__input:focus { outline: none; border-color: var(--gold-strong); box-shadow: var(--focus); }
.field__group { position: relative; display: flex; }
.field__group .field__input { padding-right: 52px; }
.field__addon {
    position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
    display: grid; place-items: center; width: 44px; height: 42px;
    background: none; border: 0; border-radius: var(--radius-sm); color: var(--muted); cursor: pointer;
}
.field__addon:hover { color: var(--ink); }
.field__hint { font-size: 12.5px; color: var(--muted); }
.field__static { min-height: 24px; font-size: 14px; }
.field__error { font-size: 12.5px; color: var(--danger); font-weight: 500; }
.has-error .field__input { border-color: var(--danger); }
.form__actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; padding-top: 6px; }

/* ---------- Avisos e selos ---------- */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid transparent;
}
.alert .icon { margin-top: 1px; }
.alert > span { flex: 1; }
.alert--error { background: var(--danger-bg); color: var(--danger); border-color: rgb(155 59 50 / 18%); }
.alert--success { background: var(--success-bg); color: var(--success); border-color: rgb(63 107 78 / 18%); }
.alert--warning { background: var(--warning-bg); color: var(--warning); border-color: rgb(138 90 18 / 18%); }
.alert--info { background: var(--info-bg); color: var(--info); border-color: rgb(68 88 110 / 18%); }
.alert__close {
    margin: -6px -6px -6px 0; display: grid; place-items: center; width: 32px; height: 32px;
    background: none; border: 0; color: inherit; cursor: pointer; border-radius: var(--radius-sm);
}
.alert__close .icon { width: 16px; height: 16px; margin: 0; }
.flash-stack { display: grid; gap: 10px; margin-bottom: 24px; }

.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
    font-size: 11px; font-weight: 500; letter-spacing: .03em; line-height: 1.4;
    border-radius: 999px; white-space: nowrap; vertical-align: middle;
}
.badge--neutral { background: var(--sand); color: var(--muted); }
.badge--gold { background: var(--gold-soft); color: var(--gold-strong); }
.badge--success { background: var(--success-bg); color: var(--success); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 10px; vertical-align: middle; }
.dot--success { background: var(--success); }
.dot--warning { background: #c08a2e; }

/* ---------- Estrutura do aplicativo ---------- */
.shell { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--espresso); color: var(--on-dark);
    border-right: 1px solid rgb(201 167 124 / 14%);
}
.sidebar__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 22px 10px 18px 22px; }
.sidebar .brand__tag { white-space: nowrap; letter-spacing: .24em; }
.sidebar__brand { color: var(--on-dark); text-decoration: none; }
.sidebar__close { display: none; color: var(--on-dark); }
.sidebar__footer { margin-top: auto; padding: 16px 22px 20px; border-top: 1px solid rgb(255 255 255 / 7%); }
.sidebar__env { font-size: 11px; letter-spacing: .06em; color: var(--on-dark-muted); }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; scrollbar-width: thin; scrollbar-color: var(--espresso-3) transparent; }
.nav__heading {
    padding: 18px 10px 8px; font-size: 10.5px; font-weight: 500;
    letter-spacing: .2em; text-transform: uppercase; color: var(--gold);
}
.nav__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav__link {
    display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 10px;
    font-size: 14px; color: var(--on-dark); text-decoration: none; border-radius: var(--radius-sm);
    transition: background-color .15s var(--ease);
}
.nav__link .icon { color: var(--on-dark-muted); width: 18px; height: 18px; }
a.nav__link:hover { background: var(--espresso-2); }
.nav__link.is-active { background: var(--espresso-2); box-shadow: inset 2px 0 0 var(--gold); }
.nav__link.is-active .icon { color: var(--gold); }
.nav__link.is-disabled { color: var(--on-dark-muted); cursor: default; opacity: .72; }
.nav__soon {
    margin-left: auto; font-size: 10px; letter-spacing: .04em; padding: 1px 7px;
    border: 1px solid rgb(181 168 152 / 30%); border-radius: 999px;
}

.main { margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter);
    background: rgb(248 245 241 / 88%); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar__menu { display: none; margin-left: -10px; }
.topbar__title { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }

.user-menu { position: relative; margin-left: auto; }
.user-menu__trigger {
    display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px;
    background: none; border: 1px solid transparent; border-radius: 999px; cursor: pointer;
}
.user-menu__trigger:hover, .user-menu__trigger[aria-expanded="true"] { background: var(--surface); border-color: var(--line); }
.avatar {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--espresso); color: var(--gold); font-size: 12px; font-weight: 600; letter-spacing: .04em;
}
.user-menu__who { display: grid; text-align: left; line-height: 1.25; }
.user-menu__name { font-size: 13.5px; font-weight: 500; }
.user-menu__role { font-size: 11.5px; color: var(--muted); }
.user-menu__panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; padding: 6px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.user-menu__panel form { margin: 0; }
.user-menu__item {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 12px;
    font-size: 14px; color: var(--ink); text-decoration: none; text-align: left;
    background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.user-menu__item:hover { background: var(--sand); }
.user-menu__item .icon { width: 18px; height: 18px; color: var(--muted); }

.content { padding: 32px var(--gutter) 64px; max-width: 1240px; }
.content:focus { outline: none; box-shadow: none; }

/* ---------- Cabeçalho de página ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 32px; }
.page-title {
    margin-top: 6px; font-family: var(--font-serif); font-weight: 500;
    font-size: clamp(30px, 4vw, 40px); line-height: 1.1; letter-spacing: .005em;
}
.page-lead { margin-top: 10px; max-width: 62ch; color: var(--muted); }
.section-title {
    margin-bottom: 14px; font-size: 11px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}

/* ---------- Cartões ---------- */
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 24px; box-shadow: var(--shadow-sm);
}
.card--narrow { max-width: 520px; }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card__title { font-family: var(--font-serif); font-weight: 600; font-size: 22px; line-height: 1.2; }
.card__subtitle { margin: 24px 0 10px; font-size: 11px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }

/* ---------- Indicadores ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi {
    position: relative; display: flex; flex-direction: column; gap: 14px; padding: 20px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.kpi::after {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
    background: linear-gradient(90deg, var(--gold), transparent 70%); opacity: .7;
}
.kpi--pending::after { opacity: .25; }
.kpi__head { display: flex; align-items: center; gap: 10px; }
.kpi__icon {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--sand); color: var(--gold-strong);
}
.kpi__icon .icon { width: 17px; height: 17px; }
.kpi__label { font-size: 13px; font-weight: 500; line-height: 1.3; }
.kpi__value { font-family: var(--font-serif); font-size: 40px; font-weight: 500; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.kpi__value--empty { color: var(--line-strong); }
.kpi__note { margin-top: -4px; }

.dash-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }

/* ---------- Linha do tempo ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline__item { position: relative; display: flex; gap: 14px; padding: 0 0 18px; }
.timeline__item:not(:last-child)::before {
    content: ""; position: absolute; left: 6px; top: 18px; bottom: 0; width: 1px; background: var(--line);
}
.timeline__dot {
    flex: none; width: 13px; height: 13px; margin-top: 4px; border-radius: 50%;
    background: var(--surface); border: 1.5px solid var(--line-strong);
}
.timeline__item--done .timeline__dot { background: var(--success); border-color: var(--success); }
.timeline__item--current .timeline__dot { background: var(--gold); border-color: var(--gold-strong); box-shadow: 0 0 0 4px var(--gold-soft); }
.timeline__phase { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.timeline__text { margin-top: 2px; font-size: 14px; color: var(--muted); }

/* ---------- Estatísticas e tabelas ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.stats__item { padding: 14px; background: var(--ivory); border-radius: var(--radius); }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 4px 0 0; font-size: 20px; font-weight: 500; }
.stats dd.mono { font-size: 13px; padding-top: 6px; }

.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 500;
    letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }

.empty {
    display: grid; justify-items: center; gap: 10px; padding: 28px 16px; text-align: center;
    color: var(--muted); background: var(--ivory); border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.empty .icon { width: 26px; height: 26px; color: var(--gold-strong); }

/* ---------- Login ---------- */
.auth-body { background: var(--ivory); }
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth__aside {
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 36px;
    padding: 64px clamp(40px, 6vw, 96px);
    background: radial-gradient(120% 80% at 20% 10%, var(--espresso-2), var(--espresso) 60%);
    color: var(--on-dark);
}
.auth__strings {
    position: absolute; top: -10%; bottom: -10%; right: 16%; display: flex; gap: 18px; transform: rotate(8deg); opacity: .32;
}
.auth__strings i { width: 1px; background: linear-gradient(180deg, transparent, var(--gold) 25%, var(--gold) 75%, transparent); }
.auth__brand, .auth__quote { position: relative; }
.auth__quote {
    max-width: 30ch; font-family: var(--font-serif); font-style: italic; font-size: 22px; line-height: 1.4; color: var(--champagne);
}
.auth__main { display: flex; flex-direction: column; justify-content: center; padding: 48px var(--gutter); }
.auth__main > .flash-stack, .auth-card { width: 100%; max-width: 400px; margin-inline: auto; }
.auth__mobile-brand { display: none; }
.auth-card { display: grid; gap: 24px; }
.auth-card__title { margin-top: 8px; font-family: var(--font-serif); font-weight: 500; font-size: 36px; line-height: 1.1; }
.auth-card__lead { margin-top: 8px; color: var(--muted); }
.auth-card__note { font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- Páginas mínimas (erros) ---------- */
.minimal-body { background: var(--ivory); }
.minimal { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 40px; padding: 40px var(--gutter); }
.minimal__brand { color: var(--ink); text-decoration: none; }
.error-card { max-width: 460px; display: grid; justify-items: center; gap: 12px; text-align: center; }
.error-card__code { font-family: var(--font-serif); font-size: 64px; line-height: 1; color: var(--gold-strong); }
.error-card__title { font-family: var(--font-serif); font-weight: 500; font-size: 30px; }
.error-card__text { color: var(--muted); margin-bottom: 12px; }
.error-card__debug {
    max-width: 100%; white-space: pre-wrap; text-align: left; font-size: 12px; padding: 12px;
    background: var(--warning-bg); color: var(--warning); border-radius: var(--radius-sm);
}

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-columns { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: none;
    }
    .sidebar.is-open { transform: none; box-shadow: 0 0 60px rgb(0 0 0 / 35%); }
    .sidebar__close { display: inline-grid; }
    .sidebar-backdrop {
        position: fixed; inset: 0; z-index: 35; background: rgb(43 38 34 / 45%);
    }
    .main { margin-left: 0; }
    .topbar__menu { display: inline-grid; }
    body.nav-open { overflow: hidden; }
}

@media (max-width: 860px) {
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth__aside { display: none; }
    .auth__mobile-brand { display: flex; justify-content: center; margin-bottom: 40px; color: var(--ink); }
}

@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .kpi { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; row-gap: 12px; }
    .kpi__value { font-size: 32px; }
    .kpi__note { grid-column: 1 / -1; margin-top: 0; }
    .stats { grid-template-columns: minmax(0, 1fr); }
    .card { padding: 18px; border-radius: var(--radius); }
    .table-wrap { margin: 0 -18px; padding: 0 18px; }
    .user-menu__who { display: none; }
    .user-menu__trigger { padding: 4px; }
    .content { padding-top: 24px; }
    .page-header { margin-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
    .sidebar, .topbar, .skip-link { display: none !important; }
    .main { margin: 0; }
    body { background: #fff; }
}
