:root {
  --sidebar: #f7fbff;
  --sidebar-soft: #ffffff;
  --sidebar-line: #d9e6f7;
  --page: #f5f8fc;
  --surface: #ffffff;
  --surface-2: #edf4fc;
  --text: #172033;
  --muted: #66758a;
  --line: #d7e1ee;
  --blue: #0b63ce;
  --blue-soft: #eef2f6;
  --silver: #8b93a1;
  --silver-soft: #f1f4f8;
  --chart-primary: #0b63ce;
  --chart-secondary: #dc2626;
  --green: #059669;
  --yellow: #c27803;
  --red: #dc2626;
  --shadow: 0 18px 45px rgba(18, 48, 84, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(11, 99, 206, 0.10), transparent 32%),
    linear-gradient(180deg, #fbfdff 0%, var(--page) 48%, #edf4fb 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-version {
  padding: 3px 7px;
  border: 1px solid rgba(139, 147, 161, 0.32);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--silver);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  backdrop-filter: blur(8px);
}

.fixed-version {
  position: fixed;
  left: 10px;
  bottom: 8px;
  z-index: 50;
}

.sidebar-version {
  align-self: flex-start;
  margin-top: 8px;
  margin-left: 2px;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 92px;
  padding-inline: 12px;
}

.app-shell.sidebar-collapsed .workspace {
  width: calc(100% - 92px);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 28% 18%, rgba(11, 99, 206, 0.16), transparent 30%),
    linear-gradient(135deg, #f9fcff, #edf4fb),
    var(--page);
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 22px;
  padding: 0 0 18px;
}

.auth-copy h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

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

.full-button {
  width: 100%;
  justify-content: center;
}

.notice {
  margin-top: 18px;
  border: 1px solid #cdd8e6;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f1f4f8;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
}

.notice.danger {
  border-color: #fecaca;
  background: #fff0f0;
  color: var(--red);
}

.sidebar {
  position: sticky;
  top: 0;
  width: 276px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: var(--sidebar);
  color: var(--text);
  border-right: 1px solid var(--sidebar-line);
  z-index: 20;
  transition:
    width 180ms ease,
    padding 180ms ease;
}

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

.brand-logo {
  width: 78px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: contain;
  object-position: center;
  border: 1px solid #d8e2f0;
  border-radius: 8px;
  background: #f8fbff;
  box-shadow: 0 8px 18px rgba(11, 99, 206, 0.12);
}

.auth-logo {
  width: 180px;
  height: 110px;
}

.brand-copy {
  min-width: 0;
  flex: 1;
}

.sidebar-toggle {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-content: center;
  gap: 4px;
  border: 1px solid #cbd9ec;
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  box-shadow: 0 8px 16px rgba(18, 48, 84, 0.08);
}

.sidebar-toggle span {
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

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

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

.nav-list {
  display: grid;
  gap: 5px;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  color: #4d5e74;
  text-align: left;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: var(--blue-soft);
  color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.nav-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: inline-grid;
  place-items: center;
}

.nav-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label,
.brand-copy,
.sidebar-footer-label,
.sidebar-footer-name {
  transition:
    opacity 140ms ease,
    width 140ms ease;
}

.app-shell.sidebar-collapsed .brand {
  justify-content: center;
}

.app-shell.sidebar-collapsed .brand-logo {
  width: 52px;
  height: 38px;
}

.app-shell.sidebar-collapsed .brand-copy,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .sidebar-footer-label,
.app-shell.sidebar-collapsed .sidebar-footer-name {
  width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  top: 18px;
  right: -18px;
}

.app-shell.sidebar-collapsed .nav-item {
  justify-content: center;
  padding-inline: 10px;
}

.app-shell.sidebar-collapsed .sidebar-footer {
  width: 100%;
  padding: 8px;
  min-height: 48px;
  display: grid;
  place-items: center;
}

.app-shell.sidebar-collapsed .sidebar-footer::before {
  content: "RS";
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.app-shell.sidebar-collapsed .sidebar-version {
  align-self: center;
  margin-left: 0;
  padding-inline: 5px;
  font-size: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: var(--sidebar-soft);
  box-shadow: 0 10px 22px rgba(18, 48, 84, 0.06);
}

.sidebar-footer span,
.sidebar-footer strong {
  display: block;
}

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

.sidebar-footer strong {
  margin-top: 4px;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  width: calc(100% - 276px);
  min-width: 0;
  padding: 22px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-top: 3px solid rgba(11, 99, 206, 0.18);
}

.menu-toggle {
  display: none;
}

.page-title {
  min-width: 170px;
  margin-right: auto;
}

.page-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.page-title h1 {
  margin: 4px 0 0;
  font-size: clamp(22px, 3vw, 31px);
  line-height: 1.1;
  letter-spacing: 0;
}

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

.header-identity {
  min-height: 40px;
  display: grid;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  background: #fff;
}

.header-identity span,
.header-identity strong {
  display: block;
  white-space: nowrap;
}

.header-identity span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.header-identity strong {
  font-size: 14px;
}

.period-filter {
  display: flex;
  align-items: end;
  gap: 8px;
}

.period-filter select {
  min-width: 118px;
}

.select-label,
.field label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input,
textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(11, 99, 206, 0.14);
}

.password-control {
  position: relative;
  display: block;
}

.password-control input {
  width: 100%;
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: var(--blue-soft);
  color: var(--blue);
  outline: none;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 12px;
  font-weight: 800;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0b63ce, #1374df);
  color: #fff;
  box-shadow: 0 10px 20px rgba(11, 99, 206, 0.18);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.secondary-button {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: #c9dbf2;
}

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

.icon-button {
  width: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.context-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.context-card,
.metric-card,
.panel,
.data-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 26px rgba(18, 48, 84, 0.06);
}

.context-card {
  padding: 14px;
}

.context-card span,
.metric-card span,
.table-meta,
.muted {
  color: var(--muted);
}

.context-card strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}

.view-root {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

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

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

.metric-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.metric-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue-soft), #f5f8fc);
  color: var(--blue);
  font-weight: 900;
  border: 1px solid #d7e6f8;
}

.metric-card strong {
  display: block;
  margin-top: 18px;
  font-size: 27px;
  line-height: 1.05;
}

.metric-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chart {
  height: 280px;
  display: grid;
  grid-template-columns: repeat(6, minmax(42px, 1fr));
  align-items: end;
  gap: 10px;
  padding: 10px 2px 0;
}

.bar-wrap {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
  height: 100%;
}

.bar-track {
  display: flex;
  align-items: flex-end;
  min-height: 0;
}

.bar {
  width: 100%;
  min-height: 12px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--chart-primary), var(--silver));
}

.bar.is-zero {
  min-height: 0;
  background: transparent;
}

.bar-label {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.line-chart {
  display: grid;
  gap: 12px;
}

.line-chart svg {
  width: 100%;
  height: 220px;
  max-height: 32vh;
  min-height: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.axis-line {
  stroke: #cbd5e1;
  stroke-width: 1;
}

.line-income,
.line-expense {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-income {
  stroke: var(--chart-primary);
}

.line-expense {
  stroke: var(--chart-secondary);
}

.chart-label {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: middle;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.report-chart-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.pie-chart {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1;
}

.report-bars {
  height: 250px;
  display: grid;
  grid-template-columns: repeat(6, minmax(48px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 8px 0 12px;
}

.report-bar-group {
  height: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.report-bar-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  min-height: 0;
}

.report-bar {
  width: 42%;
  min-height: 0;
  border-radius: 7px 7px 2px 2px;
}

.income-bar {
  background: var(--chart-primary);
}

.expense-bar {
  background: var(--chart-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.income {
  background: var(--chart-primary);
}

.legend-dot.expense {
  background: var(--chart-secondary);
}

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

.indicator-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.indicator-card strong {
  margin-top: 12px;
  font-size: 25px;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.import-preview-table {
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.row-error td {
  background: #fff5f5;
  color: #7f1d1d;
}

.error-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  margin: 2px;
  background: #fee2e2;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
}

.check-row input {
  min-height: auto;
}

.alerts-list,
.timeline,
.settings-list {
  display: grid;
  gap: 10px;
}

.alert,
.timeline-item,
.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.alert-status,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.green,
.alert-status.green {
  background: #e6f7ef;
  color: var(--green);
}

.badge.blue,
.alert-status.blue {
  background: #eaf1ff;
  color: var(--blue);
}

.badge.yellow,
.alert-status.yellow {
  background: #fff5df;
  color: var(--yellow);
}

.badge.red,
.alert-status.red {
  background: #fff0f0;
  color: var(--red);
}

.badge.gray,
.alert-status.gray {
  background: #f1f5f9;
  color: #475569;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

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

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

.row-actions {
  display: flex;
  gap: 7px;
}

.action-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
}

.danger-link {
  color: var(--red);
}

.success-link {
  color: var(--green);
}

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

.data-card {
  padding: 16px;
}

.data-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

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

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

.filters input,
.filters select {
  min-width: 190px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
  z-index: 40;
}

.modal {
  width: min(560px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.compact-form {
  padding: 0;
}

.field {
  display: grid;
  gap: 6px;
}

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

.form-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
  padding-top: 4px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .metrics-grid,
  .context-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .data-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .sidebar {
    position: sticky;
    width: 236px;
    padding-inline: 10px;
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: 84px;
  }

  .workspace {
    width: calc(100% - 236px);
    padding: 12px;
  }

  .app-shell.sidebar-collapsed .workspace {
    width: calc(100% - 84px);
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .page-title {
    width: 100%;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .select-label,
  .topbar-actions .primary-button {
    flex: 1 1 180px;
  }

  .select-label select,
  .topbar-actions .primary-button {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .metrics-grid,
  .context-strip {
    grid-template-columns: 1fr;
  }

  .chart {
    height: 220px;
    gap: 7px;
  }

  .line-chart svg {
    height: 180px;
    max-height: none;
  }

  .report-chart-grid {
    grid-template-columns: 1fr;
  }

  .pie-chart {
    justify-self: center;
    max-width: 180px;
  }

  .report-bars {
    height: 210px;
    gap: 7px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .alert,
  .timeline-item,
  .setting-row {
    align-items: stretch;
    flex-direction: column;
  }
}
