/* =============================================================================
   Lovely Pixel - Invoicing Platform : UI
   A clean, modern back-office design system. Light theme, accent-driven.
   The accent colour is injected per-request via --accent (from settings).
   ========================================================================== */

:root{
  --accent:#6C4CF1;
  --ink:#1c2333;
  --ink-soft:#5b6472;
  --muted:#8a92a3;
  --line:#e7e9f0;
  --line-soft:#eef0f5;
  --bg:#f5f6fa;
  --card:#ffffff;
  --radius:14px;
  --radius-sm:10px;
  --shadow:0 1px 2px rgba(20,25,40,.04), 0 8px 24px rgba(20,25,40,.06);
  --green:#1a7f43; --green-bg:#e7f7ec; --green-line:#bfe8cd;
  --red:#c02626; --red-bg:#fdecec; --red-line:#f4c9c9;
  --amber:#9a6a00; --amber-bg:#fdf3dc; --amber-line:#f0dca4;
  --blue:#3548c0; --blue-bg:#eaeefb; --blue-line:#cdd6f6;
  --grey:#5b6472; --grey-bg:#eef0f4; --grey-line:#dde1e9;
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:var(--bg); color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  font-size:14.5px; line-height:1.55; -webkit-font-smoothing:antialiased;
}
a{ color:var(--accent); text-decoration:none; }
h1{ font-size:24px; letter-spacing:-.02em; margin:0; }
h2{ font-size:17px; margin:0; }

/* ---------- App shell ---------- */
.shell{ display:flex; min-height:100vh; }
.side{
  width:240px; flex:0 0 240px; background:#fff; border-right:1px solid var(--line);
  display:flex; flex-direction:column; padding:20px 14px; position:sticky; top:0; height:100vh;
}
.brand{ display:flex; align-items:center; gap:11px; padding:6px 8px 20px; color:var(--ink); }
.brand__mark{
  width:38px; height:38px; border-radius:11px; background:var(--accent); color:#fff;
  display:grid; place-items:center; font-weight:800; letter-spacing:-.03em; font-size:15px;
  box-shadow:0 4px 12px rgba(108,76,241,.35);
}
.brand__txt{ display:flex; flex-direction:column; line-height:1.15; }
.brand__txt strong{ font-size:15px; }
.brand__txt small,.brand small{ color:var(--muted); font-size:12px; }
.nav{ display:flex; flex-direction:column; gap:3px; margin-top:6px; }
.nav__link{
  display:flex; align-items:center; gap:11px; padding:10px 12px; border-radius:10px;
  color:var(--ink-soft); font-weight:600; font-size:14px;
}
.nav__link svg{ width:19px; height:19px; opacity:.85; }
.nav__link:hover{ background:var(--line-soft); color:var(--ink); }
.nav__link.is-active{ background:color-mix(in srgb, var(--accent) 12%, #fff); color:var(--accent); }
.side__foot{ margin-top:auto; border-top:1px solid var(--line-soft); padding-top:10px; }
.main{ flex:1; min-width:0; padding:30px 34px 70px; max-width:1180px; }

/* ---------- Page head ---------- */
.page-head{ display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom:22px; }
.page-head .muted{ margin:4px 0 0; }
.back{ display:inline-block; color:var(--muted); font-size:13px; font-weight:600; margin-bottom:6px; }
.back:hover{ color:var(--accent); }
.head-actions{ display:flex; gap:10px; }

/* ---------- Cards ---------- */
.card{ background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:22px; margin-bottom:20px; }
.card__head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; gap:12px; }
.card__title{ margin:0 0 16px; font-size:15px; letter-spacing:.01em; }
.card--danger{ border-color:var(--red-line); background:#fffafa; }

/* ---------- Stats ---------- */
.stat-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:22px; }
.stat{ background:#fff; border:1px solid var(--line); border-radius:var(--radius); padding:18px 20px;
  box-shadow:var(--shadow); display:flex; flex-direction:column; gap:5px; position:relative; overflow:hidden; }
.stat::before{ content:""; position:absolute; left:0; top:0; bottom:0; width:4px; background:var(--accent); }
.stat--danger::before{ background:var(--red); }
.stat--good::before{ background:var(--green); }
.stat__label{ color:var(--muted); font-size:12.5px; font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
.stat__value{ font-size:26px; font-weight:800; letter-spacing:-.02em; }
.stat__meta{ color:var(--muted); font-size:12.5px; }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; margin:0 -6px; }
.table{ width:100%; border-collapse:collapse; font-size:14px; }
.table thead th{ text-align:left; color:var(--muted); font-size:11.5px; font-weight:700;
  text-transform:uppercase; letter-spacing:.04em; padding:8px 12px; border-bottom:1px solid var(--line); white-space:nowrap; }
.table thead th.num,.table td.num{ text-align:right; }
.table tbody td{ padding:12px; border-bottom:1px solid var(--line-soft); vertical-align:middle; }
.table tbody tr:last-child td{ border-bottom:none; }
.row-link{ cursor:pointer; transition:background .12s; }
.row-link:hover{ background:var(--line-soft); }

/* ---------- Pills ---------- */
.pill{ display:inline-block; padding:3px 10px; border-radius:999px; font-size:11.5px; font-weight:700;
  letter-spacing:.02em; border:1px solid transparent; vertical-align:middle; }
.st-green{ color:var(--green); background:var(--green-bg); border-color:var(--green-line); }
.st-red{ color:var(--red); background:var(--red-bg); border-color:var(--red-line); }
.st-amber{ color:var(--amber); background:var(--amber-bg); border-color:var(--amber-line); }
.st-blue{ color:var(--blue); background:var(--blue-bg); border-color:var(--blue-line); }
.st-grey{ color:var(--grey); background:var(--grey-bg); border-color:var(--grey-line); }

/* ---------- Buttons ---------- */
.btn{ display:inline-flex; align-items:center; justify-content:center; gap:7px; cursor:pointer;
  font:inherit; font-weight:650; font-size:14px; padding:9px 16px; border-radius:10px;
  border:1px solid var(--line); background:#fff; color:var(--ink); transition:.12s; white-space:nowrap; }
.btn:hover{ border-color:#cfd4e0; }
.btn--primary{ background:var(--accent); border-color:var(--accent); color:#fff;
  box-shadow:0 4px 12px rgba(108,76,241,.28); }
.btn--primary:hover{ filter:brightness(1.05); border-color:var(--accent); }
.btn--ghost{ background:#fff; }
.btn--plain{ border-color:transparent; background:transparent; color:var(--muted); }
.btn--plain:hover{ color:var(--ink); border-color:transparent; }
.btn--danger-ghost{ color:var(--red); border-color:var(--red-line); background:#fff; }
.btn--danger-ghost:hover{ background:var(--red-bg); }
.btn--danger{ background:var(--red); border-color:var(--red); color:#fff; }
.btn--block{ width:100%; }
.btn--sm{ padding:7px 12px; font-size:13px; }
.inline{ display:inline; }

/* ---------- Forms ---------- */
.form .field,.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:14px; font-size:13px;
  font-weight:600; color:var(--ink-soft); }
.field.small{ margin-bottom:10px; font-size:12px; }
input,select,textarea{ font:inherit; font-size:14px; font-weight:500; color:var(--ink);
  padding:9px 11px; border:1px solid var(--line); border-radius:9px; background:#fff; width:100%; }
input:focus,select:focus,textarea:focus{ outline:none; border-color:var(--accent);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
textarea{ resize:vertical; }
.hint{ font-weight:400; color:var(--muted); font-size:11.5px; }
.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:0 18px; }
.grid-3{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:0 18px; }
.check{ display:inline-flex; align-items:center; gap:8px; font-weight:600; color:var(--ink-soft); }
.check input{ width:auto; }
.form-actions{ display:flex; justify-content:space-between; align-items:center; gap:12px; margin-top:8px; flex-wrap:wrap; }
.form-actions > div{ display:flex; gap:10px; flex-wrap:wrap; }
.form--tight .field{ margin-bottom:9px; }

.tabs{ display:inline-flex; gap:4px; background:var(--line-soft); padding:3px; border-radius:9px; }
.tab{ padding:5px 12px; border-radius:7px; font-size:13px; font-weight:600; color:var(--ink-soft); }
.tab.is-active{ background:#fff; color:var(--accent); box-shadow:0 1px 3px rgba(0,0,0,.06); }

/* ---------- Filters ---------- */
.filters{ display:flex; flex-wrap:wrap; gap:10px; align-items:center; padding:14px 16px; }
.filters input[type=search]{ flex:1; min-width:190px; }
.filters select{ width:auto; min-width:130px; }
.inline-field{ display:inline-flex; align-items:center; gap:6px; font-size:12.5px; font-weight:600;
  color:var(--muted); flex-direction:row; margin:0; }
.inline-field input{ width:auto; }
.totals-inline{ display:flex; gap:18px; font-size:13px; color:var(--muted); }
.totals-inline strong{ color:var(--ink); }

/* ---------- Empty state ---------- */
.empty{ text-align:center; padding:40px 20px; color:var(--muted); }
.empty p{ margin:0 0 6px; }
.empty .btn{ margin-top:14px; }

/* ---------- Flash ---------- */
.flash{ padding:12px 16px; border-radius:11px; margin-bottom:16px; font-weight:600; font-size:14px; border:1px solid; }
.flash--ok{ background:var(--green-bg); color:var(--green); border-color:var(--green-line); }
.flash--err{ background:var(--red-bg); color:var(--red); border-color:var(--red-line); }

/* ---------- Misc ---------- */
.muted{ color:var(--muted); }
.small{ font-size:12.5px; }
.link{ color:var(--accent); font-weight:600; }

/* ---------- Invoice editor ---------- */
.edit-grid{ display:flex; flex-direction:column; }
.items-table{ width:100%; border-collapse:collapse; }
.items-table th{ text-align:left; color:var(--muted); font-size:11.5px; text-transform:uppercase;
  letter-spacing:.04em; padding:6px 8px; font-weight:700; }
.items-table th.num{ text-align:right; }
.items-table td{ padding:5px 8px; vertical-align:top; }
.items-table .col-qty{ width:90px; } .items-table .col-price{ width:130px; }
.items-table .col-amt{ width:120px; } .items-table .col-x{ width:34px; }
.items-table textarea{ min-height:40px; overflow:hidden; }
.items-table .amount{ padding-top:15px; font-weight:600; white-space:nowrap; }
.row-del{ border:none; background:var(--line-soft); color:var(--muted); width:26px; height:26px;
  border-radius:7px; cursor:pointer; font-size:16px; line-height:1; margin-top:8px; }
.row-del:hover{ background:var(--red-bg); color:var(--red); }
#addRow{ margin-top:6px; }

.totals-panel{ display:flex; gap:24px; margin-top:20px; padding-top:18px; border-top:1px solid var(--line); flex-wrap:wrap; }
.totals-controls{ flex:1; min-width:260px; display:grid; grid-template-columns:1fr 1fr; gap:0 16px; align-content:start; }
.combo{ display:flex; gap:8px; } .combo select{ flex:1; } .combo input{ width:110px; }
.totals-figures{ width:300px; max-width:100%; margin-left:auto; }
.trow{ display:flex; justify-content:space-between; padding:7px 0; border-bottom:1px solid var(--line-soft); font-weight:600; }
.trow span:first-child{ color:var(--muted); }
.trow--grand{ border-bottom:none; margin-top:4px; padding:12px 14px; background:color-mix(in srgb,var(--accent) 10%,#fff);
  border-radius:10px; font-size:18px; font-weight:800; }
.trow--grand span:first-child{ color:var(--ink); }

.sticky-actions{ position:sticky; bottom:0; display:flex; justify-content:flex-end; gap:12px;
  padding:14px 0; background:linear-gradient(to top, var(--bg) 70%, transparent); margin-top:4px; }

/* ---------- Invoice view ---------- */
.view-grid{ display:grid; grid-template-columns:1fr 320px; gap:20px; align-items:start; }
.io-head{ display:flex; justify-content:space-between; gap:24px; margin-bottom:18px; padding-bottom:18px; border-bottom:1px solid var(--line-soft); }
.io-label{ font-size:11px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); font-weight:700; margin-bottom:4px; }
.io-strong{ font-weight:700; font-size:15px; }
.io-multiline{ white-space:pre-line; }
.io-meta{ text-align:right; display:flex; flex-direction:column; gap:6px; }
.io-meta > div{ display:flex; gap:14px; justify-content:flex-end; }
.io-meta span{ color:var(--muted); }
.summary{ margin-top:16px; margin-left:auto; width:320px; max-width:100%; }
.srow{ display:flex; justify-content:space-between; padding:6px 0; border-bottom:1px solid var(--line-soft); }
.srow span:first-child{ color:var(--muted); }
.srow--grand{ font-size:17px; font-weight:800; border-bottom:2px solid var(--line); padding:10px 0; }
.srow--balance{ font-weight:800; color:var(--red); }
.note-block{ margin-top:18px; padding-top:14px; border-top:1px solid var(--line-soft); }
.note-block strong{ font-size:12px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); }
.note-block p{ margin:6px 0 0; white-space:pre-line; }

.pay-list{ list-style:none; margin:0 0 14px; padding:0; }
.pay-list li{ display:flex; justify-content:space-between; align-items:flex-start; gap:10px;
  padding:9px 0; border-bottom:1px solid var(--line-soft); }
.pay-list li > div{ display:flex; flex-direction:column; }
.pay-list .row-del{ margin-top:0; }
.pay-list form{ margin:0; }
.paid-note{ color:var(--green); font-weight:700; text-align:center; padding:8px; background:var(--green-bg);
  border-radius:9px; border:1px solid var(--green-line); }

/* ---------- Settings ---------- */
.settings-grid{ display:flex; flex-direction:column; }
.logo-row{ display:flex; gap:18px; align-items:flex-start; margin-bottom:16px; }
.logo-preview{ width:150px; height:90px; border:1px dashed var(--line); border-radius:10px;
  display:grid; place-items:center; background:var(--line-soft); overflow:hidden; flex:0 0 auto; }
.logo-preview img{ max-width:100%; max-height:100%; }
.logo-empty{ color:var(--muted); font-size:13px; }
.logo-controls{ flex:1; }

/* ---------- Login ---------- */
.login-body{ display:grid; place-items:center; min-height:100vh;
  background:radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb,var(--accent) 22%,#f5f6fa), var(--bg)); }
.login-card{ width:100%; max-width:400px; background:#fff; border:1px solid var(--line);
  border-radius:18px; box-shadow:0 20px 60px rgba(20,25,40,.14); padding:34px 30px; }
.login-brand{ display:flex; align-items:center; gap:12px; margin-bottom:22px; }
.login-brand strong{ display:block; font-size:16px; }
.login-brand small{ color:var(--muted); }
.login-card h1{ font-size:20px; margin-bottom:6px; }
.login-card .muted{ margin:0 0 18px; font-size:13.5px; }

/* ---------- Responsive ---------- */
@media (max-width:920px){
  .stat-grid{ grid-template-columns:1fr 1fr; }
  .view-grid{ grid-template-columns:1fr; }
  .grid-2,.grid-3{ grid-template-columns:1fr; }
  .totals-controls{ grid-template-columns:1fr; }
}
@media (max-width:680px){
  .shell{ flex-direction:column; }
  .side{ width:auto; flex:none; height:auto; position:static; flex-direction:row; align-items:center;
    padding:10px 14px; overflow-x:auto; }
  .side .brand{ padding:0 14px 0 4px; }
  .nav{ flex-direction:row; margin:0; }
  .nav__link span{ display:none; }
  .side__foot{ margin:0 0 0 auto; border:none; padding:0; }
  .main{ padding:20px 16px 60px; }
  .stat-grid{ grid-template-columns:1fr 1fr; }
  .page-head{ flex-direction:column; align-items:stretch; }
}
