@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #070913;
  --bg-gradient: radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.08), transparent 35%),
                 radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.05), transparent 40%),
                 radial-gradient(circle at 50% 50%, rgba(30, 41, 59, 0.3), transparent 60%),
                 var(--bg);
  --sidebar-bg: rgba(8, 12, 26, 0.65);
  --brand-gradient: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
  --panel: rgba(15, 23, 42, 0.55);
  --panel-solid: #0d1527;
  --panel-soft: rgba(30, 41, 59, 0.4);
  --line: rgba(255, 255, 255, 0.05);
  --line-focus: rgba(56, 189, 248, 0.35);
  --text: #f8fafc;
  --muted: #8493a8;
  --green: #10b981;
  --red: #f43f5e;
  --yellow: #fbbf24;
  --blue: #38bdf8;
  
  /* Gradients */
  --grad-primary: linear-gradient(135deg, #38bdf8 0%, #0369a1 100%);
  --grad-success: linear-gradient(135deg, #10b981 0%, #047857 100%);
  --grad-danger: linear-gradient(135deg, #f43f5e 0%, #be123c 100%);
  --grad-warning: linear-gradient(135deg, #fbbf24 0%, #b45309 100%);
  --grad-panel: linear-gradient(135deg, rgba(23, 37, 84, 0.15) 0%, rgba(15, 23, 42, 0.4) 100%);

  /* Shadows & Glows */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 20px 48px -8px rgba(0, 0, 0, 0.6);
  --shadow-blue-glow: 0 0 24px rgba(56, 189, 248, 0.15);
  --shadow-green-glow: 0 0 24px rgba(16, 185, 129, 0.15);
  --shadow-red-glow: 0 0 24px rgba(244, 63, 94, 0.15);
  --shadow-yellow-glow: 0 0 24px rgba(251, 191, 36, 0.12);

  --radius: 16px;
  --radius-lg: 24px;
  --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  
  --nav-active-bg: linear-gradient(90deg, rgba(56, 189, 248, 0.08) 0%, rgba(56, 189, 248, 0.01) 100%);
  --nav-active-shadow: inset 2px 0 10px rgba(56, 189, 248, 0.05);
}

:root.light-theme {
  --bg: #f1f5f9;
  --bg-gradient: radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.05), transparent 35%),
                 radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.03), transparent 40%),
                 var(--bg);
  --sidebar-bg: rgba(255, 255, 255, 0.65);
  --brand-gradient: linear-gradient(135deg, #0f172a 40%, #475569 100%);
  --panel: rgba(255, 255, 255, 0.7);
  --panel-solid: #ffffff;
  --panel-soft: rgba(241, 245, 249, 0.85);
  --line: rgba(15, 23, 42, 0.08);
  --line-focus: rgba(14, 165, 233, 0.4);
  --text: #0f172a;
  --muted: #64748b;
  --blue: #0284c7;

  /* Shadows for Light Theme */
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-blue-glow: 0 0 20px rgba(14, 165, 233, 0.04);
  --shadow-green-glow: 0 0 20px rgba(16, 185, 129, 0.04);
  --shadow-red-glow: 0 0 20px rgba(244, 63, 94, 0.04);
  --shadow-yellow-glow: 0 0 20px rgba(251, 191, 36, 0.04);

  --grad-panel: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(241, 245, 249, 0.5) 100%);
  
  --nav-active-bg: linear-gradient(90deg, rgba(2, 132, 199, 0.08) 0%, rgba(2, 132, 199, 0.01) 100%);
  --nav-active-shadow: inset 2px 0 10px rgba(2, 132, 199, 0.02);
}

/* Bulletproof Global Navigation Icon Size Constraints */
svg.nav-icon, 
.nav-icon, 
.sidebar-nav a svg {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  max-width: 20px !important;
  max-height: 20px !important;
  margin-right: 14px !important;
  fill: currentColor !important;
  display: inline-block !important;
  vertical-align: middle !important;
  flex: 0 0 20px !important;
  transition: var(--transition) !important;
}

.sidebar-nav a svg.nav-icon,
.sidebar-nav a svg {
  color: var(--muted) !important;
  opacity: 0.76 !important;
}

.sidebar-nav a:hover svg.nav-icon,
.sidebar-nav a:hover svg,
.sidebar-nav a.active svg.nav-icon,
.sidebar-nav a.active svg {
  opacity: 1 !important;
  color: var(--blue) !important;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.3)) !important;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

/* Custom Scrollbar for Webkit */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg-gradient);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

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

/* Sidebar */
.sidebar {
  padding: 40px 24px;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 100;
}

.brand {
  display: grid;
  gap: 4px;
  padding-bottom: 40px;
}

.brand-kicker {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .25em;
  color: var(--blue);
  font-weight: 700;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.brand strong {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  align-content: start;
  flex-grow: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  position: relative;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.025);
  border-color: rgba(255, 255, 255, 0.04);
}

.sidebar-nav a.active {
  background: var(--nav-active-bg);
  border-left: 3px solid var(--blue);
  font-weight: 600;
  box-shadow: var(--nav-active-shadow);
}

/* Main Content Area */
.main-content {
  padding: 48px;
  overflow-y: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 36px;
}

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--muted);
  font-weight: 600;
}

.page-header h1 {
  margin: 6px 0 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Cards & Layout */
.grid {
  display: grid;
  gap: 24px;
}

.grid.cards {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.card, .table-wrap, .form-card, .login-card, .invoice-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: var(--transition);
  position: relative;
}

.card {
  padding: 26px;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 60%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
}

/* Dashboard Metric Cards decoration */
.card-metric-green {
  border-left: 4px solid var(--green);
}
.card-metric-green:hover {
  box-shadow: var(--shadow-green-glow), var(--shadow-lg);
}

.card-metric-red {
  border-left: 4px solid var(--red);
}
.card-metric-red:hover {
  box-shadow: var(--shadow-red-glow), var(--shadow-lg);
}

.card-metric-yellow {
  border-left: 4px solid var(--yellow);
}
.card-metric-yellow:hover {
  box-shadow: var(--shadow-yellow-glow), var(--shadow-lg);
}

.card-metric-blue {
  border-left: 4px solid var(--blue);
}
.card-metric-blue:hover {
  box-shadow: var(--shadow-blue-glow), var(--shadow-lg);
}

.stat-value {
  font-size: 38px;
  font-weight: 700;
  margin-top: 10px;
  letter-spacing: -0.02em;
}

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

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

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  color: #fff;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-primary {
  background: var(--grad-success);
  border: none;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: var(--shadow-green-glow);
}

.btn-danger {
  background: var(--grad-danger);
  border: none;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.2);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  box-shadow: var(--shadow-red-glow);
}

.btn-warning {
  background: var(--grad-warning);
  border: none;
  box-shadow: 0 4px 14px rgba(251, 191, 36, 0.2);
}
.btn-warning:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  box-shadow: var(--shadow-yellow-glow);
}

.btn-soft {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--muted);
}
.btn-soft:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.btn-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  border-radius: 12px;
}
.btn-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.actions-grid {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}
.actions-grid .btn-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
}
.actions-grid .btn-icon svg {
  width: 14px;
  height: 14px;
}

/* Tables */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 20, 38, 0.4);
}

.page-toolbar {
  margin-bottom: 24px;
  justify-content: flex-end;
}

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

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

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 700;
  background: rgba(10, 15, 30, 0.3);
}

tr {
  transition: var(--transition);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-success {
  background: rgba(16, 185, 129, 0.06);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.15);
}
.badge-warning {
  background: rgba(245, 158, 11, 0.06);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.15);
}
.badge-danger {
  background: rgba(244, 63, 94, 0.06);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.15);
}
.badge-muted {
  background: rgba(148, 163, 184, 0.06);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.15);
}

/* Form Styles */
.form-card, .login-card, .invoice-shell {
  padding: 40px;
}
.form-card-wide {
  max-width: 1000px;
}
.form-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-group {
  display: grid;
  gap: 8px;
}
.input-stack {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.btn-inline {
  width: auto;
  justify-self: start;
}
.form-actions-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 12, 26, 0.5);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 15px;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  background: rgba(8, 12, 26, 0.8);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 32px;
  align-items: start;
}

/* Alerts */
.alert {
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.4;
}
.alert-success {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.15);
  color: #a7f3d0;
}
.alert-danger {
  background: rgba(244, 63, 94, 0.06);
  border-color: rgba(244, 63, 94, 0.15);
  color: #fecdd3;
}
.alert-warning {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.15);
  color: #fde68a;
}

/* Mobile & Responsive */
.mobile-cards {
  display: none;
  gap: 16px;
}

.client-card {
  padding: 24px;
  border-radius: var(--radius);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: 
    radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.06), transparent 30%),
    var(--bg);
}

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

/* Invoice view design */
.invoice-shell {
  max-width: 900px;
  margin: 40px auto;
  border-radius: 24px;
}

.invoice-shell-enhanced {
  padding: 44px;
  background:
    radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.06), transparent 35%),
    linear-gradient(180deg, rgba(23, 37, 84, 0.25) 0%, rgba(13, 20, 38, 0.7) 100%);
}

.invoice-topline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.invoice-meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.invoice-qr-card,
.invoice-info-card {
  min-width: 0;
}

.invoice-facts {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.invoice-fact {
  display: grid;
  gap: 4px;
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--line);
}

.invoice-fact span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}

.invoice-fact strong {
  font-size: 16px;
  word-break: break-word;
}

.invoice-actions {
  align-items: stretch;
}

.qr-box {
  min-height: 280px;
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.pix-code {
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(8, 12, 26, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  font-family: monospace;
  font-size: 14px;
  color: var(--muted);
}

/* Modals */
.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: modalFadeIn 0.3s ease;
}

.admin-modal-shell {
  width: min(1080px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(8, 12, 26, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: 0 32px 64px -12px rgba(0, 0, 0, 0.8), var(--shadow-blue-glow);
  padding: 40px;
  animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.admin-modal-head > div {
  flex: 1;
  min-width: 0;
}

.admin-modal-head h2 {
  margin: 6px 0 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.admin-modal-close {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font-size: 26px;
  font-weight: 400;
  flex: 0 0 40px;
  line-height: 1;
  padding: 0;
  transition: var(--transition);
}

.admin-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.admin-modal-form {
  padding-bottom: 4px;
  min-width: 0;
}

/* Animations */
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive adjustments */
@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 30px 24px;
  }
  .split, .form-grid {
    grid-template-columns: 1fr;
  }
  .admin-modal-shell {
    padding: 28px;
  }
  .admin-modal-head h2 {
    font-size: 24px;
  }
}

@media (max-width: 720px) {
  .main-content {
    padding: 24px;
  }
  .page-header h1 {
    font-size: 28px;
  }
  .desktop-only {
    display: none;
  }
  .mobile-cards {
    display: grid;
  }
  .btn {
    width: 100%;
    justify-content: center;
  }
  .btn-inline {
    width: 100%;
    justify-self: stretch;
  }
  .input-stack {
    grid-template-columns: 1fr;
  }
  .form-actions-bar {
    position: static;
    background: transparent;
  }
  .page-toolbar {
    justify-content: stretch;
  }
  .admin-modal-backdrop {
    padding: 12px;
  }
  .admin-modal-shell {
    width: 100%;
    max-height: calc(100vh - 24px);
    border-radius: 20px;
    padding: 20px;
  }
  .invoice-shell {
    margin: 0;
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .invoice-shell-enhanced {
    padding: 24px;
  }
  .invoice-shell-enhanced h1 {
    font-size: 28px;
    line-height: 1.2;
  }
  .invoice-topline {
    display: grid;
    grid-template-columns: 1fr;
  }
  .invoice-meta-chip,
  .invoice-shell .badge {
    justify-content: center;
    width: 100%;
  }
  .invoice-qr-card,
  .invoice-info-card {
    padding: 20px;
  }
  .qr-box {
    min-height: 240px;
    padding: 16px;
  }
  .stat-value {
    font-size: 32px;
  }
  .invoice-facts {
    grid-template-columns: 1fr;
  }
  .pix-code {
    font-size: 13px;
    padding: 12px;
  }
  .invoice-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .invoice-actions .btn {
    min-height: 48px;
  }
}
