:root {
  --navy: #061c35;
  --navy-2: #082846;
  --blue: #0b57c5;
  --blue-soft: #eaf5ff;
  --amber: #d97706;
  --amber-soft: #fff6da;
  --red: #d71920;
  --red-soft: #ffe9e9;
  --ink: #101828;
  --muted: #667085;
  --line: #d8e0ea;
  --panel: #ffffff;
  --bg: #f7fafc;
  --shadow: 0 18px 48px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, Segoe UI, Arial, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #071f3a 0%, #0c3d6a 45%, #f8fbff 45%);
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 32px;
  border: 1px solid rgba(216, 224, 234, .9);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 4px 0 0; font-size: 28px; letter-spacing: 0; }
.login-card p { margin: 0 0 8px; color: var(--muted); }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #1d62d1, #0b3c86);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
label { display: grid; gap: 7px; color: #24324a; font-size: 13px; font-weight: 650; }
input, select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  outline: none;
}
input:focus, select:focus { border-color: #8bb9f6; box-shadow: 0 0 0 3px rgba(11, 87, 197, .12); }
.login-card button, .panel button, .metric button, .logout, .topbar button {
  min-height: 38px;
  border: 1px solid #cfd9e8;
  border-radius: 6px;
  background: #fff;
  color: #0b3f8e;
  padding: 8px 14px;
  font-weight: 700;
}
.login-card button, .panel-head > button, #confirmBatchPay, #sendAuthorizationBtn {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.login-card small { min-height: 18px; color: var(--red); }

.shell { min-height: 100vh; display: grid; grid-template-columns: 300px 1fr; }
.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  padding: 28px 16px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 26px;
  color: #fff;
  background: radial-gradient(circle at 20% 0%, #123e6f 0%, #09243f 32%, #041b31 100%);
}
.side-brand { display: flex; align-items: center; gap: 14px; padding: 0 10px 18px; border-bottom: 1px solid rgba(255, 255, 255, .12); font-size: 25px; }
.side-nav { display: grid; align-content: start; gap: 8px; overflow-y: auto; padding-right: 2px; }
.side-nav button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  color: #e9f2ff;
  background: transparent;
  text-align: left;
  font-weight: 750;
}
.side-nav button span { width: 22px; text-align: center; font-size: 18px; }
.side-nav button.active, .side-nav button:hover, .nav-group.open > .nav-parent { background: linear-gradient(135deg, #1b60ce, #0d3b87); }
.nav-parent i {
  margin-left: auto;
  color: #c8d8ee;
  font-style: normal;
  transition: transform .18s ease;
}
.nav-group.open > .nav-parent i { transform: rotate(180deg); }
.submenu {
  display: none;
  margin: 6px 0 6px 36px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, .16);
}
.nav-group.open .submenu { display: grid; gap: 4px; }
.submenu button {
  min-height: 36px;
  border-radius: 6px;
  padding: 0 12px;
  color: #cbd9ea;
  font-size: 13px;
  font-weight: 700;
}
.submenu button.active,
.submenu button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .12);
}
.side-user { display: flex; align-items: center; gap: 12px; padding: 16px 12px; border-bottom: 1px solid rgba(255, 255, 255, .14); }
.side-user strong, .side-user span { display: block; }
.side-user span { color: #cbd7e8; font-size: 13px; margin-top: 3px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: #315d8f; font-weight: 900; }
.logout { width: 100%; color: #fff; border: 0; background: transparent; text-align: left; }

.workspace { min-width: 0; }
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(14px);
}
.menu-btn { width: 44px; padding: 0; color: #53657c; }
.filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.filters label { min-width: 170px; }
.filters input, .filters select { min-height: 42px; }
.refresh-btn {
  min-width: 110px;
  background: var(--blue) !important;
  border-color: var(--blue) !important;
  color: #fff !important;
}

.view { display: none; padding: 28px; }
.view.active { display: block; }
.page-title { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-title h1 { margin: 0; font-size: 30px; letter-spacing: 0; line-height: 1.12; }
.page-title p { margin: 6px 0 0; color: var(--muted); font-size: 17px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 24px; margin-bottom: 24px; }
.metric {
  min-height: 136px;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 22px 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.metric-icon { width: 74px; height: 74px; flex: 0 0 74px; border-radius: 50%; display: grid; place-items: center; font-size: 38px; font-weight: 900; }
.metric span { display: block; font-size: 15px; font-weight: 800; margin-bottom: 12px; }
.metric strong { display: block; font-size: 26px; letter-spacing: 0; margin-bottom: 12px; white-space: nowrap; }
.metric button { min-width: 132px; color: inherit; }
.metric.blue { border-color: #abd6f9; }
.metric.blue .metric-icon { color: #0b57c5; background: #dff1ff; }
.metric.blue strong { color: #0649a8; }
.metric.amber { border-color: #f7d384; }
.metric.amber .metric-icon { color: #d97706; background: #fff1bf; }
.metric.amber strong { color: #d97706; }
.metric.red { border-color: #ffc8c8; }
.metric.red .metric-icon { color: #d71920; background: #ffd8d8; }
.metric.red strong { color: #d71920; }
.metric-grid.compact .metric { min-height: 108px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(360px, .9fr); gap: 24px; margin-bottom: 24px; }
.two-col { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(420px, 1.2fr); gap: 24px; }
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 28px rgba(15, 23, 42, .045);
  padding: 20px;
}
.panel h2 { margin: 0 0 16px; font-size: 17px; letter-spacing: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.button-row button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.muted-info { color: var(--muted); font-size: 13px; font-weight: 700; }
.view .panel + .panel { margin-top: 20px; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid #e0e6ef; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 14px; border-bottom: 1px solid #e2e8f0; text-align: left; font-size: 14px; white-space: nowrap; }
th { background: #f9fbfe; color: #24324a; font-weight: 800; }
td { color: #334155; }
tr:last-child td { border-bottom: 0; }
tr.overdue td { color: var(--red); background: rgba(245, 68, 68, .11); }
.amount-blue { color: #0649a8; font-weight: 800; }
.amount-amber { color: #d97706; font-weight: 800; }
.amount-red { color: #d71920; font-weight: 800; }
.status {
  display: inline-grid;
  place-items: center;
  min-width: 92px;
  min-height: 28px;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 800;
}
.status.open { color: #b45309; background: #fff0c4; }
.status.overdue { color: #c4121a; background: #ffd0d0; }
.status.paid { color: #087443; background: #daf8e8; }
.status.archived, .status.forecast { color: #42526e; background: #edf2f7; }
.actions { display: flex; gap: 8px; }
.actions button { width: 32px; min-height: 30px; padding: 0; color: #0b57c5; }
.chart-panel { min-height: 256px; }
.donut-area { display: flex; align-items: center; justify-content: center; gap: 34px; min-height: 210px; }
.donut { width: 162px; height: 162px; border-radius: 50%; background: conic-gradient(#e94444 0 45%, #f26a6a 45% 72%, #f7b4b4 72% 100%); position: relative; flex: 0 0 162px; }
.donut::after { content: ""; position: absolute; inset: 40px; background: #fff; border-radius: 50%; }
.legend { display: grid; gap: 13px; min-width: 220px; }
.legend-row { display: grid; grid-template-columns: 12px 1fr; gap: 10px; align-items: start; }
.dot { width: 11px; height: 11px; border-radius: 50%; margin-top: 4px; }
.legend strong { display: block; font-size: 15px; }
.legend span { display: block; color: var(--muted); margin-top: 3px; }
.quick-panel { margin-bottom: 22px; }
.tabs { display: flex; gap: 24px; margin: 0 0 -1px 18px; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: #d71920; }
.tabs button.active { color: #0b57c5; border-bottom-color: #0b57c5; }
.panel-foot { display: flex; justify-content: space-between; gap: 14px; padding: 14px 4px 2px; color: #7a889b; font-size: 13px; }

.grid-form { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 16px; align-items: end; }
.grid-form.single { grid-template-columns: 1fr; }
.grid-form .wide { grid-column: span 2; }
.grid-form .check { min-height: 42px; display: flex; align-items: center; gap: 8px; }
.grid-form .check input { min-height: auto; width: 18px; height: 18px; }
.grid-form button { min-height: 43px; background: var(--blue); border-color: var(--blue); color: #fff; }
.list { display: grid; gap: 10px; }
.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid #e1e8f1; border-radius: 6px; background: #fbfdff; }
.list-item span { color: var(--muted); font-size: 13px; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(8, 24, 43, .42);
}
.modal-card {
  width: min(860px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.modal-head h2 { margin: 0; font-size: 21px; letter-spacing: 0; }
.modal-head p { margin: 5px 0 0; color: var(--muted); }
.icon-btn {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #334155;
  font-size: 22px;
  line-height: 1;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions button {
  min-height: 40px;
  border: 1px solid #cfd9e8;
  border-radius: 6px;
  background: #fff;
  color: #0b3f8e;
  padding: 8px 14px;
  font-weight: 800;
}
.modal-actions button[type="submit"] {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 14px 18px; border-radius: 8px; background: #10213c; color: #fff; box-shadow: var(--shadow); z-index: 20; }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 86px 1fr; }
  .side-brand strong, .side-user div, .side-nav button:not(.active), .nav-parent i { font-size: 0; }
  .side-nav button { justify-content: center; padding: 0; }
  .side-nav button span { font-size: 20px; }
  .submenu { margin-left: 0; padding-left: 0; border-left: 0; }
  .submenu button { min-height: 34px; font-size: 0; }
  .dashboard-grid, .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 280px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .side-brand strong, .side-user div, .side-nav button:not(.active), .nav-parent i, .submenu button { font-size: inherit; }
  .side-nav button { justify-content: flex-start; padding: 0 18px; }
  .submenu { margin-left: 36px; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .16); }
  .topbar { align-items: start; flex-direction: column; padding: 14px; }
  .filters, .filters label { width: 100%; }
  .view { padding: 18px 14px; }
  .metric-grid { grid-template-columns: 1fr; gap: 14px; }
  .metric { min-height: 112px; padding: 18px; }
  .metric-icon { width: 58px; height: 58px; flex-basis: 58px; font-size: 28px; }
  .metric strong { font-size: 22px; }
  .page-title h1 { font-size: 25px; }
  .grid-form, .grid-form .wide { grid-template-columns: 1fr; grid-column: auto; }
  .donut-area { flex-direction: column; }
}
