:root {
  --sky: #0795d7;
  --sky-dark: #057ab0;
  --sky-soft: #e8f8ff;
  --mint: #19b99a;
  --amber: #e6a000;
  --rose: #dd4b6a;
  --ink: #17324d;
  --muted: #668094;
  --line: rgba(77, 124, 153, 0.16);
  --panel: rgba(255, 255, 255, 0.78);
  --shadow: 0 18px 50px rgba(22, 95, 136, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(231, 248, 255, 0.9), rgba(255, 255, 255, 0.92) 48%, rgba(236, 255, 250, 0.82));
  font-size: 15px;
}

a {
  color: var(--sky-dark);
  text-decoration: none;
}

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

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.brand,
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #07a9ef, #19b99a);
  box-shadow: 0 10px 26px rgba(7, 149, 215, 0.28);
}

.brand strong,
.auth-brand strong {
  display: block;
  font-size: 16px;
}

.brand small,
.auth-brand small {
  display: block;
  margin-top: 2px;
}

.nav-list {
  margin-top: 34px;
  display: grid;
  gap: 8px;
}

.nav-link {
  min-height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 650;
}

.nav-link i {
  color: var(--sky-dark);
}

.nav-link:hover,
.nav-link.active {
  background: rgba(7, 149, 215, 0.1);
  color: var(--ink);
}

.sidebar-footer {
  margin-top: auto;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  padding: 20px 32px 8px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
}

.content {
  padding: 20px 32px 42px;
}

.panel,
.stat-card,
.auth-card,
.invoice-document {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 22px;
  margin-bottom: 22px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  padding: 18px;
}

.stat-card span {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--sky);
  margin-bottom: 14px;
}

.stat-card small,
.stat-card strong {
  display: block;
}

.stat-card strong {
  margin-top: 6px;
  font-size: 22px;
}

.dashboard-grid,
.two-column,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.span-2 {
  grid-column: span 2;
}

.inner-grid {
  gap: 14px;
}

.form-stack,
.form-grid label,
.panel label {
  display: grid;
  gap: 8px;
}

.form-stack {
  gap: 15px;
}

label span {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.form-control {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(81, 129, 155, 0.22);
  border-radius: 13px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  font: inherit;
  outline: none;
}

textarea.form-control {
  resize: vertical;
  line-height: 1.5;
}

.form-control:focus {
  border-color: rgba(7, 149, 215, 0.72);
  box-shadow: 0 0 0 4px rgba(7, 149, 215, 0.1);
}

.btn,
.icon-button {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 750;
}

.btn {
  min-height: 42px;
  border-radius: 13px;
  padding: 10px 15px;
  white-space: nowrap;
}

.btn-sm {
  min-height: 36px;
  padding: 8px 12px;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--sky), #18acd2);
  box-shadow: 0 12px 26px rgba(7, 149, 215, 0.22);
}

.btn-soft {
  color: var(--sky-dark);
  background: rgba(7, 149, 215, 0.1);
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--sky-dark);
  background: rgba(7, 149, 215, 0.1);
}

.icon-button.danger {
  color: var(--rose);
  background: rgba(221, 75, 106, 0.1);
}

.mobile-menu {
  display: none;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 190px auto;
  gap: 12px;
  margin-bottom: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

.compact .data-table {
  min-width: 520px;
}

.data-table th,
.data-table td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(81, 129, 155, 0.12);
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.data-table td strong,
.data-table td small {
  display: block;
}

.actions-col {
  width: 190px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.table-actions form {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge-success { color: #04785f; background: rgba(25, 185, 154, 0.14); }
.badge-warning { color: #996600; background: rgba(230, 160, 0, 0.16); }
.badge-danger { color: #a8334d; background: rgba(221, 75, 106, 0.14); }
.badge-secondary { color: #607181; background: rgba(96, 113, 129, 0.14); }
.badge-info { color: #0a6b83; background: rgba(16, 171, 205, 0.14); }
.badge-primary { color: #057ab0; background: rgba(7, 149, 215, 0.14); }

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success {
  color: #04785f;
  background: rgba(25, 185, 154, 0.12);
  border-color: rgba(25, 185, 154, 0.22);
}

.alert-danger {
  color: #a8334d;
  background: rgba(221, 75, 106, 0.1);
  border-color: rgba(221, 75, 106, 0.2);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px !important;
}

.details-list {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
}

.details-list dt {
  color: var(--muted);
  font-weight: 800;
}

.details-list dd {
  margin: 0;
}

.logo-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 18px;
  align-items: center;
}

.logo-preview {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(7, 149, 215, 0.1);
  overflow: hidden;
  color: var(--sky-dark);
  font-size: 28px;
}

.logo-preview img,
.invoice-logo {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.invoice-item-row {
  display: grid;
  grid-template-columns: 1.15fr 1.15fr 1.4fr 0.55fr 0.6fr 0.75fr 0.65fr 0.8fr 38px;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
  margin-bottom: 12px;
}

.invoice-item-row .wide {
  min-width: 180px;
}

.totals-list,
.summary-box {
  display: grid;
  gap: 11px;
}

.totals-list div,
.summary-box div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
}

.totals-list strong,
.summary-box strong {
  color: var(--ink);
}

.summary-box .grand {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 18px;
}

.toggle-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.toggle-row input {
  width: 19px;
  height: 19px;
  accent-color: var(--sky);
}

.form-actions,
.action-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sticky-actions {
  position: sticky;
  bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.invoice-document {
  padding: 34px;
  background: rgba(255, 255, 255, 0.92);
}

.invoice-doc-header,
.invoice-doc-grid,
.invoice-summary {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
}

.invoice-doc-header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.invoice-doc-header h1,
.invoice-doc-header h2 {
  margin: 0 0 8px;
}

.invoice-doc-header p,
.invoice-doc-grid p {
  margin: 4px 0;
  color: var(--muted);
}

.invoice-doc-meta {
  text-align: right;
}

.invoice-doc-grid,
.invoice-summary {
  margin-top: 22px;
}

.amount-words {
  align-self: start;
  border-radius: 16px;
  padding: 15px;
  background: rgba(7, 149, 215, 0.08);
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: min(100%, 460px);
  padding: 28px;
}

.auth-card h1 {
  margin: 26px 0 8px;
}

.auth-card p {
  color: var(--muted);
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .invoice-item-row {
    grid-template-columns: repeat(4, minmax(150px, 1fr)) 38px;
  }
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(17, 37, 56, 0.28);
    z-index: 20;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar,
  .content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar-user {
    display: none;
  }

  .dashboard-grid,
  .two-column,
  .form-grid,
  .invoice-doc-header,
  .invoice-doc-grid,
  .invoice-summary {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

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

  .invoice-doc-meta {
    text-align: left;
  }
}

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

  .panel,
  .invoice-document {
    padding: 16px;
  }

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

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

  .invoice-item-row .icon-button {
    width: 100%;
  }

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

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .action-bar,
  .sticky-actions {
    display: none !important;
  }

  .app-layout,
  .main,
  .content {
    display: block;
    padding: 0;
  }

  .invoice-document {
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0;
  }
}
