:root {
  color-scheme: light;
  --bg: #f6f6f5;
  --panel: #ffffff;
  --panel-2: #efefee;
  --ink: #333132;
  --muted: #696969;
  --line: #ddddda;
  --brand: #f3771e;
  --brand-2: #d85f11;
  --brand-dark: #4d4d4d;
  --blue: #4d4d4d;
  --green: #158463;
  --amber: #b46a05;
  --red: #c13122;
  --shadow: 0 12px 28px rgba(22, 34, 51, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand-dark);
  color: #fff;
  font-weight: 800;
}

.brand-mark img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
  padding: 12px;
  overflow: auto;
}

.nav-button {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-button:hover {
  background: var(--panel-2);
}

.nav-button.active {
  background: #fff1e6;
  color: var(--brand);
  font-weight: 700;
}

.nav-count {
  color: var(--muted);
  font-size: 12px;
}

.nav-icon,
.icon-button svg,
.small-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.main-panel {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 15px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.session-picker {
  display: grid;
  gap: 4px;
  min-width: 260px;
}

.session-picker span,
.field label,
.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

select:disabled,
input:disabled,
textarea:disabled {
  background: #eef1f5;
  color: var(--muted);
  cursor: not-allowed;
}

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

.content {
  display: grid;
  gap: 18px;
  padding: 22px 24px 36px;
}

.agency-hero,
.company-hero {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  min-height: 178px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--brand-dark);
  color: #fff;
  padding: 22px;
}

.agency-hero img {
  width: min(220px, 34vw);
  max-height: 136px;
  object-fit: contain;
}

.agency-hero h2,
.company-hero h2 {
  margin-bottom: 8px;
  font-size: 30px;
}

.agency-hero p,
.company-hero p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.82);
}

.company-hero {
  justify-content: flex-start;
  background-color: var(--brand-dark);
  background-image: linear-gradient(90deg, var(--brand-dark) 0 72%, var(--company-accent, var(--brand)) 72% 100%);
  background-position: center;
  background-size: cover;
}

.company-logo {
  display: grid;
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  place-items: center;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: #fff;
}

.company-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.section-band {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.kpis {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.68fr);
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.account-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.account-card-top {
  display: grid;
  height: 104px;
  place-items: center;
  background: linear-gradient(90deg, var(--brand-dark) 0 74%, var(--company-accent, var(--brand)) 74% 100%);
}

.account-card-top img {
  width: 78px;
  height: 78px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.account-card-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.account-card-body strong,
.account-card-body span {
  min-width: 0;
}

.account-card-body > span {
  color: var(--muted);
  font-size: 13px;
}

.panel,
.metric,
.form-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(22, 34, 51, 0.03);
}

.panel,
.form-panel {
  padding: 16px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 15px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  font-size: 28px;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  justify-content: space-between;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 170px;
}

.field.wide {
  min-width: 270px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 6px;
  font-weight: 700;
}

.primary-button {
  border: 0;
  background: var(--brand);
  color: #fff;
  padding: 9px 13px;
}

.primary-button:hover {
  background: var(--brand-2);
}

.secondary-button {
  border: 1px solid #d8d5d2;
  background: #f7f5f2;
  color: var(--brand-dark);
  padding: 8px 12px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 11px;
}

.danger-button {
  border: 1px solid #f3b6ba;
  background: #fff4f4;
  color: var(--red);
  padding: 8px 11px;
}

.icon-button {
  width: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.check-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.check-type {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.check-type.active[data-type="Entrada"] {
  border-color: rgba(243, 119, 30, 0.38);
  background: #fff2e8;
  color: var(--brand);
}

.check-type.active[data-type="Salida"] {
  border-color: rgba(77, 77, 77, 0.25);
  background: #eeeeed;
  color: var(--brand-dark);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.pill.good {
  background: #e8f7ef;
  color: var(--green);
}

.pill.warn {
  background: #fff4dd;
  color: var(--amber);
}

.pill.bad {
  background: #fff0f1;
  color: var(--red);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.table-wrap.compact table {
  min-width: 560px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
  color: #445064;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

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

.money-pos {
  color: var(--green);
  font-weight: 800;
}

.money-neg {
  color: var(--red);
  font-weight: 800;
}

.chart-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 110px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.bar-fill {
  height: 100%;
  background: var(--brand);
}

.bar-fill.expense {
  background: #c13122;
}

.empty-state {
  display: grid;
  min-height: 170px;
  place-items: center;
  border: 1px dashed #b9c4d2;
  border-radius: var(--radius);
  background: #fbfcfe;
  color: var(--muted);
  text-align: center;
}

.task-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.auth-page {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(300px, 420px);
  gap: 0;
  align-items: stretch;
  min-height: 100vh;
  margin: -22px -24px -36px;
  background: #fff;
}

.auth-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
  background: var(--brand-dark);
  color: #fff;
  padding: clamp(28px, 6vw, 72px);
}

.auth-brand-panel img {
  width: min(360px, 72vw);
  max-height: 360px;
  object-fit: contain;
}

.auth-brand-panel h2 {
  max-width: 520px;
  margin-bottom: 10px;
  font-size: clamp(30px, 4vw, 54px);
}

.auth-brand-panel p {
  max-width: 480px;
  color: rgba(255, 255, 255, 0.78);
}

.auth-card {
  display: grid;
  gap: 12px;
  align-self: center;
  margin: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth-logo-light {
  width: 138px;
  height: 98px;
  object-fit: contain;
}

.form-message {
  margin-bottom: 0;
  border: 1px solid #f0d28d;
  border-radius: var(--radius);
  background: #fff8e8;
  color: #7a520b;
  padding: 10px 12px;
}

.auth-mode .nav-list {
  min-height: 120px;
}

.auth-mode .app-shell {
  display: block;
}

.auth-mode .sidebar,
.auth-mode .topbar {
  display: none;
}

.auth-mode .content {
  padding: 0;
}

.auth-mode .auth-page {
  margin: 0;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.compact-button {
  min-height: 32px;
  padding: 6px 8px;
  white-space: nowrap;
}

.mini-select {
  min-width: 130px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #182133;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: 100%;
    max-width: 100vw;
    height: auto;
  }

  .nav-list {
    display: flex;
    max-width: 100vw;
    overflow-x: auto;
  }

  .nav-button {
    min-width: 190px;
  }

  .grid.kpis,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .topbar-actions,
  .session-picker {
    width: 100%;
  }

  .content {
    padding: 14px;
  }

  .agency-hero,
  .company-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .agency-hero img {
    width: 180px;
  }

  .auth-page {
    margin: 0;
    min-height: 100vh;
  }

  .auth-brand-panel {
    min-height: 360px;
  }

  .grid.kpis,
  .grid.two,
  .grid.three,
  .auth-page,
  .form-grid,
  .check-actions {
    grid-template-columns: 1fr;
  }

  .filters,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .field,
  .field.wide {
    min-width: 100%;
  }
}
