:root{
  --bg: #0b1220;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(255,255,255,.09);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --border: rgba(255,255,255,.10);
  --brand: #7c5cff;
  --brand2:#22c55e;
  --danger:#ef4444;
  --warn:#f59e0b;
  --shadow: 0 12px 28px rgba(0,0,0,.35);
  --radius: 16px;
  --radius2: 12px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 15% 10%, rgba(124,92,255,.22), transparent 60%),
    radial-gradient(900px 500px at 80% 15%, rgba(34,197,94,.18), transparent 55%),
    radial-gradient(1200px 800px at 50% 100%, rgba(59,130,246,.10), transparent 60%),
    var(--bg);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  padding: 26px;
}

a{ color: inherit; text-decoration:none; }
a:hover{ opacity:.9; }
small{ color:var(--muted); }

.container{
  max-width: 1600px;
  margin: 0 auto;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  border-radius: var(--radius);
  box-shadow: var(--shadow);

  position: sticky;
  top: 16px;
  z-index: 50;
  backdrop-filter: blur(10px);
}

@media (max-width: 760px){
  .topbar{
    flex-direction: column;
    align-items: stretch;
  }
  .nav{
    justify-content: flex-start;
  }
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight: 700;
  letter-spacing:.2px;
}

.brand-badge{
  width:34px;
  height:34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), rgba(124,92,255,.55));
  display:grid;
  place-items:center;
  box-shadow: 0 10px 24px rgba(124,92,255,.25);
}

.nav{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}

.nav a{
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted);
}

.nav a:hover{
  background: rgba(255,255,255,.06);
  border-color: var(--border);
  color: var(--text);
}

.nav a.is-active{
  background: rgba(255,255,255,.06);
  border-color: var(--border);
  color: var(--text);
}

.dashboard{
  display:flex;
  flex-direction:column;
  gap: 18px;
}

.dashboard-head{
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.dashboard-title{
  margin:0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .2px;
}

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

.dashboard-section{
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.dashboard-section-title{
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.stats-grid{
  display:grid;
  gap: 12px;
}

.stats-grid-3{
  grid-template-columns: 1fr;
}

.stats-grid-2{
  grid-template-columns: 1fr;
}

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

.stat-card{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-height: 92px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
}

.stat-title{
  font-size: 13px;
  color: var(--muted);
}

.stat-value{
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: .2px;
  margin-top: 6px;
}

.stat-hint{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.stat-hint code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  padding: 2px 6px;
  border-radius: 999px;
}

.card{
  margin-top: 18px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.card-header{
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.card-title{
  margin:0;
  font-size: 18px;
}

.card-body{
  padding: 16px 18px;
}

.card.compact .card-header{ padding: 12px 14px; }
.card.compact .card-body{ padding: 12px 14px; }

.card.muted{
  background: rgba(255,255,255,.035);
  box-shadow: 0 10px 22px rgba(0,0,0,.28);
}

.stat-card{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stat-title{
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value{
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.stat-hint{
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.flash{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  background: rgba(255,255,255,.06);
}

.flash.ok{
  border-color: rgba(34,197,94,.35);
  background: rgba(34,197,94,.10);
}

.flash.err{
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.10);
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor:pointer;
}

.btn:hover{ background: rgba(255,255,255,.10); }

.btn-primary{
  border-color: rgba(124,92,255,.45);
  background: linear-gradient(135deg, rgba(124,92,255,.90), rgba(124,92,255,.55));
}

.btn-primary:hover{ filter: brightness(1.05); }

.btn-danger{
  border-color: rgba(239,68,68,.45);
  background: rgba(239,68,68,.15);
}

.btn-warn{
  border-color: rgba(245,158,11,.45);
  background: rgba(245,158,11,.14);
}

.btn-ghost{
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover{
  border-color: var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
}

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

.btn[disabled],
.btn.is-disabled{
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}

.table th,
.table td{
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  vertical-align: middle;
}

.table th{
  color: var(--muted);
  font-weight:600;
  text-align:left;
  background: rgba(255,255,255,.04);
}

.table tr:hover td{
  background: rgba(255,255,255,.03);
}

.table-wrap{
  width: 100%;
  overflow:auto;
  border-radius: var(--radius2);
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
}

.table tr:last-child td{ border-bottom: 0; }

.badge{
  display:inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
}

.badge.paid{
  background: rgba(34,197,94,.12);
  border-color: rgba(34,197,94,.35);
  color: #bff7cf;
}

.badge.sent{
  background: rgba(59,130,246,.12);
  border-color: rgba(59,130,246,.35);
  color: #cfe2ff;
}

.badge.overdue{
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.35);
  color: #ffd1d1;
}

.input, select, textarea{
  width:100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.15);
  color: var(--text);
  outline:none;
}

.input:focus, select:focus, textarea:focus{
  border-color: rgba(124,92,255,.55);
  box-shadow: 0 0 0 4px rgba(124,92,255,.18);
}

.form-row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 760px){
  .form-row{ grid-template-columns: 1fr; }
}

.form-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.help{
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.footer{
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  text-align:center;
}

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.input:focus-visible,
select:focus-visible,
textarea:focus-visible{
  outline: none;
  box-shadow: 0 0 0 4px rgba(124,92,255,.20);
  border-color: rgba(124,92,255,.65);
}

dialog.modal{
  border: none;
  padding: 0;
  background: transparent;
  max-width: 760px;
  width: calc(100% - 24px);
  border-radius: var(--radius);
}

dialog.modal::backdrop{
  background: rgba(0,0,0,.60);
  backdrop-filter: blur(6px);
}

.modal-surface{
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  background: rgba(11,18,32,.95);
  padding: 16px;
}

.invoice-table td { vertical-align: top; }

.invoice-table .cell-stack{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-height: 56px; 
  justify-content:flex-start;
}

.invoice-table .cell-sub{
  min-height: 14px;
  line-height: 14px;
  font-size: 12px;
  color: var(--muted);
  opacity: .9;
}

.invoice-table .cell-sub.placeholder{
  visibility: hidden; 
}

.invoice-table .cell-sub strong{
  color: var(--text);
  opacity: .95;
}
