:root {
  --navy: #0b132b;
  --navy-soft: #111d3d;
  --primary: #075bff;
  --primary-hover: #0048d8;
  --blue-soft: #eaf1ff;
  --cyan: #22d3ee;
  --violet: #6d3df5;
  --bg: #f4f7fc;
  --surface: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --success: #15966a;
  --warning: #d9900b;
  --danger: #dc4c64;
  --shadow: 0 12px 36px rgba(11, 19, 43, .07);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: 276px; flex-direction: column; overflow: hidden; color: #fff; background: radial-gradient(circle at 16% 8%, rgba(34, 211, 238, .13), transparent 24%), linear-gradient(165deg, var(--navy-soft), var(--navy) 62%); box-shadow: 12px 0 38px rgba(11, 19, 43, .12); }
.brand { display: block; padding: 24px 22px 14px; text-decoration: none; }
.brand img { display: block; width: 224px; max-width: 100%; height: auto; }
.sidebar-label { margin: 2px 24px 18px; color: #67e8f9; font-size: 10px; font-weight: 800; letter-spacing: 2.2px; }
.sidebar nav { flex: 1; padding: 8px 14px 20px; }
.sidebar nav a { position: relative; display: flex; align-items: center; gap: 13px; margin-bottom: 7px; padding: 13px 15px; overflow: hidden; border-radius: 12px; color: rgba(255, 255, 255, .72); font-weight: 650; text-decoration: none; transition: color .18s ease, background .18s ease, transform .18s ease; }
.sidebar nav a i { font-size: 18px; }
.sidebar nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); transform: translateX(2px); }
.sidebar nav a.active { color: #fff; background: linear-gradient(90deg, rgba(7, 91, 255, .42), rgba(7, 91, 255, .13)); box-shadow: inset 0 0 0 1px rgba(103, 232, 249, .1); }
.sidebar nav a.active::before { position: absolute; inset: 10px auto 10px 0; width: 3px; border-radius: 0 3px 3px 0; background: var(--cyan); content: ""; }
.sidebar-foot { margin: 0 16px 10px; padding: 14px; border: 1px solid rgba(103, 232, 249, .14); border-radius: 12px; background: rgba(7, 91, 255, .11); }
.sidebar-foot span, .sidebar-foot small { display: block; }
.sidebar-foot span { margin-bottom: 3px; color: #fff; font-size: 12px; font-weight: 750; }
.sidebar-foot small { color: rgba(255, 255, 255, .55); font-size: 10px; line-height: 1.45; }
.logout { padding: 0 16px 18px; }
.logout button { width: 100%; padding: 11px 14px; border: 0; border-radius: 10px; color: #fca5a5; background: transparent; font-weight: 700; text-align: left; transition: background .18s ease; }
.logout button:hover { background: rgba(220, 76, 100, .11); }
.logout button i { margin-right: 8px; }

.main { min-height: 100vh; margin-left: 276px; }
.topbar { display: flex; height: 78px; align-items: center; gap: 22px; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); }
.topbar-title { margin-right: auto; }
.topbar-title span, .topbar-title small, .user-chip strong, .user-chip small { display: block; }
.topbar-title span { font-weight: 800; }
.topbar-title small, .user-chip small { color: var(--muted); font-size: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip > div { text-align: right; }
.user-avatar { display: grid; width: 39px; height: 39px; place-items: center; order: 2; border-radius: 12px; color: var(--primary); background: var(--blue-soft); font-size: 19px; }
.menu-button { display: none; }
.content { max-width: 1500px; margin: auto; padding: 34px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 27px; }
.page-head h1 { margin: 0 0 5px; color: var(--navy); font-size: 32px; font-weight: 820; letter-spacing: -.6px; }
.page-head p { margin: 0; color: var(--muted); }
.eyebrow { margin-bottom: 7px !important; color: var(--primary) !important; font-size: 11px !important; font-weight: 850; letter-spacing: 1.55px; }
.btn { border-radius: 10px; font-weight: 680; }
.btn-primary { border-color: var(--primary); background: var(--primary); box-shadow: 0 8px 20px rgba(7, 91, 255, .18); }
.btn-primary:hover, .btn-primary:focus { border-color: var(--primary-hover); background: var(--primary-hover); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { border-color: var(--primary); background: var(--primary); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.metric { display: flex; min-width: 0; align-items: center; gap: 16px; padding: 21px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); }
.metric-icon { display: grid; width: 48px; height: 48px; flex: 0 0 48px; place-items: center; border-radius: 14px; font-size: 21px; }
.metric-icon.blue { color: var(--primary); background: var(--blue-soft); }
.metric-icon.green { color: var(--success); background: #e2f8f0; }
.metric-icon.amber { color: var(--warning); background: #fff4d6; }
.metric-icon.red { color: var(--danger); background: #ffe8ed; }
.metric span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { display: block; margin-top: 1px; color: var(--navy); font-size: 31px; font-weight: 850; line-height: 1.1; }

.panel { padding: 23px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 18px; color: var(--navy); font-size: 18px; font-weight: 800; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
.panel-head a { color: var(--primary); font-size: 13px; font-weight: 750; text-decoration: none; }
.table { margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 14px 12px; border-color: #edf1f7; }
.table thead th { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .65px; text-transform: uppercase; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: #f9fbff; }
.table-link { color: var(--text); font-weight: 750; text-decoration: none; }
.table-link:hover { color: var(--primary); }
.empty { padding: 28px !important; color: var(--muted); text-align: center; }
.status { display: inline-flex; padding: 5px 9px; border-radius: 999px; color: #526174; background: #edf1f7; font-size: 11px; font-weight: 800; }
.status-ativo { color: #08704d; background: #dcf7ec; }
.status-erro { color: #b32743; background: #ffe5eb; }
.status-provisionando, .status-na_fila { color: #855d05; background: #fff0c7; }
.status-aguardando_dns { color: #234ea5; background: #e6edff; }
.timeline > div { display: flex; gap: 12px; margin: 15px 0; }
.timeline > div > span { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px rgba(34, 211, 238, .12); }
.timeline p, .timeline strong, .timeline small { display: block; margin: 0; }
.timeline small { margin-top: 3px; color: var(--muted); }
.form-panel { max-width: 900px; }
.form-control { min-height: 45px; border-color: #d8e0eb; border-radius: 9px; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 .22rem rgba(7, 91, 255, .12); }
.form-check-input:checked { border-color: var(--primary); background-color: var(--primary); }
.errorlist { margin: 6px 0 0; padding-left: 18px; color: #b32743; font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel dl { margin: 0; }
.panel dl > div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px solid #edf1f7; }
.panel dt { color: var(--muted); font-weight: 600; }
.panel dd { margin: 0; font-weight: 700; text-align: right; }
.action-row { display: flex; gap: 8px; margin-top: 18px; }
.alert { border: 0; border-radius: 12px; }
.alert pre { margin: 8px 0 0; font-size: 12px; white-space: pre-wrap; }

/* Autenticação e configuração inicial */
.auth-page { background: var(--navy); }
.auth-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(390px, 46%) 1fr; background: var(--surface); }
.auth-brand { position: relative; display: flex; min-height: 100vh; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 54px 9%; color: #fff; background: radial-gradient(circle at 18% 14%, rgba(34, 211, 238, .2), transparent 23%), radial-gradient(circle at 85% 76%, rgba(109, 61, 245, .2), transparent 30%), linear-gradient(145deg, #111d3d, var(--navy) 68%); }
.auth-brand::after { position: absolute; right: -120px; bottom: 10%; width: 330px; height: 330px; border: 1px solid rgba(103, 232, 249, .11); border-radius: 50%; box-shadow: 0 0 0 55px rgba(7, 91, 255, .04), 0 0 0 110px rgba(7, 91, 255, .025); content: ""; }
.auth-logo { position: relative; z-index: 1; width: min(380px, 88%); height: auto; }
.auth-message { position: relative; z-index: 1; max-width: 560px; }
.auth-kicker { margin: 0 0 16px; color: #67e8f9; font-size: 11px; font-weight: 850; letter-spacing: 2.2px; }
.auth-message h1 { margin: 0 0 18px; font-size: clamp(34px, 4.2vw, 59px); font-weight: 830; letter-spacing: -1.7px; line-height: 1.05; }
.auth-message > p:last-child { max-width: 520px; margin: 0; color: #b9c6dd; font-size: 17px; line-height: 1.7; }
.auth-foundation { position: relative; z-index: 1; display: flex; align-items: center; gap: 9px; color: #aebcd4; font-size: 13px; font-weight: 650; }
.auth-foundation i { color: var(--cyan); font-size: 19px; }
.auth-form-area { display: grid; min-height: 100vh; place-items: center; padding: 48px; background: linear-gradient(rgba(244, 247, 252, .76), rgba(244, 247, 252, .76)), radial-gradient(circle at 80% 20%, rgba(7, 91, 255, .12), transparent 32%); }
.auth-card { width: min(440px, 100%); }
.setup-card { width: min(700px, 100%); }
.auth-mobile-logo { display: none; }
.auth-card h2 { margin: 0 0 8px; color: var(--navy); font-size: 31px; font-weight: 830; letter-spacing: -.6px; }
.auth-intro { margin: 0 0 28px; color: var(--muted); line-height: 1.6; }
.auth-form .form-label { margin-bottom: 7px; color: #26344d; font-size: 13px; }
.auth-form .form-control { min-height: 49px; background: #fff; }
.auth-form .btn { display: flex; min-height: 50px; align-items: center; justify-content: center; gap: 10px; margin-top: 7px; }
.auth-support { margin: 23px 0 0; color: #8995a8; font-size: 11px; text-align: center; }
.auth-support i { margin-right: 4px; color: var(--primary); }
.form-help { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.setup-shell { grid-template-columns: minmax(340px, 38%) 1fr; }
.setup-form-area { padding-top: 34px; padding-bottom: 34px; }

.dashboard-lower > div { display: flex; }
.dashboard-panel { width: 100%; min-height: 388px; }
.audit-panel { display: flex; flex-direction: column; }
.panel-counter { color: var(--muted); font-size: 11px; font-weight: 750; }
.timeline-scroll { max-height: 316px; margin-right: -8px; padding-right: 10px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #b8c8df transparent; }
.timeline-scroll::-webkit-scrollbar { width: 6px; }
.timeline-scroll::-webkit-scrollbar-track { background: transparent; }
.timeline-scroll::-webkit-scrollbar-thumb { border-radius: 999px; background: #b8c8df; }
.financial-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.financial-summary > div { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f9fbff; }
.financial-summary span, .financial-summary strong { display: block; }
.financial-summary span { margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.financial-summary strong { color: var(--navy); font-size: 14px; }
.environment-badge { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px solid #bcd0ff; border-radius: 999px; color: #174cae; background: var(--blue-soft); font-size: 12px; font-weight: 750; }
.metric strong.money { font-size: 23px; }
.status-pago, .status-confirmada, .status-recebida { color: #08704d; background: #dcf7ec; }
.status-aguardando_pagamento, .status-pendente { color: #855d05; background: #fff0c7; }
.status-inadimplente, .status-vencida, .status-estornada { color: #b32743; background: #ffe5eb; }
.status-isento { color: #40536c; background: #e8edf4; }
.form-section { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.form-section span { color: var(--primary); font-size: 11px; font-weight: 850; letter-spacing: 1.4px; }
.form-section p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.danger-panel { max-width: 760px; border-color: #ffd0d8; }
.danger-heading { display: flex; align-items: flex-start; gap: 16px; }
.danger-heading > i { display: grid; width: 46px; height: 46px; flex: 0 0 46px; place-items: center; border-radius: 14px; color: #b4233f; background: #ffe7ec; font-size: 22px; }
.danger-heading h2 { margin: 0 0 5px; color: var(--navy); font-size: 22px; }
.danger-heading p { margin: 0; color: var(--muted); line-height: 1.55; }
.delete-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 24px 0; }
.delete-summary > div { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f9fbff; }
.delete-summary dt { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.delete-summary dd { margin: 5px 0 0; color: var(--navy); font-weight: 750; overflow-wrap: anywhere; }

@media (max-width: 1050px) {
  .auth-shell, .setup-shell { grid-template-columns: 40% 1fr; }
  .auth-brand { padding: 42px 8%; }
  .auth-message h1 { font-size: 39px; }
  .auth-form-area { padding: 38px; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-102%); transition: transform .22s ease; }
  .menu-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar { justify-content: space-between; padding: 0 18px; }
  .menu-button { display: inline-grid; padding: 4px; border: 0; color: var(--navy); background: transparent; font-size: 25px; }
  .topbar-title { display: none; }
  .user-chip { margin-left: auto; }
  .content { padding: 24px 15px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .financial-summary { grid-template-columns: 1fr 1fr; }
  .auth-shell, .setup-shell { display: block; min-height: 100vh; background: var(--bg); }
  .auth-brand { display: none; }
  .auth-form-area { min-height: 100vh; padding: 30px 18px; }
  .auth-card { width: min(650px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: var(--shadow); }
  .auth-mobile-logo { display: block; margin-bottom: 28px; }
  .auth-mobile-logo img { width: 270px; max-width: 100%; height: auto; }
}

@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 27px; }
  .user-chip small { display: none; }
  .auth-form-area { align-items: start; padding: 0; background: #fff; }
  .auth-card { padding: 30px 20px; border: 0; border-radius: 0; box-shadow: none; }
  .auth-card h2 { font-size: 27px; }
  .auth-mobile-logo img { width: 235px; }
  .setup-card .row > div { width: 100%; }
  .financial-summary { grid-template-columns: 1fr; }
  .delete-summary { grid-template-columns: 1fr; }
}
