* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f6f8;
  color: #1f2937;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

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

.sidebar {
  width: 240px;
  min-height: 100vh;
  background: #111827;
  color: white;
  padding: 24px 16px;
  flex-shrink: 0;
}

.sidebar h2 {
  margin: 0 8px 30px;
}

.nav-section {
  margin-bottom: 28px;
}

.nav-title {
  color: #9ca3af;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 8px 8px;
}

.nav-btn {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: #d1d5db;
  text-align: left;
  padding: 11px 12px;
  border-radius: 7px;
  margin-bottom: 3px;
}

.nav-btn:hover,
.nav-btn.active {
  background: #374151;
  color: #fff;
}

.main {
  flex: 1;
  padding: 32px;
  min-width: 0;
}

.app-view {
  max-width: 1500px;
  margin: 0 auto;
}

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

.page-header h1 {
  margin: 0 0 5px;
  font-size: 28px;
}

.muted {
  color: #6b7280;
  margin: 0;
}

.card {
  background: white;
  border-radius: 10px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}

.card h2 {
  margin: 0 0 20px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  background: white;
  color: #111827;
}

input:focus,
select:focus {
  outline: 2px solid rgba(37, 99, 235, .15);
  border-color: #2563eb;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  border: 0;
  border-radius: 7px;
  padding: 10px 15px;
  font-weight: 600;
}

.btn.primary {
  background: #2563eb;
  color: white;
}

.btn.primary:hover {
  background: #1d4ed8;
}

.btn.secondary {
  background: #e5e7eb;
  color: #111827;
}

.btn.secondary:hover {
  background: #d1d5db;
}

.btn.danger {
  background: #dc2626;
  color: white;
}

.btn.danger:hover {
  background: #b91c1c;
}

.btn.small {
  padding: 6px 9px;
  font-size: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 850px;
}

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

th {
  background: #f9fafb;
  color: #374151;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

td {
  font-size: 14px;
}

tr:hover td {
  background: #fafafa;
}

.status {
  margin-top: 12px;
  font-size: 14px;
}

.status.error {
  color: #dc2626;
}

.status.success {
  color: #15803d;
}

.status.info {
  color: #2563eb;
}

.tag {
  display: inline-block;
  padding: 4px 8px;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  font-size: 12px;
}

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

.empty,
.loading {
  padding: 35px;
  text-align: center;
  color: #6b7280;
}

.error-box {
  padding: 15px;
  border-radius: 7px;
  background: #fef2f2;
  color: #b91c1c;
}

/* Journal entries */

.journal-entry {
  border: 1px solid #e5e7eb;
  border-radius: 9px;
  margin-bottom: 14px;
  overflow: hidden;
}

.journal-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 16px;
  background: #f9fafb;
  cursor: pointer;
}

.journal-entry-header:hover {
  background: #f3f4f6;
}

.journal-entry-title {
  font-weight: 700;
  margin-bottom: 5px;
}

.journal-entry-meta {
  color: #6b7280;
  font-size: 13px;
}

.journal-entry-lines {
  display: none;
  padding: 0 16px 16px;
}

.journal-entry.expanded .journal-entry-lines {
  display: block;
}

.journal-line {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) 160px 160px;
  gap: 15px;
  padding: 11px 0;
  border-bottom: 1px solid #f0f0f0;
}

.journal-line.header {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  color: #6b7280;
}

.journal-totals {
  display: flex;
  justify-content: flex-end;
  gap: 35px;
  padding-top: 15px;
  font-weight: 700;
}

/* Mobile */

@media (max-width: 850px) {
  .sidebar {
    width: 190px;
  }

  .main {
    padding: 20px;
  }

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

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

  .journal-line {
    grid-template-columns: 1fr 100px 100px;
  }
}

@media (max-width: 600px) {
  .app {
    display: block;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
  }

  .nav-section {
    margin-bottom: 12px;
  }

  .main {
    padding: 15px;
  }
}
