:root {
  --bg: #eef4fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --text: #12304a;
  --muted: #5d7388;
  --line: rgba(18, 48, 74, 0.12);
  --accent: #1d79c8;
  --accent-dark: #0c4e8a;
  --accent-soft: #d9ecfb;
  --danger: #c34a3b;
  --success: #2d8f67;
  --shadow: 0 18px 45px rgba(24, 67, 110, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Aptos", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(111, 188, 255, 0.28), transparent 28%),
    radial-gradient(circle at right, rgba(193, 229, 255, 0.5), transparent 24%),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-hidden {
  display: none !important;
}

.login-hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background:
    radial-gradient(circle at top left, rgba(111, 188, 255, 0.28), transparent 28%),
    radial-gradient(circle at right, rgba(193, 229, 255, 0.5), transparent 24%),
    var(--bg);
  overflow: auto;
}

.login-card {
  width: min(460px, 100%);
  padding: 32px;
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h1,
.sidebar h1,
.content h2,
.panel h3,
.invoice-builder-header h4 {
  margin: 0;
}

.login-copy {
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-form label,
.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.login-form input,
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.hint {
  margin: 0;
  color: var(--muted);
}

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

.sidebar {
  padding: 32px 24px;
  background: linear-gradient(180deg, #0f3556, #184e7a);
  color: #f4fbff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.72rem;
  color: var(--muted);
}

.sidebar .eyebrow {
  color: rgba(226, 242, 255, 0.72);
}

.sidebar-copy {
  color: rgba(236, 247, 255, 0.84);
  line-height: 1.6;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-link,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}

.nav-link {
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  color: #f4fbff;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(209, 236, 255, 0.18);
  transform: translateX(3px);
}

.sidebar-card,
.panel,
.stat-card {
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.sidebar-card {
  padding: 18px;
  border-radius: 24px;
  color: var(--text);
}

.content {
  padding: 28px;
}

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

.topbar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 14px 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  box-shadow: 0 12px 26px rgba(24, 67, 110, 0.08);
}

.primary-button {
  background: var(--accent);
  color: white;
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: inherit;
}

.danger-button {
  background: rgba(195, 74, 59, 0.14);
  color: var(--danger);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid,
.panel-grid {
  display: grid;
  gap: 18px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

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

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

.panel-grid.single {
  grid-template-columns: 1fr;
}

.stat-card,
.panel {
  border-radius: 28px;
  padding: 22px;
}

.brand-panel {
  background: linear-gradient(135deg, rgba(29, 121, 200, 0.12), rgba(0, 184, 148, 0.08));
}

.brand-summary p {
  margin: 0 0 16px;
  line-height: 1.7;
}

.brand-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.brand-chips span {
  display: inline-flex;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 700;
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 14px;
}

.stat-card strong {
  font-size: 2rem;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 20px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.92rem;
}

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

.full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.section-divider {
  margin-bottom: 20px;
}

.section-helper {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(29, 121, 200, 0.07);
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.6;
}

.backup-box h4 {
  margin: 0 0 8px;
}

.backup-box p {
  margin: 0 0 16px;
  color: var(--muted);
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.table-card {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.list-stack {
  display: grid;
  gap: 12px;
}

.list-item {
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.list-item strong,
.list-item span {
  display: block;
}

.list-item span {
  color: var(--muted);
  margin-top: 4px;
}

.invoice-builder {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
}

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

.invoice-lines {
  display: grid;
  gap: 12px;
}

.invoice-line {
  display: grid;
  grid-template-columns: 2fr 120px 140px 120px;
  gap: 10px;
}

.total-box {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-radius: 18px;
  padding: 16px;
  background: rgba(29, 121, 200, 0.08);
}

.preview-panel {
  margin-top: 18px;
}

.invoice-preview-sheet {
  background: white;
  color: #222;
  padding: 32px;
  border-radius: 18px;
}

.invoice-preview-sheet header,
.invoice-preview-sheet .invoice-meta,
.invoice-preview-sheet .invoice-totals {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.invoice-preview-sheet table {
  margin: 24px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 700;
}

.badge.paid {
  background: rgba(45, 143, 103, 0.15);
  color: var(--success);
}

.badge.sent {
  background: rgba(29, 121, 200, 0.14);
  color: var(--accent-dark);
}

.badge.draft {
  background: rgba(67, 76, 89, 0.12);
  color: #44505d;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #12304a;
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .stats-grid,
  .panel-grid,
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

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

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

  .sidebar,
  .content {
    padding: 20px;
  }

  .stats-grid,
  .panel-grid,
  .form-grid,
  .invoice-line {
    grid-template-columns: 1fr;
  }

  .topbar,
  .invoice-builder-header,
  .panel-heading,
  .total-box,
  .invoice-preview-sheet header,
  .invoice-preview-sheet .invoice-meta,
  .invoice-preview-sheet .invoice-totals {
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
    padding: 12px;
  }

  .topbar-actions button,
  .form-actions button,
  .row-actions button {
    width: 100%;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  #invoice-preview-content,
  #invoice-preview-content * {
    visibility: visible;
  }

  #invoice-preview-content {
    position: absolute;
    inset: 0;
    width: 100%;
  }
}
