*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f172a;
  color: #e5e7eb;
}

.app-header {
  padding: 0.75rem 1rem;
  background: linear-gradient(90deg, #0f766e, #22c55e);
  color: #ecfdf5;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 1.3rem;
}

.tab-bar {
  display: flex;
  border-bottom: 1px solid #1f2937;
  background: #020617;
}

.tab-button {
  flex: 1;
  padding: 0.65rem 0.25rem;
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 0.9rem;
  cursor: pointer;
}

.tab-button.active {
  color: #f9fafb;
  border-bottom: 2px solid #22c55e;
}

.app-main {
  padding: 0.75rem;
  max-width: 960px;
  margin: 0 auto;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.card {
  background: #020617;
  border-radius: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #1e293b;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45);
}

.card-title {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}

.card-value {
  font-size: 1.2rem;
  font-weight: 600;
  color: #ecfeff;
}

.form-card,
.list-card {
  background: #020617;
  border-radius: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #1e293b;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45);
  margin-bottom: 0.75rem;
}

.form-card h2,
.list-header h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}

.form-row.small {
  margin-bottom: 0.25rem;
}

.form-row label {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.2rem;
}

input,
select,
textarea {
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.9rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #22c55e;
  outline-offset: 1px;
  border-color: #22c55e;
}

.segmented {
  display: inline-flex;
  background-color: #020617;
  border-radius: 999px;
  border: 1px solid #1f2937;
  overflow: hidden;
}

.segmented label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: #e5e7eb;
  user-select: none;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  transition: background-color 150ms ease, color 150ms ease;
}

.segmented input:checked + span {
  background-color: #22c55e;
  color: #022c22;
  font-weight: 600;
}

.btn-primary,
.btn-secondary {
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  margin-right: 0.35rem;
}

.btn-primary {
  background: linear-gradient(90deg, #22c55e, #0ea5e9);
  color: #022c22;
  font-weight: 600;
}

.btn-secondary {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #1f2937;
}

.btn-primary:active,
.btn-secondary:active {
  transform: translateY(1px);
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.5rem 0;
  border-bottom: 1px solid #0f172a;
}

.list-item:last-child {
  border-bottom: none;
}

.list-main {
  flex: 1;
  min-width: 0;
}

.list-title {
  font-size: 0.9rem;
  margin-bottom: 0.1rem;
}

.list-sub {
  font-size: 0.7rem;
  color: #9ca3af;
}

.list-meta {
  text-align: right;
  margin-left: 0.5rem;
}

.amount-in {
  color: #4ade80;
}

.amount-out {
  color: #f97373;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  border-radius: 999px;
  background: #111827;
  color: #e5e7eb;
  margin-left: 0.25rem;
}

.badge-pill {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.badge-soft {
  background: rgba(148, 163, 184, 0.2);
}

.customer-actions {
  margin-top: 0.25rem;
}

.icon-button {
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  padding: 0.2rem;
  font-size: 1.1rem;
}

.icon-button:hover {
  color: #e5e7eb;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}

.form-inline .form-row {
  flex: 1 1 40%;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
}

.modal-content {
  position: relative;
  background: #020617;
  border-radius: 0.75rem;
  border: 1px solid #1e293b;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
  padding: 0.75rem;
  width: min(100% - 1.5rem, 720px);
  max-height: calc(100% - 3rem);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.modal-body {
  overflow: auto;
}

.ledger-summary {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}

.ledger-table-wrapper {
  overflow-x: auto;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.ledger-table th,
.ledger-table td {
  border-bottom: 1px solid #111827;
  padding: 0.25rem 0.4rem;
  text-align: left;
}

.ledger-table th {
  position: sticky;
  top: 0;
  background: #020617;
}

.ledger-table tbody tr:nth-child(2n) {
  background: rgba(15, 23, 42, 0.6);
}

@media (min-width: 720px) {
  .app-main {
    padding: 1rem;
  }

  .form-card,
  .list-card {
    padding: 1rem;
  }
}

