:root {
  font-family: 'Outfit', sans-serif;
  --page-bg: #f8fafc;
  --surface: #ffffff;
  --muted-surface: #f1f5f9;
  --ink: #0f172a;
  --muted: #475569;
  --accent: #18CB96;
  --border: #e2e8f0;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-soft: 0 12px 30px rgba(15, 23, 42, 0.08);
}

body.theme-dark {
  --page-bg: #0b1220;
  --surface: #0f172a;
  --muted-surface: #111a2c;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --accent: #18CB96;
  --border: #1f2937;
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.28);
}

body {
  background: var(--page-bg);
  color: var(--ink);
  font-size: 14px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

#main-layout {
  color: var(--ink);
  background: var(--page-bg);
}

#sidebar,
#main-header,
.drawer-panel {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

.login-hero {
  position: relative;
  background: linear-gradient(135deg, var(--page-bg) 0%, var(--muted-surface) 100%);
  overflow: hidden;
  isolation: isolate;
}

.login-hero::before,
.login-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.6;
  filter: blur(60px);
  z-index: -1;
}

.login-hero::before {
  background: radial-gradient(circle at 22% 30%, rgba(24, 203, 150, 0.12), transparent 42%),
              radial-gradient(circle at 80% 18%, rgba(148, 163, 184, 0.22), transparent 38%);
}

.login-hero::after {
  background: radial-gradient(circle at 70% 78%, rgba(24, 203, 150, 0.12), transparent 42%),
              radial-gradient(circle at 16% 86%, rgba(148, 163, 184, 0.18), transparent 40%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  border-radius: var(--radius-lg);
}

.login-card h2 {
  letter-spacing: -0.02em;
}

.input-field {
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.8);
}

.input-field:focus {
  box-shadow: 0 10px 28px rgba(24, 203, 150, 0.18);
  border-color: var(--accent);
  background: #fff;
}

.btn-primary {
  background: linear-gradient(120deg, var(--accent), color-mix(in srgb, var(--accent) 80%, #6fe5c0));
  box-shadow: 0 14px 28px rgba(24, 203, 150, 0.24);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  border-radius: var(--radius-md);
}

.btn-accent {
  background: linear-gradient(125deg, var(--accent), color-mix(in srgb, var(--accent) 78%, #7ce9c7));
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--accent) 78%, #e8fff5);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 26px rgba(24, 203, 150, 0.22);
  transition: transform 0.16s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(24, 203, 150, 0.26);
}

.btn-accent:active {
  transform: translateY(0);
  box-shadow: 0 10px 20px rgba(24, 203, 150, 0.18);
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.btn-ghost:hover { background: var(--muted-surface); }

.btn-danger {
  color: #b91c1c;
  border: 1px solid #fca5a5;
  background: color-mix(in srgb, #fef2f2 82%, transparent);
  border-radius: var(--radius-md);
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn-danger:hover { background: color-mix(in srgb, #fee2e2 88%, transparent); border-color: #f87171; }
.btn-danger svg { color: inherit; }

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(24, 203, 150, 0.28);
}

.btn-primary:active {
  transform: translateY(0);
}

.theme-toggle-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle-btn:hover {
  background: var(--muted-surface);
}

.container {
  max-width: 1200px;
}

.status-draft { background: #f3f4f6; color: #6b7280; font-weight: 600; }
.status-sent { background: #e0f2fe; color: #2563eb; font-weight: 600; }
.status-paid { background: #ecfdf3; color: #16a34a; font-weight: 600; }


.card-flat {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  border-radius: var(--radius-md);
}

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

.invoice-table thead {
  background: var(--muted-surface);
}

.invoice-table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.invoice-table-row {
  background: var(--surface);
  transition: background-color 0.16s ease, color 0.16s ease;
}

.invoice-table-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.invoice-table-row:hover {
  background: var(--muted-surface);
}

.table-action {
  font-weight: 600;
  color: var(--muted);
  transition: color 0.16s ease;
}

.table-link {
  font-weight: 700;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.table-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.table-action:hover {
  color: var(--ink);
}

.table-action.danger {
  color: #ef4444;
}

.table-action.danger:hover {
  color: #dc2626;
}

.invoice-cell {
  padding: 14px 18px;
  color: var(--ink);
  font-weight: 600;
}

.invoice-cell-muted {
  color: var(--muted);
  font-weight: 500;
}

.invoice-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.invoice-actions button {
  font-weight: 600;
}

#content-area {
  background: var(--page-bg);
}

@media print {
  body {
    background-color: white !important;
    margin: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 13px;
  }
  @page { size: A4; margin: 1.2cm; }
  html, body { width: 210mm; }
  #invoice-print-area {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  #sidebar, #main-header, #pdf-actions, .no-print { display: none !important; }
  #content-area { margin: 0 !important; padding: 0 !important; width: 100% !important; }
  .page-break { page-break-after: always; }
  .invoice-card { box-shadow: none !important; border: none !important; padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
  .invoice-shell { padding: 12mm !important; border-radius: 0 !important; background: white !important; box-shadow: none !important; width: 100% !important; max-width: 100% !important; margin: 0 auto !important; }
  .no-break { page-break-inside: avoid; }
  .print-hide { display: none !important; }
  .print-two-col { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 1.5rem !important; }
}

@media (max-width: 768px) {
  .responsive-table th, .responsive-table td {
    display: block;
    width: 100%;
    text-align: right;
  }
  .responsive-table thead {
    display: none;
  }
  .invoice-table-row {
    display: block;
    padding: 10px 12px;
    margin-bottom: 12px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
  }
  .invoice-table-row:not(:last-child) {
    border-bottom: none;
  }
  .invoice-cell,
  .invoice-cell-muted {
    padding: 10px 0;
    text-align: right;
  }
  .responsive-table th {
    text-align: left;
    padding-top: 0.5rem;
  }
  .responsive-table td:before {
    content: attr(data-label);
    float: left;
    font-weight: 500;
    padding-right: 1rem;
    color: var(--muted);
  }
}

body.theme-dark {
  color: var(--ink);
}

body.theme-dark .login-card,
body.theme-dark .card-flat,
body.theme-dark .theme-toggle-btn {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
}

body.theme-dark .input-field {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
  color: var(--ink);
}

body.theme-dark input:not([type="checkbox"]):not([type="radio"]),
body.theme-dark select,
body.theme-dark textarea {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder,
body.theme-dark select::placeholder {
  color: var(--muted);
}

body.theme-dark .input-field:focus {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 24px rgba(24, 203, 150, 0.22);
}

body.theme-dark .invoice-table-row {
  background: var(--surface);
  border-color: var(--border);
}

body.theme-dark .invoice-table-row:hover {
  background: color-mix(in srgb, var(--muted-surface) 80%, transparent);
}

body.theme-dark .bg-white,
body.theme-dark .bg-gray-50,
body.theme-dark .bg-slate-50 {
  background-color: var(--surface) !important;
}

body.theme-dark .text-gray-900,
body.theme-dark .text-gray-800,
body.theme-dark .text-gray-700,
body.theme-dark .text-gray-600,
body.theme-dark .text-gray-500,
body.theme-dark .text-slate-900,
body.theme-dark .text-slate-800,
body.theme-dark .text-slate-700,
body.theme-dark .text-slate-600,
body.theme-dark .text-slate-500 {
  color: var(--ink) !important;
}

body.theme-dark .border-gray-200,
body.theme-dark .border-slate-200 {
  border-color: var(--border) !important;
}

body.theme-dark .status-draft { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
body.theme-dark .status-sent { background: rgba(59, 130, 246, 0.15); color: #bfdbfe; }
body.theme-dark .status-paid { background: rgba(22, 163, 74, 0.18); color: #bbf7d0; }

.signature-canvas {
  width: 100%;
  height: 180px;
  background: #fff;
  border-radius: 12px;
  touch-action: none;
}

#signature-wrapper {
  min-height: 180px;
}
