:root{
  --bg: #f6f9ff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5edff;
  --borderStrong: #b6c9ff;
  --blue: #2563eb;
  --blue2: #1d4ed8;
  --blueSoft: rgba(37, 99, 235, 0.12);
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --shadowSoft: 0 10px 18px rgba(37,99,235,0.12);
  --radius: 18px;
  --radius2: 14px;
  --fs-base: 14px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue";
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-base);
  -webkit-tap-highlight-color: transparent;
}

button, a, .btn, .icon-btn, .qbtn, .tab-btn{
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body.font-sm{ --fs-base: 13px; }
body.font-md{ --fs-base: 14px; }
body.font-lg{ --fs-base: 16px; }

body.theme-dark{
  --bg: #05070b;
  --card: #0b0f15;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #111827;
  --blue: #3b82f6;
  --blue2: #2563eb;
  --blueSoft: rgba(59, 130, 246, 0.18);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.55);
  --shadowSoft: 0 12px 22px rgba(0,0,0,0.45);
}

body.theme-dark .logo{
  background: rgba(59,130,246,0.22);
  color: #93c5fd;
}

body.theme-dark .card,
body.theme-dark .item,
body.theme-dark .modal{
  background: linear-gradient(180deg, #0b0f15, #0a0d12);
  border-color: #111827;
  box-shadow: 0 12px 30px rgba(0,0,0,0.55);
}

body.theme-dark .icon-btn,
body.theme-dark .btn.secondary{
  background: #0a0d12;
  border-color: #111827;
  color: var(--text);
}


body.theme-dark .btn{
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}
body.theme-dark .btn:hover{
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}
body.theme-dark .btn.danger{
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 10px 18px rgba(239,68,68,0.25);
}

body.theme-dark .qbtn{
  background: linear-gradient(135deg, #0b0f15, #0a0d12);
  border-color: #111827;
  box-shadow: 0 10px 20px rgba(0,0,0,0.6);
}
body.theme-dark .qbtn i{
  background: rgba(59,130,246,0.25);
  color: #93c5fd;
}
body.theme-dark .qbtn-sales{
  border-color: rgba(16,185,129,0.3);
  box-shadow: 0 14px 22px rgba(16,185,129,0.18);
}
body.theme-dark .qbtn-sales i{
  background: rgba(16,185,129,0.22);
  color: #34d399;
}
body.theme-dark .qbtn-finance{
  border-color: rgba(245,158,11,0.3);
  box-shadow: 0 14px 22px rgba(245,158,11,0.2);
}
body.theme-dark .qbtn-finance i{
  background: rgba(245,158,11,0.22);
  color: #fbbf24;
}
body.theme-dark .qbtn-reports{
  border-color: rgba(59,130,246,0.32);
  box-shadow: 0 14px 22px rgba(59,130,246,0.2);
}
body.theme-dark .qbtn-reports i{
  background: rgba(59,130,246,0.22);
  color: #93c5fd;
}
body.theme-dark .qbtn-setup{
  border-color: rgba(100,116,139,0.3);
  box-shadow: 0 14px 22px rgba(100,116,139,0.18);
}
body.theme-dark .qbtn-setup i{
  background: rgba(100,116,139,0.22);
  color: #94a3b8;
}

body.theme-dark .stat .icon{
  background: rgba(59,130,246,0.25);
  color: #93c5fd;
}

body.theme-dark .input,
body.theme-dark select,
body.theme-dark textarea{
  background: #0a0d12;
  border-color: #111827;
  color: var(--text);
}
body.theme-dark .input::placeholder,
body.theme-dark textarea::placeholder{
  color: #6b7280;
}

body.theme-dark .table{
  background: #0a0d12;
  border-color: #111827;
}
body.theme-dark .table th{
  background: #0b1018;
  color: #9ca3af;
}
body.theme-dark .table tr:nth-child(even) td{
  background: #0a0f17;
}
body.theme-dark .table td{
  border-bottom-color: #111827;
}

body.theme-dark .entry-row{
  background: #0a0d12;
  border-color: #111827;
  box-shadow: 0 0 0 1px rgba(59,130,246,0.12);
}
body.theme-dark .entry-row-index{
  background: rgba(59,130,246,0.25);
  color: #dbeafe;
}
body.theme-dark .entry-header{
  background: #0b1018;
  color: #9ca3af;
}
body.theme-dark .entry-grid{
  border-color: #111827;
}

body.theme-dark .badge{
  background: rgba(59,130,246,0.18);
  color: #dbeafe;
}

body.theme-dark .modal-backdrop{
  background: rgba(0,0,0,0.7);
}
body.theme-dark .modal .head,
body.theme-dark .modal .foot{
  border-color: #111827;
}

body.theme-dark .nav-item{
  color: #9ca3af;
}
body.theme-dark .nav-item.active{
  color: #e5e7eb;
  background: rgba(59,130,246,0.18);
}

.app{
  min-height:100%;
  display:flex;
  flex-direction:column;
}

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.72));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 14px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}
body.theme-dark .topbar{
  background: linear-gradient(180deg, rgba(7,10,16,0.92), rgba(7,10,16,0.72));
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
}
.logo{
  width:44px;
  height:44px;
  border-radius: .8rem;
  background: linear-gradient(135deg, rgb(0 80 255), #54bcff);
  color: #000;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0 0 20px #54bcff47;
  font-size: 1.3rem;
}
.brand-title{ font-weight: 800; letter-spacing: .2px; }
.brand-subtitle{ font-size: 0.85rem; color: var(--muted); margin-top:2px; }

.top-actions{ display:flex; gap:10px; }
.section-title .right{
  display:flex;
  gap:8px;
  align-items:center;
}
.icon-btn{
  text-decoration: none;
  width:42px;
  height:42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.icon-badge{
  position:absolute;
  top:-6px;
  right:-6px;
  min-width:18px;
  height:18px;
  padding:0 5px;
  border-radius:999px;
  background: var(--blue);
  color:#fff;
  font-size:11px;
  font-weight:800;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-shadow: var(--shadowSoft);
}
.icon-btn:active{ transform: scale(0.98); }
.icon-btn:hover{
  border-color: rgba(37,99,235,0.25);
  box-shadow: var(--shadowSoft);
}
.icon-btn.spin i{
  animation: spin 1s linear infinite;
}
@keyframes spin{
  from{ transform: rotate(0deg); }
  to{ transform: rotate(360deg); }
}
.icon-btn.danger{
  color: #fff;
  background: #ef4444;
  border-color: #ef4444;
}
.icon-btn.danger:hover{
  background: #dc2626;
  border-color: #dc2626;
  box-shadow: 0 10px 18px rgba(220,38,38,0.22);
}
.icon-btn.brand-facebook{
  background: #1877f2;
  border-color: #1877f2;
  color: #fff;
}
.icon-btn.brand-facebook:hover{
  background: #0f5dcc;
  border-color: #0f5dcc;
}
.icon-btn.brand-telegram{
  background: #2aabee;
  border-color: #2aabee;
  color: #fff;
}
.icon-btn.brand-telegram:hover{
  background: #1d8ec7;
  border-color: #1d8ec7;
}
.icon-btn.brand-email{
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}
.icon-btn.brand-email:hover{
  background: #0b1220;
  border-color: #0b1220;
}
.icon-btn.danger-outline{
  color: #fff;
  background: #ef4444;
  border-color: #ef4444;
}
.icon-btn.danger-outline:hover{
  background: #dc2626;
  border-color: #dc2626;
  box-shadow: 0 10px 18px rgba(220,38,38,0.22);
}

.main{
  flex:1;
  padding: 14px;
  padding-bottom: 90px;
}

.demo-banner{
  max-width: 1100px;
  margin: 0 auto 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 0.9rem;
  box-shadow: var(--shadowSoft);
}
body.theme-dark .demo-banner{
  background: rgba(249, 115, 22, 0.15);
  border-color: rgba(249, 115, 22, 0.35);
  color: #fdba74;
}

.view-host{
  max-width: 1100px;
  margin: 0 auto;
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadowSoft);
}

.section{
  margin-bottom: 14px;
}

.section-title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin: 6px 0 10px;
  gap:10px;
}
.section-title h2{
  margin:0;
  font-size: 1.1rem;
  letter-spacing:.2px;
}
.section-title .hint{
  color: var(--muted);
  font-size: 0.85rem;
}

.grid{
  display:grid;
  gap: 12px;
}

.grid.cards{
  grid-template-columns: repeat(2, minmax(0,1fr));
}
@media(min-width: 860px){
  .grid.cards{ grid-template-columns: repeat(4, minmax(0,1fr)); }
}

.stat{
  padding: 14px;
}
.stat .label{ color: var(--muted); font-size: 0.85rem; }
.stat .value{ font-size: 1.5rem; font-weight: 900; margin-top:6px; letter-spacing: .2px; }
.stat .icon{
  width:38px; height:38px;
  border-radius: 14px;
  background: var(--blueSoft);
  color: var(--blue);
  display:flex; align-items:center; justify-content:center;
  margin-bottom: 10px;
  box-shadow: var(--shadowSoft);
}
.stat-danger .icon{
  background: rgba(239,68,68,0.18);
  color: #ef4444;
  box-shadow: 0 10px 18px rgba(239,68,68,0.18);
}
body.theme-dark .stat-danger .icon{
  background: rgba(239,68,68,0.22);
  color: #fca5a5;
  box-shadow: 0 10px 18px rgba(239,68,68,0.25);
}

.quick-actions{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
  padding: 12px;
}
.dash-group{
  border: 1px solid var(--borderStrong);
  background: linear-gradient(180deg, rgba(248,250,252,0.7), rgba(241,245,249,0.9));
}
.dash-group .section-title{
  border-bottom: 1px dashed var(--border);
  padding-bottom: 10px;
}
.sr-orders-toolbar .toolbar{
  align-items:center;
  flex-wrap: nowrap;
  gap: 10px;
}
.sr-orders-toolbar .left{
  flex: 1 1 auto;
  min-width: 0;
}
.sr-orders-toolbar .right{
  flex: 0 0 auto;
}
.sr-orders-toolbar .masters-tabs{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(37,99,235,0.08);
  border: 1px solid #6f9bff;
  border-radius: 16px;
  padding: 6px;
}
.sr-orders-toolbar .tab-btn{
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: 12px;
}
.sr-orders-toolbar .right{
  display:flex;
  gap: 8px;
  align-items:center;
  flex-wrap: nowrap;
}
.sr-orders-search{
  width: 180px;
  min-width: 140px;
  max-width: 200px;
  height: 36px;
}
.sr-orders-toolbar .right .btn{
  height: 36px;
  padding: 0 14px;
}
@media (max-width: 720px){
  .sr-orders-toolbar .toolbar{
    flex-wrap: wrap;
  }
  .sr-orders-toolbar .left,
  .sr-orders-toolbar .right{
    width: 100%;
  }
  .sr-orders-toolbar .right{
    justify-content: flex-start;
  }
  .sr-orders-search{
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
  }
}
.sr-order-create{
  display: none;
}
.sr-order-create.open{
  display: block;
}
.order-card.pending{
  border: 1px solid rgba(245,158,11,0.5);
}
.order-card.completed{
  border: 1px solid rgba(16,185,129,0.5);
}
.order-metrics{
  gap: 6px;
  padding-top: 6px;
  flex-wrap: wrap;
}
.dashboard-clock{
  padding: 12px;
  text-align: center;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.2px;
}
@media(min-width:860px){
  .quick-actions{ grid-template-columns: repeat(6, minmax(0,1fr)); }
}
.qbtn{
  background: linear-gradient(135deg, #ffffff, #e0ecff00);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 10px;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap: 8px;
  cursor:pointer;
  min-height: 84px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  color: var(
  --text);
  box-shadow: 1px 0px 16px rgb(0 76 255 / 58%);
}
/* Dashboard buttons use unified style */
.qbtn i{
  color: var(--blue);
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: var(--blueSoft);
}
.qbtn-sales{
  border-color: rgba(16,185,129,0.25);
  box-shadow: 0 12px 24px rgba(16,185,129,0.18);
}
.qbtn-sales i{
  color: #059669;
  background: rgba(16,185,129,0.16);
}
.qbtn-finance{
  border-color: rgba(245,158,11,0.25);
  box-shadow: 0 12px 24px rgba(245,158,11,0.18);
}
.qbtn-finance i{
  color: #d97706;
  background: rgba(245,158,11,0.18);
}
.qbtn-reports{
  border-color: rgba(59,130,246,0.25);
  box-shadow: 0 12px 24px rgba(59,130,246,0.18);
}
.qbtn-reports i{
  color: #2563eb;
  background: rgba(59,130,246,0.18);
}
.qbtn-setup{
  border-color: rgba(100,116,139,0.25);
  box-shadow: 0 12px 24px rgba(100,116,139,0.18);
}
.qbtn-setup i{
  color: #64748b;
  background: rgba(100,116,139,0.18);
}
.qbtn .t{ font-weight: 800; font-size: 0.9rem; color: var(--text); text-decoration: none; }
.qbtn .d{ color: var(--muted); font-size: 0.8rem; text-decoration: none; }
.qbtn:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(37,99,235,0.25);
}
.qbtn:active{
  transform: translateY(0);
}

button.btn.entry-save-fixed {
    font-size: 4vh;
}

.row{
  display:flex;
  gap:12px;
  align-items:center;
}
.row.wrap{ flex-wrap: wrap; }

.input, select, textarea{
  width:100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background:#fff;
  outline:none;
  font-size: 14px;
}
textarea{ resize: vertical; min-height: 90px; }
.date-field{
  display:flex;
  align-items:center;
  gap:8px;
}
.date-field .date-text{
  flex:1;
}
.date-field .date-btn{
  flex:0 0 42px;
}
.date-native{
  position: absolute;
  opacity: 0.001;
  width: 1px;
  height: 1px;
}

.btn{
  border: none;
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--blue);
  color:#fff;
  font-weight: 800;
  cursor:pointer;
  box-shadow: var(--shadowSoft);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn.secondary{
  background:#fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.danger{
  background:#ef4444;
  box-shadow: 0 10px 18px rgba(239,68,68,0.18);
}
.btn:active{ transform: scale(0.99); }
.btn:hover{
  background: var(--blue2);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn.secondary:hover{
  background: #f8fbff;
  border-color: rgba(37,99,235,0.35);
  box-shadow: var(--shadowSoft);
}
.btn.danger:hover{
  background:#dc2626;
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(220,38,38,0.22);
}
.btn:focus-visible,
.icon-btn:focus-visible,
.tab-btn:focus-visible,
.qbtn:focus-visible{
  outline: 2px solid rgba(37,99,235,0.45);
  outline-offset: 2px;
}

.toolbar{
  padding: 12px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
}
.toolbar .left, .toolbar .right{
  display:flex; gap:10px; flex-wrap:wrap; align-items:center;
}
.toolbar .left .input{
  min-width: 140px;
}
@media (max-width: 720px){
  .toolbar .left .input{
    min-width: 100%;
  }
}

.list{
  padding: 8px;
}
.payment-history-list{
  max-height: 320px;
  overflow-y: auto;
}
.sr-pay-group summary{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sr-pay-filter{
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(37,99,235,0.18);
  box-shadow: 0 10px 24px rgba(37,99,235,0.08);
}
.sr-pay-filter .toolbar{
  padding: 0;
}
.sr-pay-filter .left .small{
  font-weight: 600;
}
.sr-pay-filter .right .icon-btn{
  width: 40px;
  height: 40px;
  border-radius: 14px;
}
.sr-pay-filter #srPayDueOnlyQuick{
  width: 16px;
  height: 16px;
}
.sr-pay-empty{
  border-radius: 18px;
  border: 1px solid rgba(59,130,246,0.25);
  background: linear-gradient(180deg, #ffffff, rgba(226,232,240,0.4));
  box-shadow: 0 12px 26px rgba(37,99,235,0.1);
  padding: 16px;
}
.sr-pay-empty .btn{
  padding: 8px 16px;
  border-radius: 12px;
  text-decoration: none;
}
.sr-pay-empty .muted{
  font-weight: 600;
}
.pay-card{
  display: grid;
  grid-template-columns: 1.1fr 1.4fr 0.7fr;
  gap: 16px;
  padding: 14px;
}
.pay-left{
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pay-name{
  font-weight: 900;
  font-size: 1.05rem;
}
.pay-route{
  color: var(--muted);
  font-size: 0.85rem;
}
.pay-att{
  margin-top: 6px;
}
.pay-strip{
  height: 8px;
  border-radius: 999px;
  background: rgba(59,130,246,0.12);
  overflow: hidden;
}
.pay-strip span{
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: 999px;
}
.pay-mid{
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pay-math{
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pay-math .row{
  justify-content: space-between;
}
.pay-bars{
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bar-row{
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 10px;
  align-items: center;
}
.bar-label{
  font-size: 0.8rem;
  color: var(--muted);
}
.bar-track{
  height: 8px;
  background: rgba(148,163,184,0.2);
  border-radius: 999px;
  overflow: hidden;
}
.bar{
  display: block;
  height: 100%;
  border-radius: 999px;
}
.bar.sales{ background: linear-gradient(90deg, #3b82f6, #2563eb); }
.bar.salary{ background: linear-gradient(90deg, #f97316, #ea580c); }
.bar-value{
  font-weight: 700;
  font-size: 0.85rem;
}
.danger-text{
  color: #ef4444;
}
.success-text{
  color: #16a34a;
}
.pay-right{
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
}
.pay-net{
  font-weight: 900;
  font-size: 1.4rem;
  color: #16a34a;
}
.pay-clear{
  width: 100%;
  justify-content: center;
}
@media (max-width: 980px){
  .pay-card{
    grid-template-columns: 1fr;
  }
  .pay-right{
    align-items: flex-start;
  }
  .bar-row{
    grid-template-columns: 90px 1fr auto;
  }
}

.supplier-cards{
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  gap: 12px;
  padding: 12px;
  overflow-x: auto;
}
.supplier-card{
  min-width: 220px;
  border: 1px solid rgba(148,163,184,0.3);
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 10px 20px rgba(15,23,42,0.08);
}
.supplier-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.supplier-name{
  font-weight: 900;
  font-size: 0.95rem;
}
.supplier-meter .meter-track{
  height: 8px;
  border-radius: 999px;
  background: rgba(148,163,184,0.25);
  overflow: hidden;
}
.supplier-meter .meter-paid{
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
}
.supplier-meter .meter-labels{
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 6px;
}
.supplier-due{
  font-weight: 900;
  font-size: 1.05rem;
}
.supplier-pay{
  width: 100%;
  justify-content: center;
}
.supplier-pay-spacer{
  height: 4px;
}

.timeline{
  padding: 16px;
  position: relative;
}
.timeline-line{
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(148,163,184,0.3);
  transform: translateX(-50%);
}
.timeline-group{
  position: relative;
  padding: 12px 0 20px;
}
.timeline-date{
  position: sticky;
  top: 0;
  background: #f8fafc;
  padding: 6px 12px;
  border-radius: 12px;
  font-weight: 800;
  display: inline-block;
  margin-bottom: 10px;
  z-index: 2;
}
.timeline-items{
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.timeline-item{
  display: flex;
  width: 100%;
}
.timeline-item.left{
  justify-content: flex-start;
  padding-right: 50%;
}
.timeline-item.right{
  justify-content: flex-end;
  padding-left: 50%;
}
.timeline-bubble{
  width: calc(100% - 24px);
  max-width: 320px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(148,163,184,0.25);
  background: #fff;
  box-shadow: 0 8px 18px rgba(15,23,42,0.08);
}
.timeline-bubble.pay{
  background: rgba(16,185,129,0.12);
  border-color: rgba(16,185,129,0.3);
}
.bubble-head{
  display: flex;
  gap: 8px;
  align-items: center;
}
.bubble-title{
  font-weight: 800;
}
.bubble-detail{
  font-size: 0.8rem;
  color: var(--muted);
}
.bubble-amount{
  font-weight: 900;
  margin-top: 8px;
}
@media (max-width: 860px){
  .timeline-line{
    left: 12px;
    transform: none;
  }
  .timeline-item.left,
  .timeline-item.right{
    justify-content: flex-start;
    padding-left: 24px;
    padding-right: 0;
  }
  .timeline-bubble{
    max-width: 100%;
  }
}
.sr-pay-order{
  border: 1px solid var(--border);
}
.sr-pay-order.due-today{
  border-color: rgba(245,158,11,0.65);
  box-shadow: 0 10px 20px rgba(245,158,11,0.15);
}
.sr-pay-order.overdue{
  border-color: rgba(239,68,68,0.7);
  box-shadow: 0 10px 20px rgba(239,68,68,0.18);
}
.badge.warn{
  background: rgba(245,158,11,0.18);
  color: #f59e0b;
}
.help-scroll{
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}
.help-dev{
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}
.dev-clear-btn{
  font-size: 10px;
  padding: 2px 6px;
  opacity: 0.2;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
}
body.theme-dark .dev-clear-btn{
  border-color: #1f2937;
  color: #94a3b8;
}
.summary-filter-bar{
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:flex-start;
  padding: 6px 12px 0;
  flex-wrap: wrap;
}
.summary-filter-bar .input{
  max-width: 180px;
}
.item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background:#fff;
  margin-bottom: 10px;
  box-shadow: 0 6px 14px rgba(15,23,42,0.06);
}
.item .meta{
  display:flex; gap:12px; align-items:center;
}
.actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.thumb{
  width:42px; height:42px;
  border-radius: 12px;
  overflow:hidden;
  border: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:center;
  background: var(--blueSoft);
  color: var(--blue2);
  font-weight: 800;
}
.thumb img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}
.thumb-fallback{
  font-size: 16px;
}
.item-row{
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 8px;
  background: #fff;
}
.item-title{
  font-weight: 800;
  margin-bottom: 6px;
}
.record-highlight{
  border: 2px solid var(--blue);
  box-shadow: 0 0 0 4px var(--blueSoft);
}
tr.record-highlight td{
  background: var(--blueSoft);
}
.entry-grid{
  padding: 12px;
  display:grid;
  gap:10px;
  overflow-x:auto;
  overflow-y:visible;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.sr-order-grid .entry-header,
.sr-order-grid .entry-row{
  grid-template-columns: 240px 120px 120px;
  min-width: 520px;
}
.entry-header{
  display:grid;
  grid-template-columns: 220px 110px 90px 90px 90px 100px;
  gap:10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  padding: 0 6px;
  position: sticky;
  top: 0;
  background: #f8fbff;
  z-index: 2;
  padding-top: 6px;
  padding-bottom: 6px;
  min-width: 700px;
}
.entry-row{
  display:grid;
  grid-template-columns: 220px 110px 90px 90px 90px 100px;
  gap:10px;
  align-items:center;
  padding: 6px;
  border: 1px solid var(--borderStrong);
  border-radius: 12px;
  background: #fff;
  min-width: 700px;
  position: relative;
}
.entry-row-index{
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
  color: var(--muted);
  background: var(--blueSoft);
  padding: 2px 6px;
  border-radius: 999px;
  display: none;
}
.entry-cell .input{
  width:100%;
}
.entry-label{
  display:none;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 4px;
}
.entry-actions{
  display:flex;
  justify-content:flex-end;
}
.entry-footer{
  padding: 12px;
  display:grid;
  gap:12px;
}
.entry-save-fixed{
  position: fixed;
  top: 86px;
  right: 16px;
  z-index: 40;
  box-shadow: var(--shadow);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 0;
}
@media (max-width: 720px){
  .entry-save-fixed{
    top: 78px;
    right: 12px;
  }
}
.entry-totals{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.payments-card{
  padding: 8px;
}
.payments-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:12px;
  padding: 12px;
}
@media(min-width: 860px){
  .payments-grid{ grid-template-columns: repeat(4, minmax(0,1fr)); }
}
.payments-block .value{
  font-weight: 900;
  margin-top: 6px;
}
.payments-block.override{
  grid-column: span 2;
}
.btn.pay-override-btn{
  width: 100%;
  justify-content: center;
  border-color: #f59e0b;
  background: linear-gradient(180deg, rgba(245,158,11,0.18), rgba(245,158,11,0.06));
  color: #92400e;
}
.btn.pay-override-btn:hover{
  border-color: #d97706;
  background: linear-gradient(180deg, rgba(245,158,11,0.24), rgba(245,158,11,0.1));
}
.pay-override-wrap{
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f7f8fb;
  border: 1px solid var(--borderStrong);
  border-radius: 12px;
  padding: 6px 10px;
}
.pay-override-input{
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 6px 0;
}
.pay-override-input:focus{
  outline: none;
}
.pay-override-wrap:focus-within{
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.pay-override-suffix{
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #64748b;
}
.pay-override-hint{
  margin-top: 6px;
}
@media (max-width: 720px){
  .payments-block.override{ grid-column: span 2; }
}
.payments-deductions{
  padding: 12px;
}
.table-wrap{
  overflow:auto;
}
.payments-charts{
  display:grid;
  gap:12px;
  padding: 12px;
}
@media(min-width: 860px){
  .payments-charts{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}
.chart{
  padding: 12px;
}
.chart-row{
  display:grid;
  grid-template-columns: 1.2fr 2fr 0.8fr;
  gap:8px;
  align-items:center;
  margin-top: 8px;
}
.chart-row .label{
  font-size: 0.85rem;
}
.chart-row .bar{
  height: 8px;
  background: rgba(37,99,235,0.12);
  border-radius: 999px;
  overflow: hidden;
}
.chart-row .fill{
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
}
.payments-history{
  padding: 12px;
}
.masters-tabs{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(37,99,235,0.2);
  border-radius: 18px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: 0 10px 24px rgba(37,99,235,0.12), inset 0 1px 0 rgba(255,255,255,0.85);
}
.tab-btn{
  padding: 12px 16px;
  font-weight: 800;
  text-align: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: #5b6b8a;
  border-radius: 14px;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}
.tab-btn.active{
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  box-shadow: 0 10px 18px rgba(37,99,235,0.35);
  transform: translateY(-1px);
}
.tab-btn:hover{
  color: #0f172a;
  background: rgba(37,99,235,0.08);
}
.history-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px;
  border: 1px solid var(--borderStrong);
  border-radius: 12px;
  background: var(--card);
  margin-bottom: 10px;
  cursor: pointer;
}
.history-item:hover{
  box-shadow: var(--shadowSoft);
}
details summary{
  cursor:pointer;
  list-style:none;
  display:block;
}
details summary::-webkit-details-marker{
  display:none;
}
details[open] summary{
  margin-bottom:10px;
}
details.section.card summary{
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f8ff 100%);
  border: 1px solid var(--borderStrong);
  box-shadow: 0 8px 18px rgba(15,23,42,0.08);
}
details.section.card[open] summary{
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
}
@media (max-width: 720px){
  .entry-header{ display:none; }
  .entry-row{
    grid-template-columns: 1fr;
    gap:8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background:#fff;
    min-width: 0;
    margin-bottom: 12px;
    box-shadow: 0 0 0 4px var(--blueSoft);
  }
  .entry-actions{ justify-content:flex-start; }
  .entry-label{ display:block; }
  .entry-cell{ display:flex; flex-direction:column; }
  .entry-row-index{ display: inline-flex; }
  .qbtn{
    align-items:center;
    text-align:center;
  }
  .qbtn i{
    align-self:center;
  }
}
.badge{
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--blueSoft);
  color: var(--blue2);
  font-weight: 800;
}
.badge.danger{
  background: rgba(239,68,68,0.18);
  color: #ef4444;
}
body.theme-dark .badge.danger{
  background: rgba(239,68,68,0.22);
  color: #fca5a5;
}
.warn-text{
  color: #ef4444;
}
.net-payable{
  background: rgba(59, 130, 246, 0.16);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.35);
  padding: 10px 16px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
}
body.theme-dark .net-payable{
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.45);
}

.btn.accent{
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 10px 20px rgba(34, 197, 94, 0.25);
}
body.theme-dark .btn.accent{
  background: linear-gradient(135deg, #16a34a, #15803d);
  box-shadow: 0 10px 20px rgba(16, 185, 129, 0.25);
}
.muted{ color: var(--muted); }
.small{ font-size: 0.85rem; }
.kv{ display:flex; gap:10px; flex-wrap:wrap; }
.kv .k{ color: var(--muted); font-size: 0.85rem; }
.kv .v{ font-weight: 800; }

.toggle{
  position: relative;
  width: 44px;
  height: 26px;
  display:inline-flex;
  align-items:center;
  gap:8px;
}
.toggle-row{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
}
.toggle-row .toggle{
  margin-left: auto;
}
.toggle input{
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-ui{
  position: absolute;
  inset: 0;
  background: #e2e8f0;
  border-radius: 999px;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.toggle-ui::after{
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
}
.toggle input:checked + .toggle-ui{
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  border-color: rgba(37,99,235,0.35);
}
.toggle input:checked + .toggle-ui::after{
  transform: translateX(18px);
}
body.theme-dark .toggle-ui{
  background: #0b1220;
  border-color: #1f2a44;
}

.table{
  width:100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
}
.table th, .table td{
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align:left;
  font-size: 0.9rem;
}
.table td .icon-btn{
  width:34px;
  height:34px;
  border-radius: 12px;
  margin-right: 6px;
}
.table td .icon-btn:last-child{
  margin-right: 0;
}
.action-cell{
  display:flex;
  align-items:center;
  gap:6px;
}
.table th{
  color: var(--muted);
  font-weight: 800;
  background: #f8fbff;
  position: sticky;
  top: 0;
  z-index: 2;
}
.table tr:nth-child(even) td{
  background: #fbfdff;
}

@media (max-width: 720px){
  .table th, .table td{
    padding: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
  }
}

.bottom-nav{
  position:fixed;
  left:0; right:0; bottom:0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display:flex;
  justify-content:space-around;
  padding: 10px 10px 12px;
  z-index:30;
}
body.theme-dark .bottom-nav{
  background: rgba(15,23,42,0.92);
}
.nav-item{
  text-decoration:none;
  color: var(--muted);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 16px;
}
.nav-item i{ font-size: 18px; }
.nav-item.active{
  color: var(--blue2);
  background: var(--blueSoft);
}

.toast-host{
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  width: min(520px, calc(100% - 28px));
  display:flex;
  flex-direction:column;
  gap:10px;
}
.toast{
  background:#fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
}
.toast .msg{ font-weight: 700; font-size: 13px; }
.toast .x{ background:transparent; border:none; cursor:pointer; color: var(--muted); }

.modal-backdrop{
  position:fixed;
  inset:0;
  background: rgba(15,23,42,0.38);
  z-index: 1000;
}
.modal-host{
  position:fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100% - 28px));
  z-index: 1001;
}
.modal{
  background:#fff;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.modal .head{
  padding: 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  border-bottom: 1px solid var(--border);
}
.modal .head .icon-btn{
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.modal .head .icon-btn:hover{
  background: #dc2626;
  border-color: #dc2626;
  box-shadow: 0 10px 18px rgba(220,38,38,0.22);
}
.modal .head .title{ font-weight: 900; }
.modal .foot .modal-copyright{
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}
.modal .foot .modal-copyright:hover{
  color: var(--blue2);
}
.modal .body{ padding: 14px; }
.modal .foot{
  padding: 14px;
  border-top: 1px solid var(--border);
  display:flex;
  justify-content:flex-end;
  gap:10px;
}
.modal-copyright-wrap{
  width: 100%;
  text-align: center;
}
.modal .foot .btn.secondary{
  border-color: #ef4444;
  color: #ef4444;
}
.modal .foot .btn.secondary:hover{
  background: #fee2e2;
  border-color: #dc2626;
  color: #dc2626;
}
.hidden{ display:none !important; }
