:root {
  --bg: #0f172a;
  --card: #111827;
  --muted: #94a3b8;
  --text: #e5e7eb;
  --primary: #22d3ee;
  --primary-600: #0891b2;
  --danger: #ef4444;
  --ring: rgba(34, 211, 238, .35);
}
* { 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, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 600px at 80% -10%, #123, rgba(0,0,0,0) 60%),
              radial-gradient(900px 400px at -10% 110%, #022, rgba(0,0,0,0) 60%),
              var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 24px;
}
.card {
  width: 100%;
  /*max-width: 420px;*/
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 28px;
}
.header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  color: #062028; background: linear-gradient(135deg, var(--primary), #60a5fa);
  box-shadow: 0 6px 20px rgba(34, 211, 238, .35); font-weight: 800;
}
h1 { font-size: 20px; margin: 0; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

form { display: grid; gap: 14px; margin-top: 12px; }
label { font-size: 13px; color: var(--muted); }
.input {
  display: flex; align-items: center; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.09); border-radius: 12px; padding: 10px 12px;
  transition: border .2s ease, box-shadow .2s ease;
}
.input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.input input {
  width: 100%; background: transparent; border: 0; outline: none; color: var(--text);
  font-size: 15px; padding: 4px 2px;
}
.actions { display: grid; gap: 10px; margin-top: 6px; }
button[type="submit"] {
  height: 42px; border: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  color: #062028; font-weight: 700; font-size: 15px; cursor: pointer;
  box-shadow: 0 10px 20px rgba(34, 211, 238, .25), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .06s ease, filter .2s ease, opacity .2s ease;
  display: inline-flex; align-items: center; justify-content: center;
}
button[type="submit"]:hover { filter: brightness(1.05); }
button[type="submit"]:active { transform: translateY(1px); }
button[disabled] { opacity: .75; cursor: not-allowed; }

.msg { font-size: 13px; line-height: 1.4; min-height: 18px; }
.msg.error { color: var(--danger); }
.msg.success { color: #34d399; }

.footer { text-align: center; margin-top: 12px; color: var(--muted); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Page layout */
.page { display: grid; gap: 16px; width: 100%; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Buttons */
.btn {
  height: 36px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06);
  color: var(--text); border-radius: 10px; padding: 0 12px; cursor: pointer;
  transition: background .2s ease, border-color .2s ease, transform .06s ease;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn:hover { background: rgba(255,255,255,.09); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .7; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #60a5fa); color: #062028; border-color: rgba(34,211,238,.35); box-shadow: 0 10px 20px rgba(34, 211, 238, .25), inset 0 1px 0 rgba(255,255,255,.35); }
.btn-lg { height: 44px; padding: 0 16px; font-weight: 700; }
.btn-sm { height: 32px; padding: 0 10px; border-radius: 8px; }

/* Date input */
.input-date {
  height: 32px; background: rgba(255,255,255,.06); color: var(--text);
  border: 1px solid rgba(255,255,255,.12); border-radius: 8px; padding: 0 10px; outline: none;
}
.input-date:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input-date::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.85); cursor: pointer; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat-card { background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 12px; }
.stat-title { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 18px; font-weight: 700; margin-top: 4px; }

@media (max-width: 900px){ .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px){ .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px){ body { padding: 12px; } .card { padding: 18px; } }

/* Responsive canvas */
canvas { max-width: 100%; width: 100%; height: auto; display: block; }

/* List and invoice cards */
.list { display: grid; gap: 12px; }
.invoice {
  background: rgba(255,255,255,.02); border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px; padding: 12px;
}
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.title { font-weight: 700; font-size: 16px; }
.amount { font-weight: 800; }
.amount-raw { font-size: 12px; color: var(--muted); line-height: 1.2; }
.meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  background: rgba(34, 211, 238, .1); color: var(--text); border: 1px solid rgba(34, 211, 238, .25);
  font-size: 12px; font-weight: 600;
}

/* Progress bar */
.bar-wrap {
  position: relative; margin-top: 10px; height: 10px; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08); border-radius: 999px; overflow: hidden;
}
.bar-fill { height: 100%; background: linear-gradient(135deg, var(--primary), #60a5fa); box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }

/* Empty state */
.empty { text-align: center; color: var(--muted); padding: 16px 0; }

/* Tool actions */
.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
/* Compact segmented nav for date controls */
.date-nav {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: max-content; gap: 6px; align-items: center;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 6px 8px;
}

/* Compact adjustments */
.invoice { padding: 10px; }
.meta { gap: 8px; }

/* Utility: hide on small screens */
@media (max-width: 700px){
  .tool-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .date-nav { grid-auto-flow: row; grid-template-columns: repeat(4, max-content); justify-content: start; }
  .btn-lg { height: 40px; padding: 0 14px; }
}
@media (max-width: 640px){ .hide-sm { display: none !important; } }
