:root,
:root[data-theme="light"] {
  --font: Manrope, -apple-system, BlinkMacSystemFont, sans-serif;
  --bg: #f2f2f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --muted-soft: #86868b;
  --surface: #fff;
  --paper: #fff;
  --paper-soft: #e8e8ed;
  --bg-muted: #e8e8ed;
  --ink: #1d1d1f;
  --on-ink: #fff;
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.18);
  --blue: #3475ba;
  --blue-hover: #2b63a0;
  --blue-soft: #eaf2fa;
  --blue-ring: rgba(52, 117, 186, 0.3);
  --blue-hint: #2a5078;
  --accent: #3475ba;
  --black: #1d1d1f;
  --white: #fff;
  --danger-bg: #fdecee;
  --danger: #b42318;
  --danger-border: rgba(180, 35, 24, 0.22);
  --ok-bg: #e8f8ee;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --nav-hover-bg: rgba(10, 10, 10, 0.04);
  --btn-secondary-hover: #f4f6f8;
}

:root[data-theme="dark"] {
  --bg: #000;
  --text: #f5f5f7;
  --muted: #86868b;
  --muted-soft: #6e6e73;
  --surface: #111;
  --paper: #1c1c1e;
  --paper-soft: #1c1c1e;
  --bg-muted: #111;
  --ink: #f5f5f7;
  --on-ink: #000;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);
  --blue: #6ba3d9;
  --blue-hover: #8bb8e3;
  --blue-soft: rgba(91, 155, 212, 0.16);
  --blue-ring: rgba(107, 163, 217, 0.38);
  --blue-hint: #b7d0ea;
  --accent: #6ba3d9;
  --black: #f5f5f7;
  --white: #000;
  --danger-bg: rgba(255, 59, 48, 0.16);
  --danger: #ff8a80;
  --danger-border: rgba(255, 59, 48, 0.28);
  --ok-bg: rgba(52, 199, 89, 0.16);
  --nav-hover-bg: rgba(255, 255, 255, 0.08);
  --btn-secondary-hover: #1c1c1e;
}

* { box-sizing: border-box; }
html { overflow-x: clip; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  height: 40px;
  padding: 0 1.15rem;
  border: 0;
  border-radius: 980px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--blue-hover); text-decoration: none; color: #fff; filter: none; }

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

.btn-black:hover { background: var(--blue-hover); color: #fff; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--btn-secondary-hover); color: var(--text); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease);
}

.theme-toggle:hover {
  background: var(--nav-hover-bg);
}

.theme-toggle:active {
  transform: scale(0.96);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-ring);
}

.theme-ico {
  display: none;
  line-height: 0;
}

html[data-theme="light"] .theme-ico-moon {
  display: inline-flex;
}

html[data-theme="dark"] .theme-ico-sun,
html:not([data-theme="light"]) .theme-ico-sun {
  display: inline-flex;
}

.theme-toggle .icon {
  width: 16px;
  height: 16px;
}

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

.ws-table th {
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.ws-table td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.ws-table tbody tr:has(a[href]) {
  position: relative;
  cursor: pointer;
}
.ws-table tbody tr:has(a[href]):hover td {
  background: var(--nav-hover-bg);
}
.ws-table tbody tr:has(a[href]):hover td:first-child a {
  color: var(--blue);
}
.ws-table tbody tr:has(a[href]):hover td:first-child a .ws-ico {
  opacity: 0.8;
}
.ws-table tbody tr > td:first-child a[href]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.ws-table a { color: inherit; text-decoration: none; font-weight: 650; display: inline-flex; align-items: center; gap: 0.4rem; }
.ws-table a .ws-ico { width: 14px; height: 14px; opacity: 0.45; }
.ws-table a:hover { color: var(--blue); }
.ws-table a:hover .ws-ico { opacity: 0.8; }

.ws-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-muted);
  color: var(--muted);
}

.ws-badge.draft { background: var(--paper-soft); }
.ws-badge.issued { background: var(--blue-soft); color: var(--blue-hint); }
.ws-badge.proforma { background: var(--blue-soft); color: var(--blue-hint); }
.ws-badge.paid { background: var(--ok-bg); color: #0f7a43; }
.ws-badge.overdue, .ws-badge.cancelled { background: var(--danger-bg); }

.ws-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ws-metric {
  display: block;
  padding: 1.25rem 1.3rem;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--ws-shadow, none);
}

.ws-metric span { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--muted); }
.ws-metric span .ws-ico { width: 13px; height: 13px; opacity: 0.72; }
.ws-metric strong { display: block; margin-top: 0.35rem; font-size: 1.35rem; letter-spacing: -0.04em; }

.ws-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

@media (max-width: 980px) {
  .ws-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .ws-metric {
    padding: 0.8rem 0.7rem;
  }
  .ws-metric strong {
    font-size: 1.05rem;
  }
}

@media (max-width: 360px) {
  .ws-metrics {
    grid-template-columns: 1fr;
  }
}
