/* Invoices app — dark control panel with warm accent */
@font-face {
  font-family: 'Montserrat'; font-weight: 400; font-style: normal; font-display: swap;
  src: url('fonts/Montserrat-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat'; font-weight: 500; font-style: normal; font-display: swap;
  src: url('fonts/Montserrat-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat'; font-weight: 600; font-style: normal; font-display: swap;
  src: url('fonts/Montserrat-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat'; font-weight: 700; font-style: normal; font-display: swap;
  src: url('fonts/Montserrat-Bold.woff2') format('woff2');
}
:root {
  --bg: #101014;
  --panel: #1a1a21;
  --panel-2: #22222b;
  --line: #2e2e3a;
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --accent: #e8455f;
  --accent-dark: #d0356b;
  --accent-2: #6553c0;
  --ok: #35b26b;
  --warn: #e0a63c;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.5 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; }
h1 { font-size: 26px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.r { text-align: right; }
.mt { margin-top: 12px; }
.pad { padding: 18px; }
.inline { display: inline-block; }

/* nav */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 22px; height: 58px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  font-weight: 800; font-size: 18px; text-decoration: none;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav-menu { display: flex; align-items: center; gap: 20px; flex: 1; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  text-decoration: none; color: var(--muted);
  padding: 8px 12px; border-radius: 8px; font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--panel-2); }
.nav-right { display: flex; align-items: center; gap: 14px; }
.nav-user { color: var(--muted); text-decoration: none; font-size: 13px; }
.nav-toggle {
  display: none; margin-left: auto;
  background: none; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font-size: 19px; line-height: 1; padding: 6px 11px; cursor: pointer;
}

@media (max-width: 840px) {
  .topbar { flex-wrap: wrap; position: sticky; }
  .nav-toggle { display: block; }
  .nav-menu {
    display: none;
    position: absolute; top: 58px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 6px;
    background: var(--panel); border-bottom: 1px solid var(--line);
    padding: 10px 16px 16px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .45);
  }
  .topbar.open .nav-menu { display: flex; }
  .nav-links { flex-direction: column; gap: 2px; }
  .nav-links a { padding: 11px 12px; }
  .nav-right { flex-direction: column; align-items: stretch; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
  .nav-right .btn { text-align: center; }
  .nav-user { text-align: center; padding: 6px; }
}

.wrap { max-width: 1060px; margin: 0 auto; padding: 26px 22px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* panels & tables */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.panel .panel-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); }
.table th.sortable a { color: inherit; text-decoration: none; white-space: nowrap; }
.table th.sortable a:hover { color: var(--text); }
.dl-link { color: var(--accent); display: inline-flex; padding: 5px; border-radius: 6px; vertical-align: middle; }
.dl-link:hover { background: var(--panel-2); filter: brightness(1.2); }
.icon-cell { white-space: nowrap; }

/* PDF preview modal */
.pdf-modal {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 8, 12, .78); backdrop-filter: blur(3px);
  padding: 24px;
}
.pdf-modal.open { display: flex; align-items: center; justify-content: center; }
.pdf-modal-box {
  width: min(880px, 100%); height: min(92vh, 1100px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
}
.pdf-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.pdf-modal-box iframe { flex: 1; width: 100%; border: 0; background: #525659; }
@media (max-width: 720px) { .pdf-modal { padding: 8px; } }
.table td { border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table tr[onclick] { cursor: pointer; }
.table tr[onclick]:hover td { background: var(--panel-2); }
.table .tot td { border-top: 1px solid var(--line); }
.table th.r, .table td.r { text-align: right; }

/* stats */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 2px; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat-num { font-size: 30px; font-weight: 800; }
.stat-sub { color: var(--muted); font-size: 13px; }

/* badges */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: .04em; }
.badge-draft { background: #3a3a46; color: #c8c8d4; }
.badge-sent { background: rgba(224, 166, 60, .16); color: var(--warn); }
.badge-part_paid { background: rgba(101, 83, 192, .2); color: #a99bf0; }
.badge-paid { background: rgba(53, 178, 107, .16); color: var(--ok); }
.badge-cancelled { background: rgba(232, 69, 95, .14); color: var(--accent); }

/* forms */
label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 10px 12px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit;
}
input[type="color"] { padding: 3px; height: 42px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.narrow { max-width: 560px; }
.filters { display: flex; gap: 8px; align-items: center; }
.filters input, .filters select { margin-top: 0; width: auto; }

/* buttons */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none; font-size: 14px;
}
.btn:hover { border-color: var(--accent-2); }
.btn-accent { background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border: none; color: #fff; }
.btn-accent:hover { filter: brightness(1.1); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn-danger:hover { background: var(--accent); color: #fff; }

/* flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 600; }
.flash-ok { background: rgba(53, 178, 107, .14); color: var(--ok); border: 1px solid rgba(53, 178, 107, .3); }
.flash-err { background: rgba(232, 69, 95, .12); color: var(--accent); border: 1px solid rgba(232, 69, 95, .3); }

/* auth */
.auth-card { max-width: 380px; margin: 10vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card p { margin-top: 0; }
.auth-card form { margin-top: 18px; }

/* invoice editor */
.inv-form h2 { margin-top: 20px; }
.item-row { display: grid; grid-template-columns: 1fr 130px 40px; gap: 8px; margin-bottom: 8px; }
.item-row input { margin-top: 0; }
.deposit-block { margin-top: 22px; align-items: start; }
.deposit-controls { display: flex; gap: 8px; }
.deposit-controls select { width: 140px; margin-top: 0; }
.deposit-controls input { width: 120px; margin-top: 0; }
.totals-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.tot-line { display: flex; justify-content: space-between; padding: 6px 0; }
.tot-line strong { font-size: 18px; }

/* invoice view */
.detail { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0 0 16px; }
.detail dt { color: var(--muted); font-size: 13px; }
.detail dd { margin: 0; }
.pay-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.pay-row input, .pay-row select { margin-top: 0; }
.attach-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }

/* share page (client-facing) */
body.share { min-height: 100vh; }
.share-wrap { display: flex; justify-content: center; padding: 40px 16px; }
.share-card {
  width: 100%; max-width: 560px;
  background: rgba(16, 16, 20, .82); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 16px;
  padding: 30px;
}
.share-logo { max-height: 70px; max-width: 200px; display: block; margin: 0 auto 10px; }
.share-from { text-align: center; color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; }
.share-card h1 { text-align: center; margin-bottom: 6px; }
.share-card > .muted { text-align: center; }
.share-meta { display: flex; justify-content: center; gap: 26px; margin: 18px 0; flex-wrap: wrap; }
.share-meta div { display: flex; flex-direction: column; align-items: center; }
.share-meta span { color: var(--muted); font-size: 12px; }
.share-table { margin: 10px 0 16px; }
.btn-pay {
  display: block; text-align: center; padding: 15px;
  border-radius: 12px; color: #fff; font-weight: 800; font-size: 17px;
  text-decoration: none; margin: 18px 0 6px;
}
.btn-pay:hover { filter: brightness(1.1); }
.share-paid { text-align: center; font-size: 18px; font-weight: 700; color: var(--ok); }
.share-bank { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 10px; text-align: center; }
.share-pdf { display: block; text-align: center; color: var(--muted); margin-top: 14px; font-size: 14px; }
.settings-grid .panel { margin-bottom: 20px; }

/* design library */
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.design-card { margin-bottom: 0; display: flex; flex-direction: column; }
.design-preview {
  height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; overflow: hidden; position: relative;
}
.design-preview > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.design-preview .design-logo { max-height: 44px; max-width: 60%; position: static; width: auto; height: auto; object-fit: contain; }
.design-title { font-weight: 800; font-size: 22px; letter-spacing: .12em; }
.design-line { font-size: 12px; opacity: .8; }
.design-meta { padding: 12px 14px 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatches { display: inline-flex; gap: 4px; margin-left: auto; }
.swatches i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); }
.design-actions { padding: 8px 14px 14px; display: flex; gap: 6px; }
.check-label { display: flex; align-items: center; gap: 8px; }
.check-label input { width: auto; margin: 0; }

/* settings design-mode picker */
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 16px; }
@media (max-width: 720px) { .mode-picker { grid-template-columns: 1fr; } }
.mode-option {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; cursor: pointer; font-weight: 400;
}
.mode-option:has(input:checked) { border-color: var(--accent); }
.mode-option input { width: auto; margin-top: 3px; }

/* mobile polish */
@media (max-width: 720px) {
  .wrap { padding: 18px 14px 50px; }
  h1 { font-size: 21px; }
  .stat-num { font-size: 24px; }
  .panel { overflow-x: auto; }
  .table { min-width: 540px; }
  .table th, .table td { padding: 8px 10px; font-size: 13px; }
  .share-table { min-width: 0; }        /* share page table fits as-is */
  .page-head { align-items: flex-start; flex-direction: column; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; text-align: center; }
  .filters { flex-wrap: wrap; }
  .filters input[type="search"] { width: 100%; }
  .item-row { grid-template-columns: 1fr 86px 34px; }
  .pay-row { grid-template-columns: 1fr; gap: 6px; }
  .detail { grid-template-columns: 100px 1fr; }
  .form-actions { flex-wrap: wrap; }
  .share-card { padding: 20px 16px; }
  .share-meta { gap: 16px; }
}
