:root {
  --ink: #172033;
  --muted: #667085;
  --line: #dce3eb;
  --soft: #f4f7fa;
  --panel: #ffffff;
  --brand: #075985;
  --brand-dark: #063a5f;
  --accent: #f28c28;
  --ok: #138a64;
  --warn: #b42318;
  --pending: #946200;
  --shadow: 0 14px 34px rgba(15, 39, 68, .10);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

body[dir="rtl"] {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

a { color: inherit; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar-inner,
.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.brand small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill,
.link-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.shell { padding: 34px 0 48px; }

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

.eyebrow {
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
}

h1 {
  margin: 6px 0 8px;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.05;
  color: var(--brand-dark);
}

.lead {
  margin: 0;
  max-width: 660px;
  color: var(--muted);
  font-size: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 24px;
  align-items: start;
}

.panel,
.invoice-row,
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel { padding: 24px; }

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
}

.tab {
  border: 1px solid var(--line);
  border-bottom: 3px solid transparent;
  background: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 800;
  color: var(--muted);
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--accent);
}

.field { margin-bottom: 18px; }

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
  color: var(--brand-dark);
}

.input-wrap { position: relative; }

.prefix {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 800;
  border-inline-end: 1px solid var(--line);
  padding-inline-end: 10px;
}

input[type="text"],
input[type="tel"],
input[type="search"] {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
}

.has-prefix { padding-inline-start: 76px !important; }

input:focus {
  outline: 3px solid rgba(7, 89, 133, .16);
  border-color: var(--brand);
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.btn {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #111827;
}

.btn-secondary {
  background: var(--brand);
  color: #fff;
}

.btn-muted {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--line);
}

.btn-danger {
  background: var(--warn);
  color: #fff;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.full { width: 100%; }

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.notice.error {
  border-color: rgba(180, 35, 24, .28);
  background: #fff4f2;
  color: var(--warn);
}

.notice.success {
  border-color: rgba(19, 138, 100, .25);
  background: #f0fbf7;
  color: var(--ok);
}

.side-list {
  display: grid;
  gap: 12px;
  color: var(--muted);
}

.side-item {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.side-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat { padding: 18px; box-shadow: none; }
.stat strong { display: block; font-size: 26px; color: var(--brand-dark); }
.stat span { color: var(--muted); font-weight: 700; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  margin-bottom: 18px;
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.filter {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}

.filter.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.invoice-list { display: grid; gap: 12px; }

.invoice-row {
  box-shadow: none;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(120px, .55fr)) auto;
  gap: 16px;
  align-items: center;
}

.invoice-title { font-weight: 900; color: var(--brand-dark); }
.meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.amount { font-weight: 900; color: var(--ink); }

.badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 900;
  background: #eef4ff;
  color: var(--brand);
}

.badge.paid { background: #e8f7f1; color: var(--ok); }
.badge.due { background: #fff3e6; color: var(--pending); }
.badge.failed { background: #fff4f2; color: var(--warn); }

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.empty {
  text-align: center;
  padding: 42px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.print-sheet {
  width: min(820px, calc(100% - 32px));
  margin: 24px auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 24px;
}

.invoice-table th,
.invoice-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: inherit;
}

@media (max-width: 860px) {
  .grid-2,
  .stats,
  .toolbar {
    grid-template-columns: 1fr;
  }

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

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

  .row-actions {
    justify-content: stretch;
  }

  .row-actions .btn {
    flex: 1;
  }
}

@media print {
  body { background: #fff; }
  .topbar,
  .no-print { display: none !important; }
  .print-sheet {
    width: 100%;
    margin: 0;
    border: 0;
    box-shadow: none;
  }
}
