:root {
  --bg: #eef2f7;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-soft: rgba(245, 248, 252, 0.95);
  --text: #142033;
  --muted: #6b7688;
  --line: #dbe3ee;
  --accent: #1677ff;
  --accent-dark: #0d5ed4;
  --accent-soft: #e8f1ff;
  --success: #147a52;
  --warning: #d97706;
  --danger: #c43838;
  --shadow: 0 24px 60px rgba(18, 34, 61, 0.08);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

[hidden],
.is-hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(22, 119, 255, 0.16), transparent 28%),
    linear-gradient(180deg, #f7f9fc 0%, #edf2f8 100%);
}

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

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

.sidebar {
  padding: 28px;
  color: white;
  background:
    linear-gradient(180deg, rgba(8, 20, 46, 0.96), rgba(17, 39, 85, 0.98)),
    linear-gradient(135deg, #0e2a63, #0f5bd8);
}

.brand {
  display: flex;
  align-items: center;
  margin-bottom: 36px;
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 220px;
  height: auto;
  padding: 10px 12px;
  border-radius: 14px;
  background: #ffffff;
}

.brand h1,
.topbar h2,
.panel h3,
.line-items h4 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar .eyebrow,
.sidebar-card-title {
  color: rgba(255, 255, 255, 0.72);
}

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

.nav-link {
  padding: 14px 16px;
  color: white;
  text-align: left;
  border: 0;
  border-radius: 14px;
  background: transparent;
  transition: background 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(2px);
}

.sidebar-card {
  margin-top: 28px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: rgba(255, 255, 255, 0.85);
}

.main {
  padding: 28px;
}

.topbar,
.panel-header,
.line-items-header,
.form-actions,
.topbar-actions,
.header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

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

.panel {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid rgba(219, 227, 238, 0.7);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.stat-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.8rem;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  font-size: 0.82rem;
  color: var(--muted);
}

.btn,
.icon-btn,
.text-btn {
  border: 0;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

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

.btn {
  padding: 12px 16px;
  font-weight: 700;
  border-radius: 14px;
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.btn-secondary {
  color: var(--text);
  background: var(--accent-soft);
}

.icon-btn {
  width: 36px;
  height: 36px;
  color: white;
  font-size: 1.2rem;
  border-radius: 12px;
  background: var(--danger);
}

.form-panel form,
.line-items,
.invoice-preview {
  margin-top: 12px;
}

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

.form-grid .full,
label.full {
  grid-column: 1 / -1;
}

.form-grid .row-start {
  grid-column-start: 1;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

textarea {
  resize: vertical;
}

.line-item-row {
  display: grid;
  grid-template-columns: 1.8fr 0.5fr 0.7fr 40px;
  gap: 10px;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
}

.badge-draft {
  color: #6d4c00;
  background: #fff1c7;
}

.badge-paid {
  color: #0f6844;
  background: #dff7eb;
}

.badge-overdue {
  color: #942626;
  background: #ffe0e0;
}

.badge-open {
  color: #0c4da2;
  background: #dfebff;
}

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

.mini-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

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

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  color: #0f5d68;
  font-weight: 700;
  white-space: nowrap;
  border-radius: 12px;
  background: #dff6f2;
}

.text-btn:hover {
  background: #c8efe8;
}

.ares-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: -4px;
}

.ares-actions .muted {
  margin: 0;
}

.ares-results {
  display: grid;
  gap: 10px;
}

.ares-result {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.ares-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.ares-result p {
  margin: 6px 0 0;
}

.ares-result strong {
  display: block;
}

.status-error {
  color: var(--danger);
}

.status-success {
  color: var(--success);
}

.status-warning {
  color: var(--warning);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 20px;
  background: rgba(248, 250, 253, 0.8);
}

.invoice-sheet {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 36px;
  border-radius: 24px;
  background: white;
  box-shadow: inset 0 0 0 1px var(--line);
}

.invoice-sheet-header,
.invoice-meta,
.invoice-parties,
.invoice-footer,
.invoice-total-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.invoice-sheet-header {
  align-items: flex-start;
  margin-bottom: 24px;
}

.invoice-meta,
.invoice-parties,
.invoice-items,
.invoice-summary,
.invoice-footer {
  margin-top: 24px;
}

.invoice-brand strong {
  display: block;
  font-size: 1.5rem;
}

.invoice-card {
  flex: 1;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fbff;
}

.invoice-items table th,
.invoice-items table td {
  padding: 12px 0;
}

.invoice-summary {
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
}

.invoice-total-row {
  margin-bottom: 10px;
}

.invoice-total-row.grand {
  font-size: 1.15rem;
  font-weight: 800;
}

.qr-box img {
  width: 132px;
  height: 132px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

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

  .sidebar {
    padding-bottom: 20px;
  }

  .main {
    padding: 18px;
  }

  .ares-actions,
  .ares-result-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media print {
  body {
    background: white;
  }

  .sidebar,
  .topbar,
  .panel:not(:has(.invoice-sheet)),
  .btn {
    display: none !important;
  }

  .main,
  .panel,
  .invoice-sheet {
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: 0;
  }
}
