:root {
  --primary: #004b8d;
  --accent: #0078d4;
  --background: #f3f6f9;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--background);
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--primary);
  color: white;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
}

.brand h1,
.brand p {
  margin: 0;
}

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

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  border: none;
  background: transparent;
  color: white;
  text-align: left;
  padding: 12px 14px;
  font-size: 15px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.14);
}

.content {
  padding: 24px;
  background: var(--background);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.topbar-actions {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: 14px;
  color: var(--primary);
  font-weight: 600;
}

.section-header {
  margin-bottom: 16px;
}

.section-header h3 {
  margin: 0 0 6px;
}

.section-header p {
  margin: 0;
  color: var(--muted);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  min-height: 120px;
}

.card h4 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--muted);
}

.card p {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  overflow-x: auto;
}

.form-panel {
  margin-top: 24px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.form-panel h4 {
  margin: 0 0 16px;
}

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

.form-row label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.form-actions button {
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.form-actions button.secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.form-actions button[type="submit"] {
  background: var(--accent);
  color: white;
}

action-button {
  padding: 8px 12px;
}

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

thead {
  background: #f8fafc;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
}

th {
  color: var(--muted);
  font-weight: 600;
}

tr:hover {
  background: rgba(0, 120, 212, 0.05);
}

.action-button {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  margin-right: 6px;
  cursor: pointer;
  font-size: 13px;
}

.action-button:hover {
  opacity: 0.92;
}

.action-button.delete {
  background: #f97316;
  color: white;
}

.action-button:not(.delete) {
  background: #2563eb;
  color: white;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

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

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

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

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 24px 0;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.aging-chart {
  display: grid;
  gap: 14px;
}

.aging-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 130px;
  gap: 12px;
  align-items: center;
}

.aging-bar-label {
  color: var(--muted);
  font-size: 14px;
}

.aging-bar-track {
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  height: 16px;
}

.aging-bar-fill {
  background: #0f766e;
  height: 100%;
  border-radius: 10px 0 0 10px;
}

.aging-bar-value {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 20px 0;
}

.analysis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
}

.analysis-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 8px;
}

.analysis-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

#bank-upload-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin: 15px 0;
}

#bank-upload-form input[type="file"] {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.upload-btn {
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.upload-btn:hover {
  background: #0066b3;
}

#upload-status {
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
}

#upload-status.success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

#upload-status.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.bank-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-top: 20px;
}

.bank-section h4 {
  margin: 0 0 8px;
  color: var(--text);
}

.bank-section p {
  margin: 0 0 15px;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 700px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

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

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

  #bank-upload-form {
    flex-direction: column;
  }

  #bank-upload-form input[type="file"],
  .upload-btn {
    width: 100%;
  }
}
