:root {
  --navy: #092746;
  --navy-2: #123d63;
  --blue: #1769aa;
  --line: #d9e2ea;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #667789;
  --green: #1c8b5a;
  --red: #b33a3a;
  --gold: #bd9448;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: #eef3f8;
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 24px;
  box-shadow: 0 18px 50px rgba(8, 31, 52, 0.12);
}

.auth-brand {
  margin-bottom: 20px;
  color: var(--navy);
}

.auth-card h1 {
  margin: 0 0 8px;
}

.auth-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form small {
  min-height: 18px;
  color: var(--red);
  font-weight: 700;
}

body.locked .sidebar,
body.locked .shell {
  display: none;
}

button,
input,
select {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 276px;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

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

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

.brand span,
.sidebar-footer span {
  color: #b8c9d9;
  font-size: 12px;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 3px;
  margin-top: 16px;
  padding-bottom: 12px;
}

.nav-group {
  margin: 18px 10px 6px;
  color: #a9c7e2;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 12px;
}

.nav-group:first-of-type {
  border-top: 0;
  margin-top: 8px;
  padding-top: 0;
}

.nav-item {
  width: 100%;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: #dce8f3;
  text-align: left;
  padding: 9px 11px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.15;
}

.nav-item span {
  width: 22px;
  min-width: 22px;
  color: #9dc5e8;
  text-align: center;
  font-size: 14px;
}

.nav-compact {
  font-size: 13px;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.sidebar-footer strong {
  display: block;
  margin-top: 2px;
}

.shell {
  min-height: 100vh;
  margin-left: 276px;
  padding: 22px 26px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

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

h1,
h2 {
  margin: 0;
  color: var(--navy);
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 17px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.search {
  width: min(360px, 36vw);
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
}

.primary,
.ghost {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--navy);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric,
.panel,
.report,
.total-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
  min-height: 98px;
}

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

.metric strong {
  display: block;
  margin: 10px 0 4px;
  color: var(--navy);
  font-size: 24px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.ok {
  background: #e6f5ee;
  color: var(--green);
}

.warn {
  background: #fff4df;
  color: #946400;
}

.neutral {
  background: #eaf2f8;
  color: var(--blue);
}

.late {
  background: #fdeaea;
  color: var(--red);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.cash-summary {
  grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  color: var(--navy);
  font-size: 19px;
}

.summary-card.danger strong {
  color: var(--red);
}

.summary-card.ok-card strong {
  color: var(--green);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 12px;
}

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

.table-wrap table {
  min-width: 860px;
}

.row-selected {
  background: #eaf2f8;
}

.row-late {
  background: #fff5f5;
}

.row-check {
  width: 17px;
  min-height: 17px;
  accent-color: var(--blue);
}

.table-action {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.danger-action {
  color: var(--red);
  border-color: #f3b8b8;
  background: #fff7f7;
}

.danger-action:hover {
  background: #fdeaea;
}

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

.icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 18px;
}

.alert-list {
  display: grid;
  gap: 10px;
}

.alert-list div {
  padding: 12px;
  border-left: 3px solid var(--gold);
  background: #f8fafc;
}

.alert-list strong,
.alert-list span {
  display: block;
}

.alert-list span {
  color: var(--muted);
  margin-top: 3px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
}

.check-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  text-transform: none;
  cursor: pointer;
}

.check-option input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--blue);
}

.check-option span {
  display: grid;
  gap: 2px;
}

.check-option strong {
  color: var(--navy);
  font-size: 13px;
}

.check-option small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.sale-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
}

.total-box {
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 12px;
}

.total-box span {
  color: var(--muted);
}

.total-box strong {
  color: var(--navy);
  font-size: 28px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.report {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.taxonomy-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.taxonomy-card {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.taxonomy-card h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 15px;
}

.taxonomy-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.taxonomy-card li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  background: #f8fafc;
  border-radius: 6px;
}

.taxonomy-card li span,
.empty-line {
  color: var(--muted);
  font-size: 12px;
}

.plan-builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  margin-bottom: 16px;
}

.plan-form,
.plan-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.plan-form {
  display: grid;
  gap: 12px;
}

.plan-preview {
  background: var(--navy);
  color: #fff;
  display: grid;
  align-content: center;
  gap: 12px;
}

.plan-preview span {
  color: #cfe0ef;
}

.plan-preview strong {
  font-size: 27px;
}

.installment-preview {
  display: grid;
  gap: 8px;
  color: #fff;
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}

.installment-preview div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.installment-preview div strong {
  font-size: 14px;
}

.plan-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 12px;
}

.plan-card,
.empty-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.plan-card {
  display: grid;
  gap: 12px;
}

.plan-card strong,
.plan-card span {
  display: block;
}

.plan-card strong {
  color: var(--navy);
  font-size: 16px;
}

.plan-card span,
.empty-card {
  color: var(--muted);
}

.plan-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.plan-tags span {
  min-height: 24px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eaf2f8;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.muted-card {
  opacity: 0.62;
}

.quick-conditions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-conditions .ghost {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.one-row {
  grid-template-columns: minmax(220px, 420px);
}

.empty {
  height: 62px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 5;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  background: var(--navy);
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(9, 39, 70, 0.22);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 31, 52, 0.44);
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(720px, 100%);
  max-height: min(680px, calc(100vh - 48px));
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 22px 70px rgba(8, 31, 52, 0.28);
}

.modal-body {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.modal-line {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.modal-line strong,
.modal-line span {
  display: block;
}

.modal-line span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

@media print {
  .sidebar,
  .topbar,
  .top-actions,
  .filter-grid,
  .modal-backdrop {
    display: none !important;
  }

  .shell {
    margin: 0;
    padding: 0;
  }
}

@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    width: 118px;
    padding: 10px 7px;
  }

  .shell {
    margin-left: 118px;
    padding: 14px 10px 26px;
  }

  .brand {
    justify-content: center;
    margin-bottom: 12px;
  }

  .brand div:not(.brand-mark),
  .nav-group,
  .sidebar-footer {
    display: none;
  }

  .nav {
    gap: 5px;
  }

  .nav-item {
    min-height: 58px;
    justify-content: center;
    padding: 7px 4px;
    text-align: center;
    flex-direction: column;
    gap: 5px;
    font-size: 11px;
    line-height: 1.15;
  }

  .nav-item span {
    width: auto;
    min-width: 0;
    font-size: 15px;
  }

  .nav-compact {
    font-size: 10px;
  }

  .metrics,
  .split,
  .sale-layout,
  .report-grid,
  .form-grid,
  .taxonomy-grid,
  .plan-builder,
  .plan-list,
  .summary-grid,
  .cash-summary,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .search {
    width: 100%;
  }

  .panel {
    padding: 12px;
  }
}
