:root {
  --navy: #071426;
  --navy-2: #10243f;
  --blue: #0d6adf;
  --blue-2: #1480f0;
  --blue-deep: #0a4eaa;
  --sky: #e8f2ff;
  --ice: #f4f8fd;
  --bg: #eef3f9;
  --card: #ffffff;
  --ink: #12243c;
  --muted: #5c6e86;
  --line: #dbe5f2;
  --green: #0b7d56;
  --green-bg: #e5f6ee;
  --amber: #9a6208;
  --amber-bg: #fff3df;
  --red: #b4233a;
  --red-bg: #fdecef;
  --slate: #3d5270;
  --slate-bg: #eef2f7;
  --shadow: 0 12px 32px rgba(16, 42, 78, 0.07);
  --radius: 16px;
  --side: 268px;
  --font: Manrope, "Segoe UI", sans-serif;
  --display: Sora, Manrope, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
img { max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }
::selection { background: #cfe4ff; }
h1, h2, h3, .stat-value { font-family: var(--display); letter-spacing: -0.03em; }

.nav-link svg,
.icon-btn svg,
.menu-btn svg,
.btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* Login */
.login-body {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at -10% -20%, rgba(20, 128, 240, 0.18), transparent 55%),
    radial-gradient(700px 380px at 110% 110%, rgba(13, 106, 223, 0.16), transparent 50%),
    var(--ice);
  color: var(--ink);
}
.login-grid {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
}
.login-story {
  padding: 48px 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-logo { width: min(230px, 50%); height: auto; display: block; }
.login-story h1 {
  margin: 28px 0 10px;
  font-size: clamp(32px, 4vw, 46px);
  line-height: 1.12;
  max-width: 640px;
}
.login-story .lede {
  margin: 0;
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
}
.story-list { list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 14px; max-width: 560px; }
.story-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.story-list b { display: block; font-size: 15px; }
.story-list span { color: var(--muted); font-size: 13.5px; }
.num {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--sky);
  color: var(--blue-deep);
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
}
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 28px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 28px 22px;
  box-shadow: 0 24px 60px rgba(16, 42, 78, 0.1);
}
.login-card h2 { margin: 0 0 6px; font-size: 28px; }
.login-card .sub { margin: 0 0 22px; color: var(--muted); }
.form-row { display: grid; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 13px; font-weight: 700; }
.control {
  height: 44px;
  border: 1px solid #cfdced;
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  outline: none;
}
.control:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(13, 106, 223, 0.15); }
.pass-wrap { position: relative; }
.pass-wrap .control { padding-right: 68px; }
.text-btn {
  position: absolute;
  right: 8px;
  top: 7px;
  height: 30px;
  border: 0;
  background: var(--sky);
  color: var(--blue-deep);
  border-radius: 8px;
  padding: 0 10px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: #b9cce4; }
.btn.primary {
  background: linear-gradient(180deg, var(--blue-2), var(--blue));
  border-color: var(--blue-deep);
  color: #fff;
  box-shadow: 0 8px 18px rgba(13, 106, 223, 0.25);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.block { width: 100%; height: 46px; margin-top: 4px; }
.btn.small { height: 36px; border-radius: 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.login-error {
  background: var(--red-bg);
  color: var(--red);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.demo-box {
  margin-top: 18px;
  background: var(--ice);
  border: 1px dashed #b9d2f2;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
}
.demo-box strong { display: block; margin-bottom: 6px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--blue-deep); }
.demo-box code {
  font-family: Consolas, "Courier New", monospace;
  background: #fff;
  border-radius: 6px;
  padding: 1px 6px;
}
.fine {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.fine a { font-weight: 700; }

/* App shell */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--side);
  background: linear-gradient(180deg, #08182c 0%, #071426 40%, #0a1c34 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.brand-plate {
  margin: 16px 16px 8px;
  background: #fff;
  border-radius: 14px;
  padding: 8px 10px 6px;
}
.brand-plate img { display: block; width: 100%; height: auto; }
.product-name {
  margin: 2px 20px 14px;
  color: #8eb4df;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.side-nav { padding: 0 12px 16px; overflow: auto; }
.nav-label {
  margin: 14px 10px 6px;
  color: #7f9cbc;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d7e6f8;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}
.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--blue); color: #fff; }
.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--blue);
  font-size: 12px;
  font-weight: 800;
  flex: none;
}
.who { min-width: 0; }
.who strong, .who span { display: block; }
.who strong { font-size: 13px; }
.who span {
  color: #9db6d4;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn, .menu-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: auto;
}
.menu-btn {
  display: none;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  margin-left: 0;
}
.backdrop { position: fixed; inset: 0; background: rgba(7, 20, 38, 0.48); z-index: 25; }
.main { margin-left: var(--side); min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 28px 0;
}
.topbar h1 { margin: 0; font-size: 26px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.page { padding: 18px 28px 36px; }
.page-foot { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.print-only { display: none; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat, .panel, .customer-card, .metric-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 16px 16px 14px; position: relative; overflow: hidden; }
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--blue);
}
.stat.green::before { background: var(--green); }
.stat.amber::before { background: #e09a22; }
.stat.red::before { background: var(--red); }
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat-value { margin: 8px 0 2px; font-size: 28px; font-weight: 700; }
.stat-meta { margin: 0; color: var(--muted); font-size: 13px; }
.metric-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px;
}
.metric-row div { padding: 12px 14px; }
.metric-row div + div { border-left: 1px solid var(--line); }
.metric-row b { display: block; font-family: var(--display); font-size: 18px; }
.metric-row span { color: var(--muted); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 14px; margin-top: 14px; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.panel { padding: 16px 16px 14px; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; font-weight: 700; }
.swatch { width: 9px; height: 9px; border-radius: 99px; display: inline-block; margin-right: 6px; }
.swatch.in { background: var(--blue); }
.swatch.out { background: #f0b429; }

.bars {
  height: 190px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  align-items: end;
}
.bar-col { display: grid; justify-items: center; gap: 6px; height: 100%; align-content: end; }
.bar-pair { display: flex; align-items: flex-end; gap: 4px; height: 160px; }
.bar { width: 14px; border-radius: 7px 7px 3px 3px; min-height: 4px; }
.bar.in { background: linear-gradient(180deg, #49a4ff, var(--blue)); }
.bar.out { background: linear-gradient(180deg, #ffd37a, #e09a22); }
.bar-col span { font-size: 12px; color: var(--muted); font-weight: 700; }

.donut-wrap { display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: center; }
.donut {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: conic-gradient(#0b7d56 0 50%, #e09a22 0 75%, #d14343 0 87.5%, #3d93f5 0 100%);
  display: grid;
  place-items: center;
}
.donut span {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.2;
}
.donut strong { display: block; color: var(--ink); font-size: 18px; font-family: var(--display); }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend-list li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

.pipe { display: grid; grid-template-columns: 92px 1fr 24px; gap: 8px; align-items: center; margin: 8px 0; font-size: 13px; }
.track { height: 8px; background: var(--ice); border-radius: 99px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.pipe b { text-align: right; }

.banner {
  margin-top: 14px;
  border-radius: var(--radius);
  padding: 18px 20px;
  background:
    radial-gradient(500px 120px at 100% 0%, rgba(73, 164, 255, 0.35), transparent 50%),
    linear-gradient(135deg, #0b3f86, #0d6adf 55%, #1492ff);
  color: #fff;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}
.banner h2 { margin: 0 0 6px; font-size: 22px; color: #fff; }
.banner p { margin: 0; max-width: 720px; color: rgba(255,255,255,0.88); }
.banner .btn { background: #fff; color: var(--blue-deep); border-color: #fff; }

.activity { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.activity li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: start; font-size: 14px; }
.activity i { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); margin-top: 6px; }
.activity small { display: block; color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.toolbar .control { width: auto; }
.toolbar input[type="search"] { width: min(280px, 100%); }
.toolbar select { min-width: 150px; }
.result-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 10px;
}
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 12px 10px; border-bottom: 1px solid #edf2f8; vertical-align: middle; }
table.data tr:hover td { background: #f7fbff; }
table.data .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.tag.paid, .tag.active, .tag.won { background: var(--green-bg); color: var(--green); }
.tag.pending, .tag.proposal, .tag.contacted { background: var(--amber-bg); color: var(--amber); }
.tag.overdue, .tag.lost, .tag.pastdue { background: var(--red-bg); color: var(--red); }
.tag.draft, .tag.new, .tag.demo { background: var(--sky); color: var(--blue-deep); }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

.customer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.customer-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.customer-card h3 { margin: 0; font-size: 18px; }
.customer-card p { margin: 0; color: var(--muted); font-size: 13px; }
.customer-card .fee { font-family: var(--display); font-size: 22px; color: var(--ink); font-weight: 700; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.plan-pill {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-deep);
  background: var(--sky);
  border-radius: 99px;
  padding: 4px 8px;
}

.note {
  background: var(--sky);
  border-radius: 12px;
  padding: 10px 12px;
  color: #1c3f6e;
  font-size: 13px;
  margin: 0 0 12px;
}

.split-settings { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 700; }
.about-list { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.about-list li { margin: 6px 0; }

/* Invoice */
.sheet-stage { background: #e6eef8; border-radius: 18px; padding: 22px 12px 32px; }
.invoice-sheet {
  width: min(860px, 100%);
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(16, 42, 78, 0.12);
  padding: 28px 32px 22px;
  position: relative;
  overflow: hidden;
}
.invoice-sheet::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 8px;
  background: linear-gradient(90deg, #0a4eaa, #1a84f0 55%, #6eb6ff);
}
.inv-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-top: 8px; }
.inv-logo { width: min(340px, 58%); height: auto; }
.inv-id { text-align: right; }
.inv-kicker {
  display: block;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}
.inv-id strong { display: block; font-family: var(--display); font-size: 26px; margin-top: 2px; }
.stamp {
  display: inline-block;
  margin-top: 8px;
  border: 2px solid currentColor;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.stamp.paid { color: var(--green); }
.stamp.pending { color: var(--amber); }
.stamp.overdue { color: var(--red); }
.stamp.draft { color: var(--blue-deep); }
.watermark {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) rotate(-16deg);
  font-family: var(--display);
  font-size: 92px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink);
  opacity: 0.05;
  pointer-events: none;
  white-space: nowrap;
}
.inv-parties {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 0.9fr;
  gap: 16px;
  margin: 22px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.inv-parties h3, .inv-foot h3 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.inv-parties p { margin: 0; font-size: 14px; }
.inv-meta { display: grid; gap: 8px; }
.inv-meta div { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.inv-meta span { color: var(--muted); }
table.inv-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
table.inv-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: var(--navy);
  padding: 9px 10px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
table.inv-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.inv-table small { display: block; color: var(--muted); }
table.inv-table .num { text-align: right; }
.inv-bottom { display: flex; justify-content: space-between; gap: 24px; margin-top: 16px; }
.inv-notes { max-width: 460px; font-size: 13px; color: #3e516b; }
.inv-notes p { margin: 0 0 8px; }
.inv-totals { width: min(280px, 100%); }
.inv-totals div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; }
.inv-totals .grand {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 2px solid var(--navy);
  font-size: 18px;
  font-family: var(--display);
  font-weight: 700;
}
.inv-foot {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}
.inv-contact { margin: 0; font-weight: 800; color: var(--blue-deep); font-size: 13px; }
.inv-tag { margin: 2px 0 0; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

@media (max-width: 1100px) {
  .stat-grid, .metric-row { grid-template-columns: 1fr 1fr; }
  .metric-row div:nth-child(3) { border-left: 0; }
  .grid-2, .grid-2.even, .split-settings { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .menu-btn { display: inline-flex; }
  .sidebar { transform: translateX(-105%); transition: transform 0.2s ease; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
  .login-grid { grid-template-columns: 1fr; }
  .login-story { display: none; }
  .login-panel { padding-top: 28px; }
  .mobile-logo { display: block !important; width: min(160px, 50%); margin: 0 auto 16px; }
}
.mobile-logo { display: none; }
@media (max-width: 720px) {
  .stat-grid, .metric-row { grid-template-columns: 1fr; }
  .metric-row div + div { border-left: 0; border-top: 1px solid var(--line); }
  .banner { flex-direction: column; align-items: flex-start; }
  .inv-parties, .inv-bottom, .inv-foot, .inv-head { display: block; }
  .inv-id, .inv-logo { text-align: left; width: 100%; margin-top: 8px; }
  .donut-wrap { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; }
  .no-print, .sidebar, .topbar, .backdrop, .page-foot { display: none !important; }
  .print-only { display: block; margin-bottom: 12px; }
  .print-only img { width: 220px; }
  .main { margin: 0 !important; }
  .page { padding: 0 !important; }
  .sheet-stage { background: #fff; padding: 0; }
  .invoice-sheet {
    box-shadow: none;
    width: auto;
    max-width: none;
    border-radius: 0;
    padding: 8px 0 0;
  }
  .stat, .panel, .metric-row, .banner, .bar, .donut, .tag, .invoice-sheet::before {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .banner { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
