:root {
  color-scheme: light;
  --bg: #f2f5f2;
  --bg-deep: #e6ece8;
  --panel: #ffffff;
  --text: #1d2420;
  --muted: #5d6a63;
  --accent: #227c65;
  --accent-strong: #1b5d4b;
  --warning: #d27a1f;
  --border: #dde5df;
  --shadow: 0 24px 45px -35px rgba(26, 38, 29, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Futura", "Gill Sans", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #f9fbf7 0%, var(--bg) 55%),
    linear-gradient(135deg, #f2f8f3 0%, #edf1f0 100%);
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.main {
  flex: 1;
  padding: 32px 28px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.6s ease-out;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.title-block {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  max-width: 620px;
}

.hamburger {
  display: none;
  border: 1px solid var(--border);
  background: #f7faf7;
  color: var(--accent-strong);
  border-radius: 12px;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
}

.tag {
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}

h1 {
  font-size: 2.5rem;
  margin: 0 0 8px;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

.filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.topbar-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.app-footer {
  margin-top: 32px;
}

.topbar-meta .context {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-meta .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.topbar-meta .user-info span {
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.field select {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fbf8;
  font-size: 0.95rem;
  color: var(--text);
}

.field input {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fbf8;
  font-size: 0.95rem;
  color: var(--text);
}

.sidebar {
  width: 240px;
  padding: 28px 20px;
  background: #f7faf7;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 32px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-strong);
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
}

.nav-link:hover {
  background: #eef4ef;
}

.nav-link.active {
  background: #e1f1ea;
  border-color: rgba(34, 124, 101, 0.25);
  color: var(--accent-strong);
  font-weight: 600;
}

.sidebar-overlay {
  display: none;
}

.page-section {
  display: none;
  flex-direction: column;
  gap: 24px;
}

.page-section.active {
  display: flex;
}

.calendar-header {
  margin-bottom: 12px;
  color: var(--muted);
}

.calendar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calendar-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-grid-body {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-cell {
  border: 1px solid var(--border);
  background: #f8fbf8;
  border-radius: 12px;
  padding: 10px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text);
}

.calendar-cell.header {
  min-height: auto;
  background: transparent;
  border: none;
  font-weight: 600;
  color: var(--muted);
  align-items: center;
  justify-content: center;
}

.calendar-cell.day {
  cursor: pointer;
  text-align: left;
}

.calendar-cell.day.selected {
  border-color: var(--accent);
  background: #e9f4ef;
}

.calendar-cell.day.has-payments {
  box-shadow: inset 0 0 0 1px rgba(34, 124, 101, 0.25);
}

.calendar-cell.empty {
  background: transparent;
  border: none;
}

.day-number {
  font-weight: 600;
}

.day-total {
  font-size: 0.8rem;
  color: var(--accent-strong);
}

.payment-details {
  margin-top: 18px;
}

.payment-day-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.payment-day-item {
  display: grid;
  grid-template-columns: 1.5fr 1.4fr 1fr 0.8fr;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7faf7;
  border: 1px solid var(--border);
}

.payment-day-total {
  font-weight: 600;
  color: var(--accent-strong);
}

.report-form {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 12px;
}

.report-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.auth-page {
  min-height: 100vh;
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.landing-page {
  background: var(--background);
  color: var(--text);
}

.landing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 48px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  fill: var(--accent-strong);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.auth-brand .brand-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.landing-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.landing-nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 32px;
  padding: 40px 48px 20px;
  align-items: center;
}

.hero-content h1 {
  font-size: 2.4rem;
  margin-bottom: 12px;
}

.hero-subtitle {
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.hero-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.hero-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.benefits {
  padding: 20px 48px 40px;
}

.benefit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.benefit-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.pricing {
  padding: 20px 48px 60px;
}

.pricing-subtitle {
  color: var(--muted);
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.price-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
}

.price-card.highlight {
  border-color: rgba(76, 122, 159, 0.35);
  background: #f5f8fb;
  box-shadow: 0 18px 45px rgba(23, 55, 88, 0.08);
}

.price-card .price {
  font-weight: 600;
  color: var(--accent-strong);
}

.price-card ul {
  margin: 12px 0 20px;
  padding-left: 18px;
  color: var(--muted);
}

.plan-icon {
  font-size: 1.6rem;
  display: inline-flex;
  margin-bottom: 6px;
}

.plan-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #1b5d4b;
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.check-list {
  list-style: none;
  padding-left: 0;
}

.check-list li {
  margin-bottom: 8px;
}

.pricing-note {
  margin-top: 18px;
  color: var(--muted);
}

.product-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 32px;
  padding: 10px 48px 40px;
  align-items: center;
}

.preview-list {
  margin-top: 12px;
  padding-left: 18px;
  color: var(--muted);
}

.mockup {
  background: #f5f7fb;
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.mockup-header {
  display: flex;
  gap: 6px;
  padding: 12px;
  background: #e7edf4;
}

.mockup-header .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c7d3df;
}

.mockup-body {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.mockup-row {
  height: 14px;
  background: #d8e1ec;
  border-radius: 8px;
}

.mockup-row.wide {
  height: 26px;
  background: #c9d6e5;
}

.legal-footer {
  padding: 24px 48px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
}

.footer-brand {
  display: flex;
  gap: 10px;
  align-items: center;
}

.legal-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.legal-links a {
  color: var(--muted);
  text-decoration: none;
}

.legal-page {
  background: var(--background);
  color: var(--text);
  padding: 32px 24px 60px;
}

.legal-content {
  max-width: 820px;
  margin: 0 auto;
  background: var(--panel);
  padding: 32px;
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.legal-content h1 {
  margin-top: 0;
}

.legal-content h2 {
  margin-top: 24px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 16px;
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 600;
}
.auth-card {
  background: var(--panel);
  padding: 32px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  width: min(420px, 100%);
}

.auth-card h1 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 20px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form input {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.auth-error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 12px;
}

.auth-message {
  background: #ecfdf3;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 10px 12px;
  border-radius: 12px;
}

.auth-links {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-links a {
  color: var(--accent-strong);
  text-decoration: none;
}

.panel {
  background: var(--panel);
  border-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 22px 24px 26px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 0 0 6px;
  font-size: 1.3rem;
}

.panel-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 15px 30px -18px rgba(34, 124, 101, 0.65);
}

.button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px -20px rgba(34, 124, 101, 0.8);
}

.button.ghost {
  background: #f3f7f4;
  color: var(--accent-strong);
  border: 1px solid rgba(34, 124, 101, 0.2);
}

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

.upload-panel {
  position: relative;
}

.upload-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 22px 26px;
  border: 1px dashed rgba(34, 124, 101, 0.45);
  border-radius: 18px;
  background: linear-gradient(120deg, #f9fbf7 0%, #eff5f0 100%);
  transition: border 0.2s ease, background 0.2s ease;
}

.upload-area.dragover {
  border-color: var(--accent);
  background: #f1fbf6;
}

.upload-copy h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.upload-copy p {
  margin: 0;
  color: var(--muted);
}

.upload-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.upload-actions input {
  display: none;
}

.upload-table-wrapper {
  margin-top: 20px;
}

.billing-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  align-items: end;
}

.billing-form .button {
  align-self: end;
  justify-self: start;
}

.billing-entries {
  margin-top: 18px;
}

.billing-entries h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

#uploadTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

#uploadTable th,
#uploadTable td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

#uploadTable th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#uploadTable input,
#uploadTable select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f7faf7;
  font-size: 0.9rem;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
}

.row-actions button {
  background: transparent;
  color: var(--warning);
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.empty {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

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

.chart-wrapper {
  position: relative;
  height: 320px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.chart-empty.is-visible {
  display: flex;
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.summary-item {
  padding: 16px 18px;
  border-radius: 16px;
  background: #f7faf7;
  border: 1px solid var(--border);
}

.summary-item h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.summary-item p {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.summary-item.highlight {
  background: linear-gradient(130deg, #e2f6ee 0%, #f6fbf8 100%);
  border-color: rgba(34, 124, 101, 0.25);
}

.summary-item.total {
  background: linear-gradient(130deg, #f8f1e8 0%, #fdfaf6 100%);
  border-color: rgba(210, 122, 31, 0.3);
}

.billing-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.billing-table th,
.billing-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.billing-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.billing-table input,
.billing-table select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f7faf7;
  font-size: 0.9rem;
}

.period-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: #e9f2ee;
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 600;
}

.is-processing {
  opacity: 0.85;
}

.processing-row td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  background: #f7faf7;
  color: var(--muted);
  font-size: 0.9rem;
}

.processing-row.error td {
  background: #f9ece7;
  color: #9a4b2f;
}

.processing-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.global-processing {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: #f7faf7;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

.global-processing.is-visible {
  display: inline-flex;
}

.global-processing.error {
  background: #f9ece7;
  color: #9a4b2f;
  border-color: rgba(154, 75, 47, 0.2);
}

.global-processing.error .spinner {
  display: none;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(93, 106, 99, 0.3);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.billing-actions {
  display: flex;
  gap: 10px;
}

.billing-actions .button {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.button.danger {
  background: #f6e6e1;
  color: #a15433;
}

.invoice-actions {
  display: flex;
  gap: 10px;
}

.invoice-actions .button {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.vat-result {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.vat-card {
  padding: 16px 18px;
  border-radius: 16px;
  background: #f7faf7;
  border: 1px solid var(--border);
}

.vat-card h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.vat-card p {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.vat-card.result {
  background: linear-gradient(130deg, #e7eef6 0%, #f6f9fd 100%);
  border-color: rgba(76, 122, 159, 0.25);
}

.pnl-panel .panel-header {
  align-items: flex-start;
}

.pnl-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.pnl-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.period-month {
  display: none;
}

body.period-quarterly .period-month {
  display: table-cell;
}

body.period-quarterly #billingEntriesTable th.period-month,
body.period-quarterly #billingEntriesTable td.period-month {
  display: table-cell;
}

@media (max-width: 1024px) {
  .main {
    padding: 28px 20px 40px;
  }
}

@media (max-width: 920px) {
  .topbar {
    flex-direction: column;
  }

  .filters {
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .upload-area {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -260px;
    width: 240px;
    z-index: 20;
    transition: left 0.2s ease;
  }

  body.sidebar-open .sidebar {
    left: 0;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 22, 18, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 10;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 600px) {
  .main {
    padding: 24px 18px 40px;
  }

  h1 {
    font-size: 2rem;
  }

  .filters {
    flex-direction: column;
  }
}
