:root {
  --indigo: #3730a3;
  --indigo-2: #4f46e5;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #dbeafe;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; background: var(--bg); color: var(--text); }

.wrap { min-height: 100vh; }
.header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: #fff; border-bottom: 1px solid #d1d5db; }
.brand h1 { margin: 0; font-size: 34px; color: #1e1b4b; }
.brand p { margin: 2px 0 0; color: var(--muted); }
.api { font-weight: 700; color: #7c3aed; }

.nav { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 18px; background: #fff; border-bottom: 1px solid #e2e8f0; }
.nav button { border: 0; border-radius: 8px; padding: 9px 14px; background: #e5e7eb; color: #1f2937; font-weight: 700; cursor: pointer; }
.nav button.active { background: var(--indigo); color: #fff; }

.page { padding: 16px; }
.grid { display: grid; gap: 14px; }

.billing-layout { display: grid; grid-template-columns: 1fr 410px; gap: 14px; }
.card { background: var(--card); border: 1px solid #dbeafe; border-radius: 12px; }
.card h3 { margin: 0; padding: 14px 14px 0; }
.content { padding: 14px; }

.cats { display: flex; gap: 8px; overflow: auto; margin-bottom: 10px; }
.cats button { border: 1px solid #cbd5e1; border-radius: 999px; padding: 8px 12px; background: #fff; font-weight: 700; cursor: pointer; white-space: nowrap; }
.cats button.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }

.search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #cbd5e1; margin-bottom: 12px; }

.products { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 10px; }
.product { border: 0; border-radius: 14px; background: linear-gradient(135deg, #3b82f6, #4f46e5); color: #fff; padding: 12px; cursor: pointer; }
.product .icon { font-size: 40px; text-align: center; margin-bottom: 8px; }
.product .name { font-size: 14px; font-weight: 700; min-height: 34px; text-align: center; }
.product .price { font-size: 18px; font-weight: 800; text-align: center; }

.cart-head { background: linear-gradient(135deg, #3b82f6, #4f46e5); color: #fff; border-radius: 12px 12px 0 0; padding: 12px 14px; font-weight: 800; }
.cart-body { padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid #e5e7eb; padding: 9px; font-size: 13px; }
th { background: #f8fafc; text-align: left; }

.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button { width: 24px; height: 24px; border: 0; border-radius: 999px; cursor: pointer; }

.form { padding: 12px; background: #f8fafc; border-top: 1px solid #e2e8f0; }
.row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.row input, .row select { width: 100%; padding: 9px; border: 1px solid #cbd5e1; border-radius: 8px; }
.total { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px; font-weight: 800; display: flex; justify-content: space-between; margin-top: 8px; }
.save-btn { margin: 12px; width: calc(100% - 24px); border: 0; border-radius: 10px; padding: 14px; background: linear-gradient(135deg, #3b82f6, #4f46e5); color: #fff; font-size: 16px; font-weight: 800; cursor: pointer; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: #fff; border: 1px solid #dbeafe; border-radius: 10px; padding: 12px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 800; }

.status { padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.st-pending { background: #fef3c7; color: #92400e; }
.st-ready { background: #e0e7ff; color: #3730a3; }
.st-paid { background: #dcfce7; color: #166534; }

.btn { border: 0; border-radius: 8px; padding: 8px 10px; font-weight: 700; cursor: pointer; }
.btn-blue { background: #dbeafe; color: #1d4ed8; }
.btn-green { background: #dcfce7; color: #166534; }
.btn-red { background: #fee2e2; color: #991b1b; }
.btn-indigo { background: var(--indigo); color: #fff; }

.service-form { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 8px; }

.expense-progress { margin-top: 8px; }
.bar { height: 10px; border-radius: 999px; background: #e5e7eb; }
.bar > span { display: block; height: 100%; background: var(--indigo); border-radius: 999px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 999; }
.modal { width: min(420px, 92vw); background: #fff; border-radius: 14px; padding: 18px; }

/* Tablet */
@media (max-width: 1100px) {
  .billing-layout { grid-template-columns: 1fr; }
  .products { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .service-form { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .kpis { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}

/* Mobile */
@media (max-width: 680px) {
  .header { padding: 10px; }
  .brand h1 { font-size: 24px; }
  .brand p { display: none; }
  .nav { padding: 8px; }
  .nav button { padding: 8px 10px; font-size: 12px; }
  .page { padding: 10px; }
  .products { grid-template-columns: repeat(2, minmax(110px, 1fr)); }
  .row { grid-template-columns: 1fr; }
  .service-form { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  th, td { font-size: 12px; padding: 7px; }
}
