:root {
  --color-white: #ffffff;
  --color-black: #0a0a0a;
  --color-cream: #faf8f3;
  --color-gray-50: #f6f5f1;
  --color-gray-100: #ebe8df;
  --color-gray-300: #c9c3b5;
  --color-gray-700: #4d4a43;
  --color-gray-900: #1f1d19;
  --color-gold: #d4af37;
  --color-gold-dark: #a8884a;
  --font-title: "Cormorant Garamond", Georgia, serif;
  --font-body: "Inter", Arial, sans-serif;
  --container: 1280px;
  --container-narrow: 960px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 14px 40px rgba(10, 10, 10, 0.06);
  --shadow-hover: 0 18px 50px rgba(10, 10, 10, 0.1);
  --transition: 180ms ease;
  --space-section: clamp(4rem, 7vw, 7rem);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-cream);
  color: var(--color-black);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0;
}

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

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

.container,
.container-narrow {
  margin-inline: auto;
  padding-inline: 1.5rem;
  width: 100%;
}

.container {
  max-width: var(--container);
}

.container-narrow {
  max-width: var(--container-narrow);
}

.site-header {
  align-items: center;
  backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--color-gray-100);
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  min-height: 78px;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  align-items: center;
  display: inline-flex;
  gap: 0.75rem;
  font-weight: 800;
}

.brand img {
  height: 42px;
  width: 42px;
}

.main-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: flex-end;
}

.main-nav a {
  color: var(--color-gray-700);
  font-size: 0.92rem;
  font-weight: 700;
}

.main-nav a:hover {
  color: var(--color-black);
}

.menu-toggle {
  background: var(--color-black);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-white);
  cursor: pointer;
  display: none;
  font: inherit;
  font-weight: 800;
  min-height: 40px;
  padding: 0 0.95rem;
}

.page-header {
  background: linear-gradient(180deg, var(--color-white), var(--color-cream));
  border-bottom: 1px solid var(--color-gray-100);
  padding: clamp(2.25rem, 4vw, 3.5rem) 0;
  text-align: center;
}

.eyebrow {
  color: var(--color-gold-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin: 0 0 0.9rem;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--color-black);
  font-family: var(--font-title);
  font-weight: 700;
  line-height: 1.05;
  margin: 0;
}

h1 {
  font-size: clamp(2.15rem, 4vw, 3.6rem);
}

h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.card h2 {
  font-size: clamp(1.65rem, 3vw, 2.35rem);
}

h3 {
  font-size: 1.55rem;
}

.page-header p:not(.eyebrow) {
  color: var(--color-gray-700);
  font-size: 1.08rem;
  margin: 1rem auto 0;
  max-width: 720px;
}

.section {
  padding: var(--space-section) 0;
}

.grid {
  display: grid;
  gap: 1.25rem;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.app-shell {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 260px 1fr;
}

.app-shell-full {
  grid-template-columns: 1fr;
}

.sidebar {
  align-self: start;
  background: var(--color-white);
  border: 1px solid var(--color-gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.35rem;
  padding: 0.8rem;
  position: sticky;
  top: 96px;
}

.sidebar a {
  border-radius: var(--radius-sm);
  color: var(--color-gray-700);
  font-weight: 800;
  padding: 0.8rem 0.9rem;
}

.sidebar a:hover {
  background: var(--color-cream);
  color: var(--color-black);
}

.card {
  background: var(--color-white);
  border: 1px solid var(--color-gray-100);
  border-top: 3px solid var(--color-gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.card:hover {
  border-color: var(--color-gray-300);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-muted {
  background: var(--color-gray-50);
}

.hero-card {
  align-items: end;
  background:
    linear-gradient(90deg, rgba(10, 10, 10, 0.78), rgba(10, 10, 10, 0.18)),
    url("../img/logo.png") right 4rem center / 240px no-repeat,
    var(--color-black);
  color: var(--color-white);
  min-height: 390px;
  padding: clamp(2rem, 5vw, 4rem);
}

.hero-card h1,
.hero-card p {
  color: var(--color-white);
  max-width: 740px;
}

.hero-card p {
  opacity: 0.86;
}

.btn {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font-body);
  font-weight: 800;
  justify-content: center;
  min-height: 44px;
  padding: 0 1.05rem;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

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

.btn-primary {
  background: var(--color-black);
  color: var(--color-white);
}

.btn-outline {
  background: transparent;
  border-color: var(--color-gray-300);
  color: var(--color-black);
}

.btn-link {
  color: var(--color-gold-dark);
  font-weight: 800;
  padding: 0;
}

.btn-small {
  min-height: 36px;
  padding: 0 0.8rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.badge,
.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.35rem 0.7rem;
  text-transform: uppercase;
}

[data-status="active"],
.status-active,
.status-validated,
.status-paid {
  background: #edf8ef;
  color: #1e6b34;
}

[data-status="pending"],
.status-pending,
.status-new {
  background: #fff6df;
  color: #855d0c;
}

[data-status="urgent"],
.status-urgent,
.status-refused {
  background: #fdecec;
  color: #a13434;
}

[data-status="read"],
.status-read,
.status-archived,
.status-inactive,
.status-closed {
  background: #eef0f2;
  color: #4d5560;
}

.stats {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.card.stat {
  align-content: center;
  min-height: 112px;
  padding: 0.95rem 1.05rem;
}

.stat strong {
  display: block;
  font-family: var(--font-title);
  font-size: clamp(1.65rem, 2.1vw, 2rem);
  line-height: 1;
}

.stat > span {
  color: var(--color-gray-700);
  font-size: 0.9rem;
  font-weight: 700;
}

.stat strong .currency {
  color: var(--color-gray-700);
  font-family: var(--font-body);
  font-size: 0.42em;
  font-weight: 900;
  letter-spacing: 0.04em;
  vertical-align: 0.18em;
}

.card-heading {
  align-items: start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.card-heading p {
  color: var(--color-gray-700);
  margin: 0.15rem 0 0;
}

.sync-status {
  align-items: center;
  background: #edf8ef;
  border: 1px solid #d7eadb;
  border-radius: var(--radius-sm);
  color: #1e6b34;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
}

.sync-status strong {
  font-size: 0.82rem;
  text-transform: uppercase;
}

.sync-status span {
  color: var(--color-gray-700);
  font-size: 0.9rem;
}

.provider-box {
  border: 1px solid var(--color-gray-100);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
}

.provider-box span,
.provider-box p {
  color: var(--color-gray-700);
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.owner-year-section {
  margin-top: 0.55rem;
}

.owner-year-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin: 0.05rem auto 0.45rem;
  max-width: 680px;
}

.owner-year-tab {
  min-height: 34px;
  padding-inline: 0.7rem;
}

.owner-year-tab.is-active {
  background: var(--color-black);
  border-color: var(--color-black);
  color: var(--color-white);
}

.owner-monthly-wrap {
  margin-inline: auto;
  max-width: 680px;
}

.owner-monthly-table {
  font-size: 0.88rem;
  line-height: 1.15;
  table-layout: fixed;
}

.owner-monthly-table th,
.owner-monthly-table td {
  padding: 0.42rem 0.55rem;
}

.owner-monthly-table th:first-child,
.owner-monthly-table td:first-child {
  width: 13%;
}

.owner-monthly-table th:last-child,
.owner-monthly-table td:last-child {
  text-align: right;
  width: 19%;
}

.th-stack {
  display: inline-grid;
  line-height: 1.05;
}

.money > span {
  color: var(--color-gray-700);
  font-size: 0.72em;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.owner-total-row td {
  background: #f6f4ef;
  border-bottom: 0;
  border-top: 2px solid var(--color-gold);
  font-weight: 900;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--color-gray-100);
  padding: 0.9rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--color-gray-700);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tr.current-month td {
  background: #edf8ef;
}

tr.current-month td:first-child {
  color: #1e6b34;
  font-weight: 800;
}

label {
  color: var(--color-gray-700);
  display: grid;
  font-size: 0.9rem;
  font-weight: 800;
  gap: 0.45rem;
}

input,
select,
textarea {
  background: var(--color-white);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  color: var(--color-black);
  font: inherit;
  min-height: 44px;
  padding: 0.7rem 0.85rem;
  width: 100%;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
  outline: 3px solid rgba(212, 175, 55, 0.35);
  outline-offset: 2px;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.alert {
  border-radius: var(--radius);
  font-weight: 800;
  margin-top: 1rem;
  padding: 1rem;
}

.alert-success {
  background: #edf8ef;
  color: #1e6b34;
}

.alert-error {
  background: #fdecec;
  color: #a13434;
}

.empty-state {
  background: var(--color-gray-50);
  border: 1px dashed var(--color-gray-300);
  border-radius: var(--radius);
  color: var(--color-gray-700);
  padding: 2rem;
  text-align: center;
}

.document-list,
.message-list {
  display: grid;
  gap: 0.85rem;
}

.document-row,
.message-row {
  align-items: center;
  border: 1px solid var(--color-gray-100);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr auto;
  padding: 1rem;
}

.document-actions {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.document-actions form {
  margin: 0;
}

.site-footer {
  background: var(--color-black);
  color: var(--color-white);
  margin-top: var(--space-section);
  padding: 2rem 0;
}

.footer-grid {
  display: flex;
  justify-content: space-between;
}

@media (max-width: 920px) {
  :root {
    --space-section: 2.5rem;
  }

  .site-header {
    align-items: center;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr auto;
    min-height: auto;
    padding: 0.75rem 1rem;
  }

  .brand img {
    height: 36px;
    width: 36px;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .main-nav {
    align-items: flex-start;
    background: var(--color-white);
    border-top: 1px solid var(--color-gray-100);
    display: none;
    flex-direction: column;
    gap: 0;
    grid-column: 1 / -1;
    padding-top: 0.5rem;
    width: 100%;
  }

  .main-nav.is-open {
    display: flex;
  }

  .main-nav a {
    border-bottom: 1px solid var(--color-gray-100);
    padding: 0.75rem 0;
    width: 100%;
  }

  .main-nav .btn {
    margin-top: 0.5rem;
    width: 100%;
  }

  .site-header.no-menu .main-nav {
    display: flex;
    grid-column: auto;
    justify-self: end;
    padding-top: 0;
    width: auto;
  }

  .site-header.no-menu .main-nav a {
    border-bottom: 0;
    padding: 0;
    width: auto;
  }

  .site-header.no-menu .main-nav .btn {
    margin-top: 0;
    width: auto;
  }

  .footer-grid {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-shell,
  .grid-2,
  .grid-3,
  .grid-4,
  .stats {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .page-header {
    padding: 1.75rem 0;
  }

  .page-header p:not(.eyebrow) {
    font-size: 0.98rem;
  }

  .section {
    padding: 2.5rem 0;
  }

  .container,
  .container-narrow {
    padding-inline: 1rem;
  }

  .card {
    padding: 1rem;
  }

  .card:hover {
    box-shadow: var(--shadow);
    transform: none;
  }

  .card-heading {
    display: grid;
  }

  .card-heading .status {
    justify-self: start;
  }

  .table-wrap table {
    min-width: 680px;
  }

  .owner-monthly-wrap {
    overflow-x: visible;
  }

  .owner-monthly-wrap .owner-monthly-table {
    min-width: 0;
  }

  .owner-monthly-table,
  .owner-monthly-table tbody,
  .owner-monthly-table tfoot,
  .owner-monthly-table tr,
  .owner-monthly-table td {
    display: block;
    width: 100%;
  }

  .owner-monthly-table thead {
    display: block;
  }

  .owner-monthly-table thead tr {
    background: var(--color-black);
    border: 0;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--color-white);
    display: grid;
    grid-template-columns: 1fr 1fr 0.75fr 0.75fr 1.2fr;
    margin-bottom: 0.25rem;
    overflow: hidden;
  }

  .owner-monthly-table thead th {
    border-bottom: 0;
    color: var(--color-white);
    display: block;
    font-size: 0.56rem;
    letter-spacing: 0.02em;
    line-height: 1;
    padding: 0.45rem 0.25rem;
    text-align: center;
  }

  .owner-monthly-table tr {
    background: var(--color-white);
    border: 1px solid var(--color-gray-100);
    border-radius: var(--radius-sm);
    display: grid;
    gap: 0;
    grid-template-columns: 1fr 1fr 0.75fr 0.75fr 1.2fr;
    margin-bottom: 0.35rem;
    overflow: hidden;
  }

  .owner-monthly-table tr.current-month {
    background: #edf8ef;
    border-color: #bee3c9;
    box-shadow: 0 0 0 1px #d7eadb;
  }

  .owner-monthly-table .owner-total-row {
    background: #f6f4ef;
    border-color: var(--color-gold);
  }

  .owner-monthly-table td {
    border-bottom: 0;
    display: grid;
    gap: 0.1rem;
    min-width: 0;
    padding: 0.45rem 0.35rem;
    text-align: center;
  }

  .owner-monthly-table td::before {
    color: var(--color-gray-700);
    content: none;
    font-size: 0.56rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1;
    text-align: center;
    text-transform: uppercase;
  }

  .owner-monthly-table td:first-child {
    background: #f8f7f3;
    display: grid;
    font-weight: 800;
    grid-column: auto;
    justify-content: stretch;
    padding: 0.45rem 0.35rem;
  }

  .owner-monthly-table td:first-child::before {
    content: none;
  }

  .owner-monthly-table td:last-child {
    border-top: 0;
    display: grid;
    grid-column: auto;
    justify-content: stretch;
    padding: 0.45rem 0.35rem;
  }

  .owner-monthly-table td:last-child .money {
    font-family: var(--font-body);
    font-size: 0.86rem;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
  }

  .owner-monthly-table tr.current-month > td,
  .owner-monthly-table tr.current-month > td:first-child,
  .owner-monthly-table tr.current-month > td:last-child {
    background-color: #edf8ef !important;
  }

  .owner-monthly-table .owner-total-row > td,
  .owner-monthly-table .owner-total-row > td:first-child,
  .owner-monthly-table .owner-total-row > td:last-child {
    background-color: #f6f4ef !important;
  }

  .document-row,
  .message-row {
    grid-template-columns: 1fr;
  }

  .document-actions {
    align-items: stretch;
    justify-content: stretch;
  }

  .document-actions .btn,
  .document-actions form,
  .document-actions form .btn {
    width: 100%;
  }

  .hero-card {
    background:
      linear-gradient(180deg, rgba(10, 10, 10, 0.86), rgba(10, 10, 10, 0.7)),
      var(--color-black);
    min-height: auto;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 2rem;
  }

  h2,
  .card h2 {
    font-size: 1.65rem;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat strong {
    font-size: 1.75rem;
  }

  .stat span {
    font-size: 0.82rem;
  }

  th,
  td {
    padding: 0.75rem;
  }
}

@media (max-width: 380px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .owner-monthly-table {
    font-size: 0.8rem;
  }

  .owner-monthly-table td {
    padding-inline: 0.25rem;
  }

  .owner-monthly-table td::before {
    font-size: 0.5rem;
  }
}
