/* Pairvi — professional legal calculator */
:root {
  --ink: #0f2744;
  --ink-soft: #1a3a5c;
  --accent: #1a6b7a;
  --accent-soft: #e6f2f4;
  --bg: #f3f6f9;
  --bg-warm: #eef3f7;
  --surface: #ffffff;
  --line: #d5e0ea;
  --text: #1c2b3a;
  --muted: #5c6f82;
  --ok: #1f7a4d;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(15, 39, 68, 0.08);
  --radius: 14px;
  --max: 1120px;
  --nav-h: 64px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(26, 107, 122, 0.12), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(15, 39, 68, 0.08), transparent 50%),
    var(--bg);
  line-height: 1.55;
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.container {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  backdrop-filter: blur(12px);
  background: rgba(243, 246, 249, 0.88);
  border-bottom: 1px solid rgba(213, 224, 234, 0.9);
}

.nav {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  box-shadow: 0 4px 12px rgba(15, 39, 68, 0.18);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
  line-height: 1.1;
}

.brand-tag {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-links a,
.nav-links button.nav-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
}

.nav-links a:hover,
.nav-links button.nav-link:hover,
.nav-links a.active,
.nav-links button.nav-link.active {
  color: var(--ink);
  background: rgba(15, 39, 68, 0.06);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn,
.menu-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.menu-toggle {
  display: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 11px;
  border: 1px solid transparent;
  padding: 0.75rem 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 39, 68, 0.2);
}

.btn-primary:hover {
  background: var(--ink-soft);
}

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

.btn-outline {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 0.8rem;
  font-size: 0.88rem;
}

/* Views */
.view {
  display: none;
  padding: 1.5rem 0 4rem;
  animation: fadeIn 0.35s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2rem;
  align-items: center;
  padding: 2.5rem 0 1.5rem;
}

.hero-copy h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.5vw, 3.4rem);
  line-height: 1.12;
  color: var(--ink);
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
  max-width: 14ch;
}

.hero-copy p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 48ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-panel {
  background: linear-gradient(160deg, var(--ink) 0%, #163a57 55%, var(--accent) 140%);
  color: #fff;
  border-radius: 22px;
  padding: 1.6rem;
  min-height: 280px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-panel h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  margin: 0 0 0.5rem;
}

.hero-panel p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1.4rem;
}

.stat {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 0.75rem;
}

.stat strong {
  display: block;
  font-size: 1.15rem;
}

.stat span {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Sections */
.section {
  margin-top: 2.5rem;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0;
  color: var(--ink);
}

.section-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 4px 16px rgba(15, 39, 68, 0.04);
}

.feature-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  margin-bottom: 0.85rem;
}

.feature h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  color: var(--ink);
}

.feature p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

/* Ad slots (empty for now) */
.ad-slot {
  display: none; /* set to flex/grid when ads enabled */
  min-height: 90px;
  margin: 1.25rem 0;
  border: 1px dashed var(--line);
  border-radius: 12px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.5);
}

.ad-slot[data-ads-enabled="true"] {
  display: flex;
}

/* Forms */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fafcfe, #fff);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--ink);
}

.panel-body {
  padding: 1.25rem;
}

.calc-layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1.25rem;
  align-items: start;
}

.form-section {
  margin-bottom: 1.4rem;
}

.form-section h3 {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.72rem 0.85rem;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 107, 122, 0.14);
}

.field .hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.vs-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.6rem;
  align-items: end;
}

.vs-badge {
  margin-bottom: 0.55rem;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: var(--bg-warm);
  border: 1px solid var(--line);
  font-weight: 800;
  color: var(--ink);
  font-size: 0.85rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 0.5rem;
}

/* Results */
.results-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}

.results-empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.summary-table th,
.summary-table td {
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.summary-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.summary-table td.num,
.summary-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-table tr.current {
  background: var(--accent-soft);
}

.summary-table tr.total {
  font-weight: 800;
  background: rgba(15, 39, 68, 0.04);
}

.amount-box {
  margin-top: 1rem;
  display: grid;
  gap: 0.55rem;
}

.amount-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.93rem;
}

.amount-row.remain {
  margin-top: 0.25rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--ink), var(--accent));
  color: #fff;
  font-weight: 750;
}

/* Payments */
.payment-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.payment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
}

.payment-item button {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-weight: 700;
}

/* Saved list */
.saved-list {
  display: grid;
  gap: 0.75rem;
}

.saved-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.saved-item:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(15, 39, 68, 0.06);
}

.saved-item h3 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  color: var(--ink);
}

.saved-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.saved-actions {
  display: flex;
  gap: 0.4rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

/* Settings */
.settings-grid {
  display: grid;
  gap: 1rem;
  max-width: 640px;
}

.setting-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.15rem;
}

.setting-card h3 {
  margin: 0 0 0.35rem;
  color: var(--ink);
}

.setting-card p {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.25rem;
  gap: 0.2rem;
  flex-wrap: wrap;
}

.seg button {
  border: 0;
  background: transparent;
  padding: 0.55rem 0.9rem;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
}

.seg button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(15, 39, 68, 0.08);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1.1rem;
  border-radius: 12px;
  z-index: 100;
  opacity: 0;
  transition: 0.25s ease;
  max-width: min(92vw, 420px);
  text-align: center;
  font-size: 0.92rem;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.site-footer .credit {
  color: var(--ink-soft);
  font-weight: 650;
}

.offline-badge {
  display: none;
  position: fixed;
  top: calc(var(--nav-h) + 0.5rem);
  right: 1rem;
  z-index: 60;
  background: #fff4e5;
  color: #8a4b00;
  border: 1px solid #f0c889;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
}

body.is-offline .offline-badge {
  display: inline-flex;
}

/* Mobile */
@media (max-width: 900px) {
  .hero,
  .calc-layout,
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy h1 {
    max-width: none;
  }

  .menu-toggle {
    display: grid;
  }

  .nav-links {
    position: fixed;
    inset: var(--nav-h) 0 auto 0;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid var(--line);
    padding: 0.75rem;
    display: none;
    flex-direction: column;
    align-items: stretch;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a,
  .nav-links button.nav-link {
    text-align: left;
    padding: 0.85rem 0.9rem;
  }

  .field-grid,
  .vs-row {
    grid-template-columns: 1fr;
  }

  .vs-badge {
    width: fit-content;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .brand-tag {
    display: none;
  }

  .panel-body,
  .panel-head {
    padding: 1rem;
  }

  .form-actions .btn {
    flex: 1 1 100%;
  }
}

/* Print report */
@media print {
  .site-header,
  .site-footer,
  .ad-slot,
  .form-actions,
  .nav-actions,
  .offline-badge,
  #view-home,
  #view-saved,
  #view-settings {
    display: none !important;
  }

  #view-calculator {
    display: block !important;
  }

  body {
    background: #fff;
  }

  .panel {
    box-shadow: none;
    border: 0;
  }
}

[dir="rtl"] .hero-copy h1,
[dir="rtl"] .section-head h2,
[dir="rtl"] .panel-head h2 {
  letter-spacing: 0;
}

[dir="rtl"] .summary-table td.num,
[dir="rtl"] .summary-table th.num {
  text-align: left;
}
