/* MidPay merchant area — builds on css/midpay-dashboard.css tokens (dark, green #A4D233). */
.mp-load{ text-align:center; animation:mIn .5s ease both; }
.mp-logo{ width:64px; height:auto; animation:mPulse 1.9s ease-in-out infinite; filter:drop-shadow(0 0 20px rgba(164,210,51,.38)); }
.mp-load p{ color:var(--text-2); margin-top:18px; font-size:14px; }
@keyframes mPulse{0%,100%{transform:scale(1);opacity:.9}50%{transform:scale(1.08);opacity:1}}
@keyframes mIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes mRise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
.merchant-shell .content{ animation:mRise .35s ease both; max-width:1180px; }
.brand-tag{ font-size:11px; color:rgba(20,23,16,0.5); font-weight:600; letter-spacing:1px; margin-left:8px; }
.sidebar-nav a{ text-align:left; padding:11px 14px; border-radius:10px; color:var(--text-2); font-size:14px; font-weight:500;
  display:flex; align-items:center; gap:10px; transition:background .15s,color .15s; }
.sidebar-nav a:hover{ background:#ffffff; color:var(--text); }
.sidebar-nav a.is-active{ background:var(--green-soft); color:var(--green); }
.sidebar-nav a .icon{ font-size:16px; }
.topbar-left{ display:flex; align-items:center; gap:14px; min-width:0; }
.topbar-user{ gap:12px; }
.menu-btn,.drawer-backdrop{ display:none; }

/* buttons + fields */
.btn-primary,.btn-ghost,.btn-danger{ display:inline-flex; align-items:center; justify-content:center; gap:6px; text-decoration:none; white-space:nowrap; line-height:1.1; }
.btn-danger{ padding:10px 16px; border-radius:8px; background:rgba(239,68,68,.14); color:#ff8a8a; font-weight:600; font-size:14px; }
.btn-danger:hover{ background:rgba(239,68,68,.24); }
.btn-sm{ padding:7px 12px !important; font-size:13px !important; }
.m-field{ display:flex; flex-direction:column; gap:6px; min-width:0; }
.m-field > span,.m-label{ font-size:12px; color:var(--text-3); font-weight:600; letter-spacing:.3px; }
.merchant-shell input[type=text],.merchant-shell input[type=email],.merchant-shell input[type=tel],.merchant-shell input[type=url],
.merchant-shell input[type=number],.merchant-shell input[type=date],.merchant-shell input[type=search],.merchant-shell select,.merchant-shell textarea{
  width:100%; background:var(--surface-2); border:1px solid var(--border); border-radius:8px; color:var(--text);
  font-family:inherit; font-size:14px; padding:10px 12px; min-width:0; }
.merchant-shell textarea{ min-height:76px; resize:vertical; }
.merchant-shell input:focus,.merchant-shell select:focus,.merchant-shell textarea:focus{ outline:none; border-color:var(--green); box-shadow:0 0 0 3px rgba(164,210,51,.12); }
.merchant-shell select option{ background:#ffffff; }
.grid2{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.grid3{ display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.stack{ display:flex; flex-direction:column; gap:14px; }
.row{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.row.end{ justify-content:flex-end; } .row.between{ justify-content:space-between; }
.grow{ flex:1; min-width:0; }
.hint{ font-size:12px; color:var(--text-3); }
.err-text{ color:#ff8a8a; font-size:13px; }

/* page head */
.page-head{ display:flex; justify-content:space-between; align-items:flex-start; gap:14px; flex-wrap:wrap; margin-bottom:18px; }
.page-head h2{ font-size:22px; font-weight:700; }
.page-head p{ color:var(--text-3); font-size:13px; margin-top:2px; }

/* KPI */
.kpis{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; margin-bottom:18px; }
.kpi{ padding:18px; background:var(--surface); border:1px solid var(--border); border-radius:12px; text-align:left; display:block; transition:border-color .15s, transform .15s; }
a.kpi:hover{ border-color:var(--green); transform:translateY(-1px); }
.kpi .label{ font-size:11px; color:var(--text-3); text-transform:uppercase; letter-spacing:.7px; margin-bottom:6px; }
.kpi .value{ font-size:26px; font-weight:800; letter-spacing:-.02em; }
.kpi .value.green{ color:var(--green); } .kpi .value.red{ color:#ff7b7b; } .kpi .value.orange{ color:var(--orange); }
.kpi .sub{ font-size:12px; color:var(--text-3); margin-top:2px; }
.two-col{ display:grid; grid-template-columns:minmax(0,1.5fr) minmax(0,1fr); gap:14px; }

/* status pills */
.st{ display:inline-block; padding:3px 10px; border-radius:999px; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.6px; white-space:nowrap; }
.st-draft{ background:#ffffff; color:var(--text-2); }
.st-sent,.st-viewed{ background:rgba(59,130,246,.18); color:#7cb0ff; }
.st-paid{ background:rgba(16,185,129,.18); color:var(--emerald); }
.st-partial{ background:rgba(245,158,11,.18); color:var(--orange); }
.st-overdue{ background:rgba(239,68,68,.18); color:#ff7b7b; }
.st-void{ background:#ffffff; color:var(--text-3); text-decoration:line-through; }

/* tabs */
.tabs{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:14px; }
.tab{ padding:7px 14px; border-radius:999px; border:1px solid var(--border); color:var(--text-2); font-size:13px; font-weight:600; background:transparent; }
.tab:hover{ border-color:var(--border-hi); color:var(--text); }
.tab.is-active{ background:var(--green-soft); border-color:rgba(164,210,51,.4); color:var(--green); }

/* data table */
.tbl-wrap{ overflow-x:auto; border:1px solid var(--border); border-radius:12px; background:var(--surface); }
.tbl{ width:100%; border-collapse:collapse; font-size:13.5px; min-width:640px; }
.tbl th,.tbl td{ padding:12px 14px; text-align:left; border-bottom:1px solid var(--border); }
.tbl th{ background:var(--surface-2); color:var(--text-3); font-size:11px; text-transform:uppercase; letter-spacing:.6px; font-weight:600; }
.tbl tr:last-child td{ border-bottom:0; }
.tbl tbody tr.clickable{ cursor:pointer; transition:background .12s; }
.tbl tbody tr.clickable:hover{ background:rgba(164,210,51,.05); }
.tbl .num{ text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
.tbl .code{ font-family:ui-monospace,Menlo,monospace; color:var(--green); white-space:nowrap; }
.muted{ color:var(--text-3); }

/* empty */
.empty-card{ text-align:center; padding:44px 20px; background:var(--surface); border:1px dashed var(--border-hi); border-radius:14px; }
.empty-card .big{ font-size:34px; margin-bottom:8px; }
.empty-card h3{ font-size:17px; margin-bottom:4px; }
.empty-card p{ color:var(--text-3); font-size:14px; margin-bottom:16px; }

/* bars */
.bars{ display:flex; align-items:flex-end; gap:10px; height:150px; padding-top:8px; }
.bar-col{ flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; height:100%; justify-content:flex-end; min-width:0; }
.bar{ width:100%; max-width:46px; background:linear-gradient(180deg,var(--green),rgba(164,210,51,.45)); border-radius:6px 6px 2px 2px; min-height:3px; transform-origin:bottom; animation:grow .6s cubic-bezier(.2,.8,.2,1) both; }
.bar.zero{ background:#ffffff; }
@keyframes grow{from{transform:scaleY(0)}to{transform:scaleY(1)}}
.bar-lab{ font-size:10.5px; color:var(--text-3); } .bar-val{ font-size:10.5px; color:var(--text-2); font-variant-numeric:tabular-nums; }
.aging{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.aging .cell{ padding:14px; border-radius:10px; background:var(--surface-2); border:1px solid var(--border); }
.aging .cell b{ display:block; font-size:20px; margin-top:4px; }
.aging .cell.warn b{ color:var(--orange); } .aging .cell.bad b{ color:#ff7b7b; }

/* list rows */
.list-row{ display:flex; justify-content:space-between; gap:12px; padding:11px 0; border-bottom:1px solid var(--border); align-items:center; }
.list-row:last-child{ border-bottom:0; }
.list-row .t{ font-weight:600; font-size:14px; } .list-row .s{ font-size:12px; color:var(--text-3); }

/* invoice editor */
.line-grid{ display:grid; grid-template-columns:minmax(0,3fr) 70px 110px 74px 74px 96px 34px; gap:8px; align-items:start; }
.line-head{ font-size:11px; color:var(--text-3); text-transform:uppercase; letter-spacing:.6px; padding:0 2px; }
.line-amt{ text-align:right; padding:10px 0; font-variant-numeric:tabular-nums; font-weight:600; }
.x-btn{ width:34px; height:38px; border-radius:8px; color:var(--text-3); background:#ffffff; }
.x-btn:hover{ color:#ff8a8a; background:rgba(239,68,68,.12); }
.line-item{ display:contents; }
.totals-box{ margin-left:auto; width:min(100%,340px); display:flex; flex-direction:column; gap:6px; margin-top:16px; }
.totals-box div{ display:flex; justify-content:space-between; font-variant-numeric:tabular-nums; }
.totals-box .grand{ border-top:1px solid var(--border-hi); padding-top:10px; margin-top:4px; font-size:20px; font-weight:800; color:var(--green); }
.sticky-actions{ position:sticky; bottom:0; margin:20px -24px -80px; padding:14px 24px calc(14px + env(safe-area-inset-bottom)); background:rgba(253,254,249,0.92); backdrop-filter:blur(10px); border-top:1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; z-index:5; }

/* detail */
.detail-top{ display:flex; justify-content:space-between; gap:14px; flex-wrap:wrap; align-items:flex-start; }
.detail-top h2{ font-size:24px; display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.share-box{ display:flex; gap:8px; }
.share-box input{ font-family:ui-monospace,Menlo,monospace; font-size:12.5px; }

/* modal + toast */
.modal-back{ position:fixed; inset:0; background:rgba(0,0,0,.65); z-index:200; display:flex; align-items:flex-start; justify-content:center; padding:5vh 14px; overflow-y:auto; animation:fadeIn .18s ease both; }
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.modal{ width:min(560px,100%); background:var(--surface); border:1px solid var(--border-hi); border-radius:16px; padding:22px; animation:mRise .25s ease both; }
.modal h3{ font-size:18px; margin-bottom:14px; }
.modal .actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:18px; flex-wrap:wrap; }
#toastRoot{ position:fixed; left:50%; bottom:calc(20px + env(safe-area-inset-bottom)); transform:translateX(-50%); z-index:300; display:flex; flex-direction:column; gap:8px; align-items:center; pointer-events:none; width:calc(100% - 28px); }
.toast{ pointer-events:auto; background:#ffffff; border:1px solid rgba(164,210,51,.5); color:#141710; padding:11px 18px; border-radius:10px; font-size:14px; box-shadow:0 10px 40px rgba(20,23,16,0.175); animation:mRise .25s ease both; max-width:520px; }
.toast.error{ background:#2a1212; border-color:rgba(239,68,68,.6); }

.app-status{ display:flex; gap:14px; align-items:center; flex-wrap:wrap; }
.skeleton{ height:84px; border-radius:12px; background:linear-gradient(90deg,var(--surface) 25%,var(--surface-2) 50%,var(--surface) 75%); background-size:200% 100%; animation:shimmer 1.2s infinite; }
@keyframes shimmer{to{background-position:-200% 0}}

@media (max-width:1024px){ .kpis{ grid-template-columns:repeat(2,minmax(0,1fr)); } .two-col{ grid-template-columns:1fr; } }
@media (max-width:880px){
  .merchant-shell .app{ flex-direction:column; }
  .merchant-shell .sidebar{ position:fixed; top:0; left:0; bottom:0; z-index:90; width:min(84vw,300px); height:100dvh; flex-direction:column; align-items:stretch;
    overflow-y:auto; border-right:1px solid var(--border); border-bottom:none; transform:translateX(-102%); transition:transform .28s cubic-bezier(.2,.8,.2,1); box-shadow:24px 0 60px rgba(20,23,16,0.193); }
  .merchant-shell.drawer-open .sidebar{ transform:translateX(0); }
  .merchant-shell .sidebar-brand{ border-bottom:1px solid var(--border); padding:18px 20px; }
  .merchant-shell .sidebar-nav{ flex-direction:column; padding:12px; flex:none; }
  .merchant-shell .sidebar-nav a{ padding:13px 14px; font-size:15px; }
  .merchant-shell .sidebar-foot{ display:flex; padding-bottom:calc(18px + env(safe-area-inset-bottom)); }
  .drawer-backdrop{ display:block; position:fixed; inset:0; z-index:80; background:rgba(0,0,0,.6); opacity:0; pointer-events:none; transition:opacity .25s; }
  .merchant-shell.drawer-open .drawer-backdrop{ opacity:1; pointer-events:auto; }
  .merchant-shell.drawer-open{ overflow:hidden; }
  .menu-btn{ display:inline-flex; flex-direction:column; justify-content:center; gap:4px; width:40px; height:40px; padding:0 10px; border-radius:10px; flex-shrink:0; background:var(--surface-2); border:1px solid var(--border); }
  .menu-btn span{ display:block; height:2px; border-radius:2px; background:var(--text); }
  .merchant-shell .topbar{ flex-wrap:nowrap; padding:12px 16px; }
  .merchant-shell .topbar h1{ font-size:18px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .merchant-shell .topbar-user .meta{ display:none; }
  .merchant-shell .content{ padding:16px 16px 70px; }
  .sticky-actions{ margin:20px -16px -70px; padding-left:16px; padding-right:16px; }
  .kpi .value{ font-size:22px; }
}
@media (max-width:640px){
  .kpis{ grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  .grid2,.grid3{ grid-template-columns:1fr; }
  .aging{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  #topNewInvoice{ padding:8px 12px; font-size:12px; }
  .line-head{ display:none; }
  .line-grid{ grid-template-columns:1fr 1fr; }
  .line-item{ display:grid; grid-template-columns:1fr 1fr; gap:8px; grid-column:1 / -1; padding:12px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); }
  .line-item .f-desc{ grid-column:1 / -1; } .line-item .f-amt{ grid-column:1 / 2; align-self:center; } .line-item .f-x{ justify-self:end; }
  .line-item .lab{ display:block; font-size:11px; color:var(--text-3); margin-bottom:3px; }
  .share-box{ flex-direction:column; }
  .tbl.cards{ min-width:0; } .tbl.cards thead{ display:none; }
  .tbl.cards tr{ display:block; padding:12px 14px; border-bottom:1px solid var(--border); }
  .tbl.cards td{ display:flex; justify-content:space-between; gap:12px; padding:3px 0; border:0; text-align:right; }
  .tbl.cards td::before{ content:attr(data-l); color:var(--text-3); font-size:12px; text-align:left; }
}
@media (min-width:641px){ .line-item .lab{ display:none; } }

.due-col{ grid-column:2; }
@media (max-width:640px){ .due-col{ grid-column:auto; } }

/* recurring + payment links */
.rep-box{ margin-top:14px; padding-top:14px; border-top:1px solid var(--border); }
.card a:not([class]){ color:var(--green); }
