/* ═══════════════════════════════════════════
   RESET & VARIÁVEIS
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #F1F5F9;
  --surface:   #FFFFFF;
  --border:    #E2E8F0;
  --text:      #1E293B;
  --muted:     #64748B;
  --blue:      #0D5B8F;
  --blue-dk:   #0A4E7A;
  --blue-lt:   #E8F2F9;
  --green:     #10B981;
  --green-dk:  #166534;
  --green-lt:  #C6EFCE;
  --red:       #EF4444;
  --red-dk:    #991B1B;
  --sat:       #F58220;
  --sat-lt:    #FEF0E0;
  --sun-lt:    #F5F5F5;
  --total-bg:  #F58220;
  --radius:    10px;
  --shadow:    0 2px 10px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════
   HEADER
═══════════════════════════════════════════ */
header {
  background: linear-gradient(135deg, #0A4E7A 0%, #0D5B8F 100%);
  color: #fff;
  padding: 16px 32px;
  box-shadow: 0 4px 16px rgba(13,91,143,.35);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 22px; }
.logo-text  { font-size: 20px; font-weight: 800; letter-spacing: -.5px; color: #fff; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  min-height: 20px;
}

.bc-back {
  background: none;
  border: none;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  transition: color .15s;
}
.bc-back:hover { color: #fff; }
.bc-sep     { color: rgba(255,255,255,.4); }
.bc-current { color: #fff; font-weight: 600; }

/* User area */
.header-user  { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.user-greeting { font-size: 13px; color: rgba(255,255,255,.85); }

.btn-profile,
.btn-logout {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border: 1.5px solid rgba(255,255,255,.35);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-profile:hover,
.btn-logout:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.6); }

/* ═══════════════════════════════════════════
   MAIN
═══════════════════════════════════════════ */
main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 28px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page-loading {
  text-align: center;
  padding: 60px;
  color: var(--muted);
  font-size: 15px;
}

/* ═══════════════════════════════════════════
   BOTÕES GERAIS
═══════════════════════════════════════════ */
.btn {
  padding: 10px 20px;
  border: none; border-radius: 8px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: filter .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover  { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }

.btn--primary      { background: var(--blue);  color: #fff; }
.btn--outline      { background: transparent; border: 1.5px solid var(--blue); color: var(--blue); }
.btn--ghost-danger { background: transparent; border: 1.5px solid #FECACA; color: var(--red); }
.btn--ghost-danger:hover { background: #FEE2E2; }
.btn--sm { padding: 7px 14px; font-size: 13px; }

/* ═══════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════ */
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.dash-title { font-size: 22px; font-weight: 800; color: var(--text); }
.dash-sub   { font-size: 14px; color: var(--muted); margin-top: 3px; }

.periodos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.periodo-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.periodo-card:hover {
  border-color: var(--blue);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(13,91,143,.15);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.card-top-info { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.card-nome  { font-size: 17px; font-weight: 800; color: var(--text); }
.card-datas { font-size: 12px; color: var(--muted); }

.card-drag-handle {
  color: #CBD5E1;
  cursor: grab;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
  line-height: 0;
}
.card-drag-handle:hover { color: var(--blue); background: var(--blue-lt); }
.card-drag-handle:active { cursor: grabbing; }

.card--dragging {
  opacity: .45;
  outline: 2px dashed var(--blue);
  outline-offset: 2px;
}
.card--drag-over {
  border-color: var(--blue) !important;
  box-shadow: 0 0 0 3px rgba(13,91,143,.18) !important;
  transform: translateY(-2px);
}

.card-stats { display: flex; flex-direction: column; gap: 8px; }

.card-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.card-stat span  { color: var(--muted); }
.card-stat strong { font-weight: 700; color: var(--text); }
.card-stat--vale  strong { color: var(--green); }
.card-stat--descs strong { color: var(--red-dk); }

.card-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.card-stat--liq {
  padding-top: 4px;
}
.card-stat--liq span   { font-size: 13px; font-weight: 600; color: var(--text); }
.card-stat--liq strong { font-size: 17px; font-weight: 800; color: var(--blue); }

.card-stat--liq-vale span   { font-size: 12px; color: #6B7280; }
.card-stat--liq-vale strong { font-size: 14px; font-weight: 700; color: var(--green); }

.card-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

.empty-dash {
  text-align: center;
  padding: 60px 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--muted);
}
.empty-icon { font-size: 52px; }
.empty-dash p { font-size: 15px; }

/* ═══════════════════════════════════════════
   CONFIG PANEL (PERÍODO)
═══════════════════════════════════════════ */
.config-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.period-name-input {
  width: 100%;
  max-width: 400px;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  background: transparent;
  outline: none;
  padding: 2px 0;
  transition: border-color .15s;
}
.period-name-input:hover  { border-color: var(--border); }
.period-name-input:focus  { border-color: var(--blue); }

.config-fields {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.config-field {
  display: flex; flex-direction: column; gap: 5px;
  flex: 1; min-width: 150px;
}
.config-field--sm     { flex: 0 0 90px;  min-width: 70px; }
.config-field--action { flex: 0 0 auto; }

.cfg-dias-label {
  font-size: 10px; font-weight: 500;
  color: #6B7280; text-transform: none; letter-spacing: 0;
}
.input-readonly {
  background: #F3F4F6;
  color: #6B7280;
  cursor: default;
}

.config-field label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted);
}

.config-field input {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #FAFAFA;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.config-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(13,91,143,.1);
  background: #fff;
}

.input-money {
  display: flex; align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 8px; overflow: hidden;
  background: #FAFAFA;
  transition: border-color .15s, box-shadow .15s;
}
.input-money:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(13,91,143,.1);
  background: #fff;
}
.money-prefix {
  padding: 9px 10px;
  background: var(--bg);
  border-right: 1.5px solid var(--border);
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.input-money input {
  border: none; background: transparent;
  box-shadow: none !important; border-radius: 0;
  flex: 1; min-width: 0;
}

/* ═══════════════════════════════════════════
   TABELA / PLANILHA
═══════════════════════════════════════════ */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.planilha {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 600px;
}

.planilha thead tr:first-child th {
  padding: 10px 6px 4px;
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid rgba(0,0,0,.06);
  color: var(--text);
}
.planilha thead tr:last-child th {
  padding: 3px 6px 10px;
  font-size: 12px; font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--border);
}

.th-nome {
  width: 220px; min-width: 160px;
  position: sticky; left: 0; z-index: 3;
  background: var(--blue-dk); color: #fff !important;
  text-align: left; padding-left: 16px !important;
  border-right: 2px solid rgba(255,255,255,.2);
}
.th-mes {
  width: 110px; min-width: 85px;
  position: sticky; left: 220px; z-index: 3;
  background: var(--blue-dk); color: #fff !important;
  text-align: center;
  border-right: 2px solid rgba(255,255,255,.2);
}
.th-day   { width: 56px; min-width: 50px; text-align: center; }
.th-total {
  width: 68px; min-width: 60px; text-align: center;
  background: var(--blue-dk); color: #fff !important;
  border-left: 2px solid rgba(255,255,255,.2);
}

.col-wd  { background: var(--green-lt); }
.col-sat { background: #F4C28B; }
.col-sun { background: #E8E8E8; color: #666 !important; }

.planilha tbody tr { border-bottom: 1px solid var(--border); }
.planilha tbody tr:hover { background: #F8FAFC; }

.td-nome {
  position: sticky; left: 0; z-index: 2;
  background: #fff; border-right: 2px solid var(--border); padding: 0;
}
.td-mes {
  position: sticky; left: 220px; z-index: 2;
  background: #fff; border-right: 2px solid var(--border); padding: 0;
}
.planilha tbody tr:hover .td-nome,
.planilha tbody tr:hover .td-mes { background: #F8FAFC; }

.td-day { padding: 0; border-right: 1px solid var(--border); }
.td-day.col-wd  { background: #F0FDF4; }
.td-day.col-sat { background: #FEF0E0; }
.td-day.col-sun { background: #F5F5F5; }

.cell-input {
  width: 100%; height: 100%; min-height: 40px;
  border: none; background: transparent;
  text-align: center; font-size: 14px; font-weight: 600;
  color: var(--text); padding: 0 2px; outline: none; display: block;
  -moz-appearance: textfield;
}
.cell-input::-webkit-outer-spin-button,
.cell-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.cell-input:focus { background: rgba(13,91,143,.08); border-radius: 3px; }

.cell-input-text {
  width: 100%; height: 100%; min-height: 40px;
  border: none; background: transparent;
  font-size: 13px; font-weight: 500; color: var(--text);
  padding: 0 10px; outline: none; display: block;
}
.cell-input-text:focus { background: rgba(13,91,143,.06); }

.td-total {
  text-align: center;
  font-size: 13px; font-weight: 700;
  color: var(--blue);
  background: var(--blue-lt);
  border-left: 2px solid var(--border);
  white-space: nowrap;
  padding: 0 6px;
  min-width: 60px;
}
.planilha tbody tr:hover .td-total { background: #D6E9F5; }

.td-remove { width: 32px; padding: 0; text-align: center; border-right: none; }
.btn-remove {
  background: none; border: none; cursor: pointer;
  color: #CBD5E1; font-size: 13px; padding: 4px 6px;
  border-radius: 4px; transition: color .15s, background .15s; line-height: 1;
}
.btn-remove:hover { color: var(--red); background: #FEE2E2; }

.planilha tfoot td {
  background: var(--total-bg); color: #fff;
  font-weight: 800; font-size: 13px;
  padding: 10px 6px; text-align: center;
  border-top: 2px solid rgba(0,0,0,.15);
}
.tfoot-nome {
  position: sticky; left: 0; z-index: 2;
  text-align: left !important; padding-left: 16px !important;
  border-right: 2px solid rgba(255,255,255,.2) !important;
  font-size: 14px !important;
}
.tfoot-mes {
  position: sticky; left: 220px; z-index: 2;
  border-right: 2px solid rgba(255,255,255,.2) !important;
}
.tfoot-day   { border-right: 1px solid rgba(255,255,255,.15) !important; }
.tfoot-total {
  border-left: 2px solid rgba(255,255,255,.2) !important;
  font-size: 14px !important;
}

.table-actions {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.table-hint { font-size: 12px; color: var(--muted); font-style: italic; }

/* ═══════════════════════════════════════════
   PAINEL FINANCEIRO
═══════════════════════════════════════════ */
.financeiro-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.fin-title {
  font-size: 15px; font-weight: 800;
  color: var(--text);
  padding: 18px 24px 0;
  letter-spacing: -.2px;
}

.fin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 16px 0;
}

.fin-section {
  padding: 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fin-section:first-child {
  border-right: 1px solid var(--border);
}

.fin-section-title {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .7px;
  padding-bottom: 4px;
  border-bottom: 2px solid;
  margin-bottom: 4px;
}
.fin-section-title--green { color: var(--green-dk); border-color: var(--green); }
.fin-section-title--red   { color: var(--red-dk);   border-color: var(--red);   }

.fin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
}

.fin-label {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.fin-val {
  font-size: 14px; font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.fin-val--green { color: var(--green-dk); }
.fin-val--red   { color: var(--red-dk);   }

/* Badge de faixa do vale */
.fin-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  background: #DCFCE7; color: var(--green-dk);
  padding: 2px 7px; border-radius: 20px;
  letter-spacing: .2px;
  white-space: nowrap;
}

.fin-row--vale .fin-label { font-weight: 600; color: var(--green-dk); }
.fin-row--subtotal .fin-label { font-weight: 700; font-size: 13px; color: var(--text); }
.fin-row--subtotal .fin-val   { font-size: 15px; }

.fin-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Inputs de desconto */
.fin-input-wrap {
  display: flex; align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 7px; overflow: hidden;
  background: #FAFAFA;
  transition: border-color .15s;
  flex-shrink: 0;
}
.fin-input-wrap:focus-within {
  border-color: var(--blue);
  background: #fff;
}
.fin-prefix {
  padding: 5px 7px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--bg);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.fin-input {
  width: 90px; padding: 5px 8px;
  border: none; background: transparent;
  font-size: 13px; font-weight: 600; color: var(--text);
  outline: none; text-align: right;
  -moz-appearance: textfield;
}
.fin-input::-webkit-outer-spin-button,
.fin-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Extra desconto */
.fin-row--extra { gap: 8px; }
.fin-label-input {
  flex: 1;
  border: 1.5px solid var(--border); border-radius: 7px;
  padding: 5px 10px; font-size: 13px; color: var(--text);
  background: #FAFAFA; outline: none;
  transition: border-color .15s;
}
.fin-label-input:focus { border-color: var(--blue); background: #fff; }
.fin-label-input::placeholder { color: #CBD5E1; }

.btn-remove-desc {
  background: none; border: none; cursor: pointer;
  color: #CBD5E1; font-size: 13px; padding: 4px 6px;
  border-radius: 4px; transition: color .15s, background .15s;
  flex-shrink: 0;
}
.btn-remove-desc:hover { color: var(--red); background: #FEE2E2; }

.btn-add-desc {
  align-self: flex-start;
  background: none; border: 1.5px dashed var(--border);
  color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 7px; cursor: pointer;
  transition: border-color .15s, color .15s;
  margin-top: 2px;
}
.btn-add-desc:hover { border-color: var(--blue); color: var(--blue); }

/* Sub-rótulo de seção dentro dos descontos */
.fin-sublabel {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  display: block;
  margin-top: 4px;
  margin-bottom: 2px;
}

/* Linha de encargo legal (INSS / IRRF) */
.fin-row--legal {
  align-items: flex-start;
}

.fin-row--legal .fin-label {
  padding-top: 2px;
}

.fin-legal-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex-shrink: 0;
}

.fin-legal-base {
  font-size: 10px;
  color: var(--muted);
}

/* Badge variante cinza (encargos legais) */
.fin-badge--gray {
  background: #F1F5F9;
  color: var(--muted);
}

/* Salário Líquido */
.salario-liquido {
  background: linear-gradient(135deg, #0A4E7A, #0D5B8F);
  padding: 0 24px;
  color: #fff;
  display: flex;
  flex-direction: column;
}

.liq-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
}

.liq-sep {
  height: 1px;
  background: rgba(255,255,255,.2);
}

.liq-label { font-size: 13px; font-weight: 700; opacity: .85; letter-spacing: .3px; }
.liq-val   { font-size: 24px; font-weight: 900; letter-spacing: -.5px; white-space: nowrap; }
.liq-val--secondary { font-size: 18px; opacity: .75; }

/* ═══════════════════════════════════════════
   PERFIL
═══════════════════════════════════════════ */
.perfil-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 700px;
}

.perfil-header { display: flex; flex-direction: column; gap: 4px; }
.perfil-title    { font-size: 22px; font-weight: 800; color: var(--text); }
.perfil-subtitle { font-size: 14px; color: var(--muted); }

.perfil-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.perfil-section-title {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--blue);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--blue-lt);
}

.perfil-hint {
  font-size: 13px; color: var(--muted);
  margin-top: -8px; line-height: 1.5;
}

.perfil-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.perfil-field { display: flex; flex-direction: column; gap: 5px; }

.perfil-field label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted);
}

.perfil-field > input {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px; color: var(--text);
  background: #FAFAFA;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.perfil-field > input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(13,91,143,.1);
  background: #fff;
}
.perfil-field > input:disabled {
  color: var(--muted);
  background: var(--bg);
  cursor: not-allowed;
}

.perfil-actions { display: flex; gap: 10px; }

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1E293B; color: #fff;
  padding: 12px 18px; border-radius: 8px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  z-index: 1000;
  animation: toastIn .2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════ */
footer {
  text-align: center; padding: 18px;
  font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   RESPONSIVO
═══════════════════════════════════════════ */
@media (max-width: 860px) {
  .fin-grid { grid-template-columns: 1fr; }
  .fin-section:first-child { border-right: none; border-bottom: 1px solid var(--border); }
}

@media (max-width: 600px) {
  header { padding: 12px 14px; }
  main   { padding: 16px 10px 32px; gap: 14px; }
  .dash-header { flex-direction: column; }
  .periodos-grid { grid-template-columns: 1fr; }
  .th-nome { width: 150px; }
  .th-mes  { left: 150px; }
  .td-mes  { left: 150px; }
  .tfoot-mes { left: 150px; }
  .liq-val { font-size: 20px; }
}
