:root {
  --accent: #5b3df5;
  --side: #1d1147;
  --side-2: #2b1566;
  --bg: #f5f4fb;
  --card: #fff;
  --ink: #1d1a33;
  --muted: #6b6785;
  --line: #e9e6f4;
  --soft: #f3f0ff;
  --green: #15803d; --green-bg: #e7f7ec;
  --amber: #b45309; --amber-bg: #fdf3e2;
  --red: #c02646; --red-bg: #fde8ec;
  --blue: #1d5fd8; --blue-bg: #e6efff;
  --grey: #5f5b77; --grey-bg: #efedf5;
  --purple-bg: #efeaff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 17, 71, .04), 0 4px 14px rgba(29, 17, 71, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--soft); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
small { font-size: 12.5px; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.err { color: var(--red); }
.neg { color: var(--red); }
.pos { color: var(--green); }
.inline { display: inline; }

/* ---- app shell ---- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--side), var(--side-2)); color: #d9d3f5; display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 18px; padding: 2px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand em { font-style: normal; font-size: 11px; font-weight: 600; background: rgba(255,255,255,.9); color: var(--side); border-radius: 99px; padding: 2px 9px; margin-left: auto; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #8b6cff, #e05bc0); color: #fff; }
.brand-mark .i { width: 19px; height: 19px; }
.nav-group { margin-bottom: 14px; }
.nav-title { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: #9c93c9; padding: 8px 12px 6px; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: 12px; color: #e3ddff; padding: 9px 12px; border-radius: 10px; font-weight: 500; }
.nav-link:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav-link.active { background: #fff; color: var(--accent); font-weight: 600; }
.nav-link .count { margin-left: auto; background: #e05bc0; color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 7px; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 14px 6px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.who small { color: #a9a0d6; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.who .dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; margin-top: 6px; flex: none; }
.icon-btn { background: transparent; border: 1px solid rgba(255,255,255,.2); color: inherit; border-radius: 9px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.main { min-width: 0; }
.top { height: 64px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 28px; position: sticky; top: 0; z-index: 5; }
.top-title { font-size: 16px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; background: linear-gradient(135deg, var(--accent), #d24fbf); }
.menu-btn { display: none; color: var(--ink); border-color: var(--line); }
.content { padding: 28px; max-width: 1180px; }
.scrim { display: none; }
.impersonate { grid-column: 1 / -1; background: #fde68a; color: #713f12; padding: 8px 16px; font-size: 13px; text-align: center; font-weight: 600; }

/* ---- hero, cards, stats ---- */
.hero { background: linear-gradient(115deg, var(--accent) 0%, #7d3cf0 45%, #d24fbf 100%); color: #fff; border-radius: 18px; padding: 28px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; box-shadow: 0 10px 30px rgba(91, 61, 245, .18); }
.hero h2 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.hero p { margin: 6px 0 0; opacity: .9; }
.hero a:not(.btn) { color: #fff; text-decoration: underline; }
.hero-sm { padding: 20px 24px; }
.hero-sm h2 { font-size: 21px; }
.hero .badge { background: rgba(255,255,255,.92); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.narrow { max-width: 760px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -2px 0 14px; }
.card-head h3 { font-size: 16px; font-weight: 700; }
.card-head a:not(.btn) { font-size: 13px; font-weight: 600; color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: var(--ink); box-shadow: var(--shadow); display: block; }
a.stat:hover { text-decoration: none; border-color: #cfc6f5; }
.stat-head { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.stat-icon .i { width: 16px; height: 16px; }
.t-purple { background: linear-gradient(135deg, #7c5cff, #5b3df5); }
.t-amber { background: linear-gradient(135deg, #fbbf24, #f97316); }
.t-teal { background: linear-gradient(135deg, #2dd4bf, #0d9488); }
.t-pink { background: linear-gradient(135deg, #f472b6, #db2777); }
.t-green { background: linear-gradient(135deg, #4ade80, #16a34a); }
.stat-value { font-size: 28px; font-weight: 800; margin: 12px 0 4px; letter-spacing: -.02em; }
.stat-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cols-wide { grid-template-columns: minmax(0, 1fr) 320px; }
.cols > * { min-width: 0; }

/* ---- lists & tables ---- */
.list { margin: 0 -20px -20px; }
.list-sm { margin: 10px 0 0; }
.list-sm .row { padding: 8px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 20px; border-top: 1px solid var(--line); color: var(--ink); }
a.row:hover { background: #faf9ff; text-decoration: none; }
.row small { display: block; color: var(--muted); }
.row-end { display: flex; align-items: center; gap: 12px; }
.row.act { justify-content: flex-start; }
.row.act > div { flex: 1; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #a8a3c3; flex: none; }
.dot-staff { background: var(--accent); }
.dot-client { background: #10b981; }
.table { width: 100%; border-collapse: collapse; }
.card > .table { margin: -6px 0 -8px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: #faf9ff; }
.table a { color: var(--ink); }
.num { text-align: right !important; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 22px 10px; }
.empty div { margin-top: 12px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.dl-tight { gap: 6px 14px; font-size: 14px; }
.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 12px; margin-top: 14px; font-size: 14px; }

/* ---- badges ---- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-grey { background: var(--grey-bg); color: var(--grey); }
.b-purple { background: var(--purple-bg); color: var(--accent); }

/* ---- buttons & forms ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: 14px; border-radius: 10px; padding: 9px 16px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: #cfc6f5; background: #fcfbff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(91, 61, 245, .25); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.07); border-color: var(--accent); }
.btn-light { background: #fff; color: var(--accent); border-color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red); filter: brightness(1.07); }
.btn-danger-ghost { color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn-row form { margin: 0; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.actions-col { display: flex; flex-direction: column; gap: 10px; }
.actions-col form { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: end; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid2 .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: 13.5px; }
.field label small { font-weight: 400; color: var(--muted); }
.hint { color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #ddd8ee; border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(91, 61, 245, .25); border-color: var(--accent); }
input[type="color"] { padding: 4px; height: 42px; }
input[type="file"] { padding: 8px; background: #faf9ff; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; }
.check small { flex-basis: 100%; color: var(--muted); }
.money-in { display: flex; align-items: center; border: 1px solid #ddd8ee; border-radius: 10px; background: #fff; }
.money-in span { padding-left: 12px; color: var(--muted); }
.money-in input { border: 0; padding-left: 6px; }
.money-in:focus-within { outline: 2px solid rgba(91, 61, 245, .25); border-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 16px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.w-sm { width: 80px; padding: 5px 8px; font-size: 13px; }
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: 1fr 160px auto; gap: 10px; align-items: end; }
.search, .filters { display: flex; gap: 10px; margin-bottom: 18px; align-items: flex-end; }
.search input { max-width: 420px; }
.filters .field { width: 240px; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 16px; color: var(--muted); font-size: 13px; }
details.danger-zone summary { cursor: pointer; color: var(--red); font-weight: 600; font-size: 14px; padding: 6px 0; }
details.danger-zone[open] { border: 1px solid var(--red-bg); border-radius: 10px; padding: 10px 12px; }
.dept { border-top: 1px solid var(--line); padding: 14px 0; display: flex; flex-direction: column; gap: 12px; }
.dept:first-of-type { border-top: 0; padding-top: 0; }

/* ---- notices ---- */
.flash, .notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.flash .i, .notice .i { margin-top: 2px; }
.flash-ok, .notice { background: #eefbf2; color: #14532d; border: 1px solid #bbf0cc; }
.notice { background: var(--soft); color: #3b2a8c; border-color: #ddd3ff; }
.flash-err, .notice-err { background: var(--red-bg); color: #8a1531; border: 1px solid #f7c3cf; }

/* ---- client bits ---- */
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.product { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.product h3 { font-size: 18px; }
.product .price { font-size: 26px; font-weight: 800; color: var(--accent); }
.price small, .table small.per { font-size: 14px; color: var(--muted); font-weight: 500; }
.product-desc { color: var(--muted); flex: 1; }
.cycles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cycle { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; gap: 10px; cursor: pointer; }
.cycle:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.cycle span { display: flex; flex-direction: column; }
.saved-card { display: flex; gap: 14px; align-items: center; background: var(--soft); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.saved-card small { display: block; color: var(--muted); }
.secret { font-size: 15px; padding: 6px 10px; cursor: copy; }
.pay-box { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; border-color: #d9cffd; background: linear-gradient(180deg, #fff, #faf8ff); }
.pay-box h3 { font-size: 20px; }
.pay-box p { margin: 4px 0 0; }
.pay-actions { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.pay-box .bank { flex-basis: 100%; font-size: 14px; }
.pay-box .bank summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.invoice-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.invoice { padding: 34px; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.inv-brand { font-size: 22px; font-weight: 800; color: var(--accent); margin-bottom: 6px; }
.inv-meta { text-align: right; }
.inv-meta h2 { font-size: 20px; margin-bottom: 6px; }
.inv-meta dl { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 10px 0 0; justify-content: end; font-size: 14px; }
.inv-meta dt { color: var(--muted); }
.inv-meta dd { margin: 0; }
.inv-to { margin-bottom: 22px; }
.inv-to small { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.inv-lines tfoot td { border: 0; padding: 6px 10px; }
.inv-lines tfoot .total td { font-weight: 800; font-size: 16px; border-top: 1px solid var(--line); }
.inv-notes { margin-top: 18px; color: var(--muted); font-size: 14px; }
.close-form { margin-top: 12px; text-align: right; }

/* ---- tickets ---- */
.thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.msg { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.msg-staff { border-left: 4px solid var(--accent); }
.msg-internal { background: #fffbeb; border-color: #fde68a; border-left-color: #f59e0b; }
.msg header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.msg header time { margin-left: auto; color: var(--muted); font-size: 13px; }
.msg-body { overflow-wrap: anywhere; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.files a { display: inline-flex; align-items: center; gap: 6px; background: var(--soft); border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--ink); }
.files .i { width: 14px; height: 14px; }

/* ---- auth pages ---- */
.auth { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, #e9e2ff, transparent), radial-gradient(900px 500px at 110% 110%, #fbe1f3, transparent), var(--bg); }
.auth-wrap { max-width: 430px; margin: 0 auto; padding: 56px 16px; }
.auth-wrap.wide { max-width: 620px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 800; font-size: 20px; margin-bottom: 22px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px; box-shadow: 0 12px 40px rgba(29, 17, 71, .08); }
.auth-card h1 { font-size: 22px; margin-bottom: 18px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 18px; font-size: 14px; font-weight: 600; }
.cf-turnstile { min-height: 65px; }

/* ---- responsive ---- */
@media (max-width: 1050px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cols, .cols-wide { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 270px; transform: translateX(-100%); transition: transform .2s; z-index: 30; }
  body.menu-open .side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 10, 40, .45); z-index: 20; }
  .menu-btn { display: grid; }
  .top { padding: 0 16px; }
  .content { padding: 18px 16px; }
  .hero { padding: 22px 20px; flex-direction: column; align-items: flex-start; }
  .hero h2 { font-size: 22px; }
  .hide-sm { display: none !important; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .line { grid-template-columns: 1fr 110px; }
  .line .check { grid-column: 1 / -1; }
  .invoice { padding: 20px; }
  .inv-meta { text-align: left; }
  .inv-meta dl { justify-content: start; }
  .card { padding: 16px; }
  .list { margin: 0 -16px -16px; }
  .row { padding: 12px 16px; }
  .table td, .table th { padding: 10px 6px; }
  .search, .filters { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 22px; }
  .auth-card { padding: 22px; }
}

/* ---- print (invoices) ---- */
@media print {
  .side, .top, .no-print, .flash, .impersonate, .tabs { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .invoice { padding: 0; }
}
