:root {
  --bg: #f5f7fb;
  --text: #1a2233;
  --muted: #667085;
  --line: #d8e0ef;
  --card: #fff;
  --primary: #2859d6;
  --primary-soft: #eef3ff;
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.12);
  --danger-bg: #ffe9e9;
  --danger-text: #9c1f1f;
  --success-bg: #e9f9ef;
  --success-text: #1f6f37;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  background-image: radial-gradient(circle at 10% -10%, #e9efff 0, transparent 40%);
}

.container {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 24px;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 8px;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.top-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: #1f2a44;
  padding: 6px 10px;
 
}

.top-nav__logo {
  height: 22px;
  width: auto;
  display: block;
}

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

.top-nav a {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  background: #fff;
  transition: all 0.18s ease;
}

.top-nav a:hover {
  border-color: #b9c8ea;
  background: #f8faff;
}

.top-nav a.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: #173985;
  font-weight: 600;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.page-head h1,
.card h1,
.card h2 {
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

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

.tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
}

.tab-btn.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.month-tab-panel[hidden] {
  display: none !important;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
  padding: 12px 14px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.auth-card {
  max-width: 420px;
  margin: 40px auto;
}

.dashboard-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.mt-16 {
  margin-top: 16px;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  max-width: 90ch;
}

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

.form-grid {
  display: grid;
  gap: 12px;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
  align-items: end;
}

.dropzone {
  border: 2px dashed #b9c8ea;
  border-radius: 12px;
  padding: 14px;
  background: #f8faff;
  transition: all 0.18s ease;
  cursor: pointer;
}

.dropzone--active {
  border-color: var(--primary);
  background: #eef3ff;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-inline input[type="checkbox"] {
  width: auto;
  margin: 0;
}

input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  width: 100%;
  background: #fff;
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  background: #fff;
  width: 100%;
}

input:focus,
select:focus {
  outline: 2px solid #d7e3ff;
  border-color: var(--primary);
}

button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button svg {
  width: 18px !important;
  height: 18px !important;
}
button:hover {
  box-shadow: var(--shadow-sm);
}

button:active {
  transform: translateY(1px);
}

.btn-small {
  padding: 6px 10px;
  font-size: 13px;
}

.ocr-preview {
  white-space: pre-wrap;
  background: #f6f8fc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
  max-height: 320px;
  overflow: auto;
}

.table-wrap {
  overflow: auto;
}

.invoice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.invoice-panel {
  padding: 14px;
}

.invoice-panel h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.table-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.table-filters label {
  min-width: 220px;
}

.year-switcher {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.months-calendar {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 12px;
}

.month-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  min-height: 180px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.month-card--active {
  box-shadow: var(--shadow-sm);
}

.month-card--empty {
  border-style: dashed;
  background: #f8faff;
}

.month-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.month-card__head h3 {
  margin: 0;
}

.month-card__stats {
  display: grid;
  gap: 6px;
}

.month-card__stats p {
  margin: 0;
  font-size: 14px;
}

.calendar-add-form {
  margin: 18px 0 8px;
  display: flex;
  justify-content: center;
}

.calendar-add-btn {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  font-size: 34px;
  line-height: 1;
  font-weight: 400;
  padding: 0;
}

.split-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #f8faff;
}

.split-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.assign-row {
  display: grid;
  grid-template-columns: 1fr 160px 120px auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.assignee-row {
  grid-template-columns: 1fr 160px 120px auto;
}

.expense-row {
  grid-template-columns: 1fr 220px auto;
  align-items: start;
}

.expense-amount-wrap {
  display: grid;
  gap: 4px;
}

.assign-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #f8faff;
}

.assign-remaining-positive {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--success-bg);
  color: var(--success-text);
  font-weight: 700;
}

.expense-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.table th {
  font-size: 13px;
  color: #344054;
  background: #f4f7ff;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody tr:nth-child(even) td {
  background: #fbfcff;
}

.table tbody tr:hover td {
  background: #f3f7ff;
}

.row-edit-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.row-edit-form input,
.row-edit-form select {
  min-width: 110px;
}

.badge {
  display: inline-block;
  border-radius: 20px;
  font-size: 12px;
  padding: 4px 8px;
}

.badge--success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge--muted {
  background: #eceff5;
  color: #4f5d75;
}

.badge--info {
  background: #e8f0ff;
  color: #1d4ed8;
}

.badge--warning {
  background: #fff8e5;
  color: #a16207;
}

.btn-link {
  display: inline-block;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  background: #fff;
  transition: all 0.18s ease;
}

.btn-link:hover {
  border-color: #b9c8ea;
  background: #f8faff;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-actions form {
  margin: 0;
}

.btn-danger {
  background: #c73737;
  color: #fff;
}

.btn-icon-delete {
  background: transparent;
  color: #98a2b3;
  padding: 2px 6px;
  font-weight: 700;
  line-height: 1;
  border-radius: 6px;
  box-shadow: none;
}

.btn-icon-delete:hover {
  background: #f2f4f7;
  color: #667085;
  box-shadow: none;
}

.btn-purple {
  background: #6f42c1;
  color: #fff;
}

.invoice-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: #eef2ff;
  color: #374151;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
}

.invoice-help-float {
  position: fixed;
  min-width: 220px;
  max-width: 360px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  z-index: 9999;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  white-space: pre-line;
  pointer-events: none;
}

.btn-purple:hover {
  background: #5d34a3;
}

.flash {
  border-radius: 10px;
  padding: 11px 12px;
  margin: 0 auto 16px;
  border: 1px solid transparent;
  border-left-width: 4px;
  box-shadow: var(--shadow-sm);
}

.flash--error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-left-color: #c73737;
}

.flash--success {
  background: var(--success-bg);
  color: var(--success-text);
  border-left-color: #2f8f4f;
}

.help-text {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
  display: inline-block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal {
  width: 100%;
  max-width: 980px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 16px;
  max-height: calc(100vh - 60px);
  overflow: auto;
  box-shadow: var(--shadow-md);
}

.modal--medium {
  max-width: 760px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btn-icon-eye {
  min-width: 34px;
  text-align: center;
  padding: 6px 8px;
}

.future-options {
  border: 1px dashed var(--line);
  background: #f8faff;
  border-radius: 8px;
  padding: 10px;
  color: #334155;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .top-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .top-nav__links {
    width: 100%;
  }

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

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

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

  .months-calendar {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

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

  .assign-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 12px;
  }

  .top-nav {
    top: 6px;
  }

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

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

  .months-calendar {
    grid-template-columns: 1fr;
  }
}
