@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-light: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-light: #f1f5f9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.09);
  --orange: #d97706;
  --orange-soft: rgba(217, 119, 6, 0.09);
  --red: #e11d48;
  --red-soft: rgba(225, 29, 72, 0.09);
  --navy: #0f172a;
  --navy-surface: #1e293b;
  --radius: 16px;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 12px 36px -4px rgba(15, 23, 42, 0.1), 0 4px 12px -2px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

/* Sidebar Navigation */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 256px;
  padding: 28px 20px 24px;
  display: flex;
  flex-direction: column;
  background: var(--navy);
  color: #cbd5e1;
  z-index: 20;
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
  color: #fff;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  color: #ffffff;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

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

.brand strong {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand small {
  color: #94a3b8;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.16s ease;
}

.nav-link svg {
  width: 17px;
  height: 17px;
  opacity: 0.8;
  transition: opacity 0.16s ease;
}

.nav-link:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.07);
}

.nav-link:hover svg {
  opacity: 1;
}

.nav-link.active {
  color: #ffffff;
  background: rgba(59, 130, 246, 0.18);
  font-weight: 600;
  box-shadow: inset 3px 0 0 #3b82f6;
}

.nav-link.active svg {
  opacity: 1;
  color: #60a5fa;
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.source-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #94a3b8;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.16);
}

.source-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
  font-size: 12px;
  transition: background 0.15s ease;
}

.source-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.source-link svg {
  width: 14px;
  height: 14px;
}

.retrieved {
  margin: 12px 0 0;
  color: #64748b;
  font-size: 11px;
}

.mobile-topbar {
  display: none;
}

.mobile-toggle,
.sidebar-close {
  display: none;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.mobile-topbar-title {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Main Layout */
.main {
  margin-left: 256px;
  padding: 40px 48px 32px;
  max-width: 1560px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.03em;
  color: var(--ink);
}

h1 {
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 800;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
  font-weight: 700;
}

h3 {
  font-size: 15px;
  font-weight: 600;
}

.subtitle,
.panel-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

.btn-ghost {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.btn-ghost:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-outline {
  border-color: #cbd5e1;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-small {
  padding: 7px 12px;
  border-color: var(--line);
  background: var(--panel);
  font-size: 12px;
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.danger-btn {
  color: var(--red);
  border-color: #fecaca;
}

.danger-btn:hover {
  background: #fff1f2;
  border-color: #fda4af;
  color: #be123c;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi {
  position: relative;
  padding: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.kpi::after {
  content: "";
  position: absolute;
  inset: auto -20px -50px auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--kpi-soft, rgba(37, 99, 235, 0.08));
  pointer-events: none;
}

.kpi-revenue {
  --kpi-color: var(--green);
  --kpi-soft: var(--green-soft);
  border-top: 3px solid var(--green);
}

.kpi-expense {
  --kpi-color: var(--orange);
  --kpi-soft: var(--orange-soft);
  border-top: 3px solid var(--orange);
}

.kpi-profit {
  --kpi-color: var(--accent);
  --kpi-soft: var(--accent-soft);
  border-top: 3px solid var(--accent);
}

.kpi-cash {
  --kpi-color: #7c5cff;
  --kpi-soft: rgba(124, 92, 255, 0.09);
  border-top: 3px solid #7c5cff;
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.kpi-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--kpi-color);
  background: var(--kpi-soft);
}

.kpi-icon svg {
  width: 20px;
  height: 20px;
}

.kpi-tag {
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--kpi-soft);
  color: var(--kpi-color);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.kpi-tag:empty {
  display: none;
}

.kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.kpi-value {
  position: relative;
  z-index: 1;
  margin: 6px 0 8px;
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.kpi-note {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #94a3b8;
  font-size: 11.5px;
}

/* Panels */
.panel {
  min-width: 0;
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  scroll-margin-top: 24px;
}

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

.panel-head.compact {
  align-items: center;
  margin-bottom: 16px;
}

.panel-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

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

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.swatch.revenue {
  background: var(--green);
}

.swatch.expense {
  background: var(--orange);
}

.swatch.profit {
  background: var(--accent);
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chart-empty {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  padding: 48px 12px;
  text-align: center;
}

.chart-wrap svg {
  display: block;
  min-width: 760px;
  width: 100%;
  height: auto;
}

.chart-wrap svg text {
  fill: #64748b;
  font-size: 11px;
  font-family: inherit;
  stroke: none;
}

.chart-grid {
  stroke: #f1f5f9;
  stroke-width: 1;
}

.chart-zero {
  stroke: #cbd5e1;
  stroke-width: 1.2;
}

.chart-bar {
  rx: 4;
  transition: opacity 0.15s ease;
}

.chart-wrap svg:hover .chart-bar,
.chart-wrap svg:hover .chart-line {
  opacity: 0.72;
}

.chart-wrap svg .chart-bar:hover,
.chart-wrap svg .chart-point:hover {
  opacity: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-point {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2.5;
}

/* Two Column Layout */
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 20px;
}

.two-col .panel {
  margin-bottom: 24px;
}

.rank-list {
  display: grid;
  gap: 13px;
}

.rank-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.rank-number {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.rank-info {
  min-width: 0;
}

.rank-name {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-bar {
  height: 6px;
  margin-top: 6px;
  border-radius: 99px;
  background: #f1f5f9;
}

.rank-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f59e0b, #ea580c);
}

.rank-value {
  text-align: right;
  font-size: 12.5px;
  font-weight: 700;
}

.rank-percent {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
}

/* Composition Donut */
.composition {
  display: flex;
  align-items: center;
  gap: 24px;
}

.donut {
  position: relative;
  flex: 0 0 140px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--panel);
}

.donut-label {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  text-align: center;
}

.donut-label strong {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.donut-label span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.composition-legend {
  display: grid;
  gap: 12px;
  flex: 1;
  font-size: 12.5px;
}

.composition-legend div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.composition-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.composition-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.insight {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #f0f7ff;
  border: 1px solid #dbeafe;
  color: #1e40af;
  font-size: 12.5px;
  line-height: 1.6;
}

.insight strong {
  color: #0f172a;
}

/* Form Styles & Redesign */
.journal-form {
  display: grid;
  gap: 16px;
}

.form-card-section {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.form-section-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.section-badge {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.section-badge.inventory-badge {
  background: #fef3c7;
  color: #b45309;
}

.title-with-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-optional {
  padding: 2px 8px;
  border-radius: 99px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.form-section-sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.journal-fields-grid {
  display: grid;
  grid-template-columns: 140px minmax(200px, 1.8fr) repeat(2, minmax(180px, 1.2fr)) 160px;
  gap: 12px;
}

.inventory-box {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.inventory-fields-grid {
  display: grid;
  grid-template-columns: 1.5fr 1.2fr 1fr;
  gap: 12px;
}

.form-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 4px;
}

.btn-save {
  padding: 11px 22px;
  font-size: 13.5px;
}

.form-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.form-status:empty {
  display: none;
}

.form-status.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.form-status.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.form-status.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Fields & Inputs */
.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(130px, 1fr));
  gap: 12px;
}

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

.field span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Data Tables */
.table-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #f8fafd;
}

.data-table .right {
  text-align: right;
}

.data-table .center {
  text-align: center;
}

.data-table td.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table td.date {
  color: var(--muted);
  white-space: nowrap;
}

.data-table td.account {
  color: var(--ink-light);
  white-space: nowrap;
}

.code-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #475569;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  margin-right: 2px;
}

.num-debet {
  color: var(--green);
  font-weight: 600;
}

.num-kredit {
  color: #2563eb;
  font-weight: 600;
}

.delete-tx-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.delete-tx-btn:hover {
  color: var(--red);
  background: #fef2f2;
  border-color: #fecaca;
  transform: translateY(-1px);
}

.delete-tx-btn svg {
  width: 13px;
  height: 13px;
}

.worksheet-table {
  min-width: 980px;
}

.worksheet-table thead tr:first-child th {
  text-align: center;
}

.worksheet-table thead tr:first-child th:nth-child(-n + 4) {
  text-align: left;
}

.worksheet-table td.pos {
  color: var(--muted);
  white-space: nowrap;
}

.worksheet-table .closing-row td {
  background: #fffbeb;
  font-weight: 600;
  color: #b45309;
}

.empty-row td {
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

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

.balance-title {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.total-row td {
  border-top: 2px solid var(--line);
  background: #f8fafc;
  font-weight: 700;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--navy);
  color: #ffffff;
  box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  font-weight: 500;
  animation: toast-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.error {
  background: #b91c1c;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px 0;
  color: #94a3b8;
  font-size: 11.5px;
}

.footer a {
  color: var(--accent);
  font-weight: 600;
}

.footer a:hover {
  text-decoration: underline;
}

.validation-banner {
  margin-bottom: 22px;
  padding: 14px 18px;
  border: 1px solid rgba(226, 86, 86, 0.35);
  border-radius: var(--radius);
  background: rgba(226, 86, 86, 0.08);
  color: #9f2d2d;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.extra-lines {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.extra-line {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 110px minmax(120px, 1fr) 42px;
  gap: 10px;
  align-items: center;
}

.add-line-btn {
  margin-top: 14px;
}

@media (max-width: 820px) {
  .extra-line {
    grid-template-columns: 1fr 1fr;
  }

  .extra-line .extra-remove {
    justify-self: end;
  }
}

/* Responsive Media Queries */
@media (max-width: 1280px) {
  .journal-fields-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1180px) {
  .main {
    padding: 32px 28px 24px;
  }

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

  .two-col {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  body.nav-open {
    overflow: hidden;
  }

  .mobile-topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 30;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 16px;
    background: var(--navy);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.2);
  }

  body.nav-open .mobile-topbar {
    z-index: 18;
  }

  .mobile-toggle {
    display: grid;
  }

  .sidebar-close {
    display: grid;
    position: absolute;
    top: 20px;
    right: 16px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
  }

  .sidebar {
    width: min(280px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.3);
    overscroll-behavior: contain;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    overscroll-behavior: contain;
  }

  .sidebar-backdrop.open {
    opacity: 1;
    visibility: visible;
  }

  .main {
    margin-left: 0;
    padding: 24px 16px 24px;
  }

  .panel {
    scroll-margin-top: 72px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .header-actions .btn {
    flex: 1 1 auto;
  }

  .panel-head {
    flex-wrap: wrap;
    gap: 12px;
  }

  .panel-head > div {
    min-width: 0;
  }

  .panel-head > .panel-meta,
  #depSummary {
    max-width: 100%;
    text-align: left;
  }

  input,
  select,
  textarea {
    font-size: 15px;
  }

  .footer {
    flex-wrap: wrap;
  }

  .balance-grid {
    grid-template-columns: 1fr;
  }

  .inventory-fields-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .kpi-grid,
  .filters,
  .journal-fields-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .kpi {
    padding: 18px;
  }

  .composition {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-summary {
    flex-direction: column;
    gap: 4px;
  }

  .data-table th,
  .data-table td {
    padding: 9px 10px;
  }

  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .sidebar-backdrop,
  .mobile-topbar,
  .mobile-toggle,
  .header-actions,
  .filters,
  .journal-form,
  .pagination,
  #exportBtn,
  .footer a,
  .toast-container,
  .delete-tx-btn {
    display: none !important;
  }

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

  .panel,
  .kpi {
    box-shadow: none;
    border: 1px solid #e2e8f0;
    break-inside: avoid;
  }
}
