@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Manrope:wght@400;500;600;700;800&display=swap');

:root{
  /* Light base + neon accents; side menu stays dark for contrast */
  --bg:#F6F7FC; --surface:#FFFFFF; --surface-2:#F1F3F9; --surface-muted:#F1F3F9;
  --ink:#1F2430; --ink-muted:#6B7280;
  --line:#E7E9F2;

  --primary:#7C3AED; --primary-dark:#6D28D9; --primary-tint: rgba(124,58,237,.10);
  --gold:#D97706; --gold-tint: rgba(217,119,6,.10);
  --panel:#12172B; --panel-2:#1C2340;

  --give:#E11D48; --give-tint: rgba(225,29,72,.09);
  --receive:#0891B2; --receive-tint: rgba(8,145,178,.09);
  --ok:#16A34A; --ok-tint: rgba(22,163,74,.09);

  --radius:16px; --radius-sm:11px;
  --shadow-sm: 0 1px 3px rgba(16,24,40,.06);
  --shadow-md: 0 6px 18px rgba(16,24,40,.08);
  --shadow-lg: 0 18px 44px rgba(16,24,40,.16);
}
*{ box-sizing:border-box; }
body{
  margin:0; font-family:'Manrope',sans-serif; color:var(--ink); background:var(--bg); min-height:100vh;
  background-image:
    radial-gradient(650px circle at 6% 0%, rgba(124,58,237,.06), transparent 55%),
    radial-gradient(650px circle at 96% 12%, rgba(8,145,178,.06), transparent 55%),
    radial-gradient(550px circle at 50% 100%, rgba(225,29,72,.045), transparent 55%);
  background-attachment: fixed;
}
.display{ font-family:'Sora',sans-serif; font-weight:700; letter-spacing:-.01em; }
a{ color:inherit; text-decoration:none; }
::-webkit-scrollbar{ width:6px; height:6px; }
::-webkit-scrollbar-thumb{ background: var(--line); border-radius:8px; }

/* ---- Buttons — vivid neon fills with colored glow ---- */
.btn{
  display:inline-flex; align-items:center; gap:8px; justify-content:center;
  font-family:'Manrope',sans-serif; font-weight:700; font-size:14px; border-radius:12px;
  padding:11px 20px; cursor:pointer; white-space:nowrap; border:1px solid transparent; color:var(--ink);
  transition: transform .12s ease, box-shadow .18s ease, background .15s ease, border-color .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:active{ transform: scale(.97); }
.btn-primary{ color:#fff; background:linear-gradient(135deg,#8B5CF6,#7C3AED); box-shadow:0 4px 16px rgba(124,58,237,.35); }
.btn-primary:hover{ box-shadow:0 6px 22px rgba(124,58,237,.48); transform:translateY(-1px); }
.btn-gold{ color:#fff; background:linear-gradient(135deg,#FBBF24,#D97706); box-shadow:0 4px 16px rgba(217,119,6,.32); }
.btn-gold:hover{ box-shadow:0 6px 22px rgba(217,119,6,.45); transform:translateY(-1px); }
.btn-ghost{ color:var(--ink); background:var(--surface); border-color:var(--line); }
.btn-ghost:hover{ background:var(--surface-2); border-color:#D9D3FA; }
.btn-danger{ color:var(--give); background:var(--give-tint); border-color:rgba(225,29,72,.25); }
.btn-danger:hover{ box-shadow:0 4px 16px rgba(225,29,72,.22); }
.btn-sm{ padding:7px 14px; font-size:13px; border-radius:10px; }
.btn-icon{ width:36px; height:36px; padding:0; border-radius:10px; }
.btn:disabled{ opacity:.5; cursor:not-allowed; }

/* ---- Cards ---- */
.card{ background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.card-hover:hover{ transform: translateY(-2px); box-shadow: 0 10px 24px rgba(124,58,237,.14); border-color:#D9D3FA; }
.input, select.input, textarea.input{
  width:100%; border:1.5px solid var(--line); background:#fff; border-radius:11px;
  padding:11px 13px; font-size:14.5px; font-family:'Manrope',sans-serif; color:var(--ink); outline:none;
  transition:border-color .15s, box-shadow .15s;
}
.input::placeholder{ color:#A3A9BF; }
.input:focus{ border-color:var(--primary); box-shadow:0 0 0 3px var(--primary-tint); }
label.field-label{ font-size:12.5px; font-weight:700; color:var(--ink-muted); text-transform:uppercase; letter-spacing:.04em; margin-bottom:6px; display:block; }
.field{ margin-bottom:14px; }

/* ---- Searchable supplier picker (autocomplete) ---- */
.autocomplete-list{
  position:absolute; top:100%; left:0; right:0; margin-top:4px; z-index:70;
  background:var(--surface); border:1px solid var(--line); border-radius:12px;
  box-shadow:var(--shadow-md);
  max-height:min(240px, 45vh); overflow-y:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain;
}
.autocomplete-item{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:11px 14px; font-size:14px; line-height:1.3; cursor:pointer; color:var(--ink);
  border-bottom:1px solid var(--line);
}
.autocomplete-item:last-child{ border-bottom:none; }
.autocomplete-item:hover, .autocomplete-item:active{ background:var(--surface-2); }
.autocomplete-item-name{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.autocomplete-item-phone{ font-size:12px; color:var(--ink-muted); font-weight:600; flex-shrink:0; }
.autocomplete-empty{ padding:14px; font-size:12.5px; color:var(--ink-muted); text-align:center; }
.autocomplete-more{ padding:9px 14px; font-size:11.5px; color:var(--ink-muted); text-align:center; background:var(--surface-2); font-weight:600; }

/* ---- Topbar: grid layout — left business info | centered nav | right actions ---- */
.topbar{
  position:sticky; top:0; z-index:20; padding:10px 16px;
  display:grid; grid-template-columns: 1fr auto 1fr; align-items:center; gap:12px;
  background: rgba(246,247,252,.92); backdrop-filter: blur(10px); border-bottom:1px solid var(--line);
}
.topbar-left{ display:flex; align-items:center; gap:11px; min-width:0; justify-self:start; }
.topbar-avatar{ width:38px; height:38px; border-radius:11px; background:linear-gradient(135deg,#8B5CF6,#7C3AED); display:flex; align-items:center; justify-content:center; flex-shrink:0; overflow:hidden; box-shadow:0 4px 12px rgba(124,58,237,.35); }
.topbar-avatar img{ width:100%; height:100%; object-fit:cover; }
.topbar-avatar span{ color:#fff; font-family:'Sora',sans-serif; font-weight:700; font-size:15px; }
.topbar-title{ font-family:'Sora',sans-serif; font-weight:700; font-size:15px; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.topbar-meta{ display:flex; gap:10px; font-size:11.5px; color:var(--ink-muted); font-weight:600; overflow:hidden; }
.topbar-meta span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:220px; }

/* Center pill-group nav — desktop only */
.topbar-center{ display:none; justify-self:center; }
.topbar-pillgroup{ display:flex; align-items:center; gap:2px; background:var(--surface-2); border:1px solid var(--line); border-radius:999px; padding:4px; }
.topbar-navlink{ display:inline-flex; align-items:center; gap:7px; padding:9px 18px; border-radius:999px; font-size:13.5px; font-weight:700; color:var(--ink-muted); white-space:nowrap; transition: background .15s, color .15s, box-shadow .15s; }
.topbar-navlink:hover{ color:var(--ink); }
.topbar-navlink.active{ background:linear-gradient(135deg,#8B5CF6,#7C3AED); color:#fff; box-shadow:0 4px 14px rgba(124,58,237,.35); }
.topbar-navlink.logout{ color:var(--give); padding:9px 16px; }
.topbar-navlink.logout:hover{ background:var(--give-tint); }

/* Right side — logout button on desktop, hamburger on tablet/mobile */
.topbar-right{ display:flex; align-items:center; gap:8px; justify-self:end; flex-shrink:0; }
.topbar-logout-desktop{ display:none; }

/* ---- Animated hamburger ---- */
.hamburger{
  width:42px; height:42px; border-radius:12px; border:1px solid var(--line);
  background:var(--surface); display:flex; align-items:center; justify-content:center;
  cursor:pointer; flex-shrink:0; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}
.hamburger:hover{ border-color:#C7B8F5; box-shadow:0 0 0 4px var(--primary-tint); }
.hamburger .bar{ display:block; width:19px; height:2.4px; background:var(--ink); border-radius:2px; position:relative; transition: transform .28s cubic-bezier(.4,0,.2,1), background .2s; }
.hamburger .bar::before,.hamburger .bar::after{ content:''; position:absolute; left:0; width:19px; height:2.4px; background:var(--ink); border-radius:2px; transition: transform .28s cubic-bezier(.4,0,.2,1); }
.hamburger .bar::before{ top:-6.5px; } .hamburger .bar::after{ top:6.5px; }
.hamburger.open .bar{ background:transparent; }
.hamburger.open .bar::before{ top:0; transform:rotate(45deg); background:var(--primary); }
.hamburger.open .bar::after{ top:0; transform:rotate(-45deg); background:var(--primary); }

/* ---- Side panel: docked RIGHT, stays dark for contrast ---- */
.overlay{ position:fixed; inset:0; background: rgba(15,18,32,.5); z-index:40; opacity:0; pointer-events:none; transition: opacity .25s ease; }
.overlay.show{ opacity:1; pointer-events:auto; }
.sidepanel{
  position:fixed; top:0; right:0; bottom:0; left:auto; width:288px; max-width:82vw;
  background: linear-gradient(200deg, var(--panel), var(--panel-2));
  z-index:50; transform: translateX(105%); transition: transform .3s cubic-bezier(.4,0,.2,1);
  display:flex; flex-direction:column;
}
.sidepanel.open{ transform: translateX(0); }
.sidepanel-profile{ display:flex; align-items:center; gap:12px; padding:22px 18px 18px; border-bottom:1px solid rgba(255,255,255,.08); }
.sidepanel-avatar{ width:44px; height:44px; border-radius:13px; background:linear-gradient(135deg,#A78BFA,#7C3AED); display:flex; align-items:center; justify-content:center; flex-shrink:0; overflow:hidden; box-shadow:0 4px 18px rgba(139,92,246,.55); }
.sidepanel-avatar img{ width:100%; height:100%; object-fit:cover; }
.sidepanel-avatar span{ color:#fff; font-family:'Sora',sans-serif; font-weight:700; font-size:17px; }
.navitem{ display:flex; align-items:center; gap:12px; padding:11px 12px; margin-bottom:3px; border-radius:12px; color:#AEB4D0; font-weight:600; font-size:14.5px; cursor:pointer; transition: background .15s, color .15s; }
.navitem:hover{ background: rgba(139,92,246,.12); color:#fff; }
.navitem.active{ background: linear-gradient(135deg,#8B5CF6,#6D28D9); color:#fff; box-shadow:0 4px 18px rgba(139,92,246,.5); }
.navitem-icon{ width:32px; height:32px; border-radius:9px; display:flex; align-items:center; justify-content:center; font-size:15px; flex-shrink:0; }

/* ---- Modal ---- */
.modal-backdrop{ position:fixed; inset:0; background: rgba(15,18,32,.5); z-index:60; display:flex; align-items:flex-end; justify-content:center; }
@media(min-width:640px){ .modal-backdrop{ align-items:center; } }
.modal{
  background:#fff; width:100%; max-width:520px; max-height:92vh; overflow-y:auto;
  border-radius:20px 20px 0 0; padding:22px; animation: modalUp .2s ease; box-shadow: var(--shadow-lg);
  border:1px solid var(--line);
}
.modal.wide{ max-width:640px; }
@media(min-width:640px){ .modal{ border-radius:20px; } }
@keyframes modalUp{ from{ transform: translateY(24px); opacity:0; } to{ transform:translateY(0); opacity:1; } }
.modal-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.modal-head h3{ font-size:19px; margin:0; color:var(--ink); }

/* ---- Chips ---- */
.chip{ display:inline-flex; align-items:center; gap:6px; padding:4px 11px; border-radius:999px; font-size:12.5px; font-weight:700; }
.chip-give{ background:var(--give-tint); color:var(--give); box-shadow:0 0 0 1px rgba(225,29,72,.18) inset; }
.chip-receive{ background:var(--receive-tint); color:var(--receive); box-shadow:0 0 0 1px rgba(8,145,178,.18) inset; }
.chip-clear{ background:var(--ok-tint); color:var(--ok); box-shadow:0 0 0 1px rgba(22,163,74,.18) inset; }

.ring-row{ display:flex; } .ring-row svg{ margin-left:-14px; } .ring-row svg:first-child{ margin-left:0; }

.fadein{ animation: fadeIn .2s ease; }
@keyframes fadeIn{ from{ opacity:0; transform:translateY(6px); } to{ opacity:1; transform:translateY(0); } }

.tab{ display:inline-flex; align-items:center; gap:6px; padding:9px 16px; border-radius:10px; font-size:13.5px; font-weight:700; cursor:pointer; color:var(--ink-muted); }
.tab.active{ background: var(--primary-tint); color: var(--primary); }
.supplier-tabbar{ display:inline-flex; gap:2px; background:var(--surface-2); border:1px solid var(--line); border-radius:999px; padding:4px; margin-bottom:14px; }
.supplier-tabbar .tab{ border-radius:999px; }

/* ---- Supplier detail header ---- */
.supplier-header{ padding:20px; border:2px solid var(--accent, var(--line)); box-shadow:0 8px 22px var(--accent-tint, rgba(16,24,40,.06)); margin-bottom:18px; }
.supplier-header-top{ display:flex; justify-content:space-between; align-items:flex-start; gap:16px; flex-wrap:wrap; }
.supplier-header-left{ display:flex; gap:14px; align-items:center; }
.supplier-header-avatar{ width:52px; height:52px; font-size:19px; }
.supplier-header-name{ font-size:21px; margin:0; color:var(--ink); }
.supplier-header-line{ margin:3px 0 0; color:var(--ink-muted); font-size:13px; display:flex; align-items:center; gap:6px; }
.supplier-header-right{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.supplier-mini-stat{ display:flex; flex-direction:column; padding:7px 12px; border-radius:11px; line-height:1.25; }
.supplier-mini-stat .lbl{ font-size:9.5px; text-transform:uppercase; font-weight:700; opacity:.8; letter-spacing:.03em; }
.supplier-mini-stat .val{ font-size:13px; font-weight:800; white-space:nowrap; }
.supplier-header-balance{ font-size:15px; padding:9px 18px; }
.supplier-header-actions{ display:flex; gap:8px; margin-top:16px; flex-wrap:wrap; }

/* ---- Box / payment row entries ---- */
.entry-row{ padding:13px; display:flex; align-items:center; gap:12px; flex-wrap:wrap; border-left:4px solid var(--line); }
.entry-row-icon{ width:38px; height:38px; border-radius:11px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }

/* ---- Reports picker ---- */
.reports-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:14px; }
.report-card{ padding:18px; display:flex; flex-direction:column; gap:10px; }
.report-card-icon{ width:42px; height:42px; border-radius:12px; display:flex; align-items:center; justify-content:center; }
.report-card-title{ font-weight:700; font-size:14.5px; color:var(--ink); }
.report-card-desc{ font-size:12.5px; color:var(--ink-muted); line-height:1.4; flex:1; }

.toast{ position:fixed; top:18px; left:50%; transform:translateX(-50%); z-index:100; color:#fff; padding:11px 20px; border-radius:999px; font-size:13.5px; font-weight:700; display:flex; align-items:center; gap:8px; box-shadow: var(--shadow-lg); }
.toast.error{ background:linear-gradient(135deg,#FB7185,#E11D48); }
.toast.success{ background:linear-gradient(135deg,#4ADE80,#16A34A); }

.stat-card{
  position:relative; overflow:hidden; border-radius:18px; padding:20px; min-width:0;
  color:#fff; box-shadow:0 12px 26px -8px var(--sc-shadow, rgba(124,58,237,.4));
  background: var(--sc-grad, linear-gradient(135deg,#A78BFA,#7C3AED));
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover{ transform: translateY(-3px); box-shadow:0 18px 34px -8px var(--sc-shadow, rgba(124,58,237,.5)); }
.stat-card::after{ content:''; position:absolute; top:-30px; right:-30px; width:110px; height:110px; border-radius:50%; background:rgba(255,255,255,.14); pointer-events:none; }
.stat-card::before{ content:''; position:absolute; bottom:-40px; right:20px; width:70px; height:70px; border-radius:50%; background:rgba(255,255,255,.08); pointer-events:none; }
.stat-card.stat-neutral{ --sc-grad: linear-gradient(135deg,#A78BFA,#7C3AED); --sc-shadow: rgba(124,58,237,.4); }
.stat-card.stat-give{ --sc-grad: linear-gradient(135deg,#FB7185,#E11D48); --sc-shadow: rgba(225,29,72,.38); }
.stat-card.stat-receive{ --sc-grad: linear-gradient(135deg,#22D3EE,#0891B2); --sc-shadow: rgba(8,145,178,.4); }
.stat-card.stat-gold{ --sc-grad: linear-gradient(135deg,#FBBF24,#D97706); --sc-shadow: rgba(217,119,6,.4); }
.stat-card .icon-badge{ position:relative; z-index:1; width:38px; height:38px; border-radius:11px; display:flex; align-items:center; justify-content:center; font-size:17px; background:rgba(255,255,255,.22); }
.stat-card .lbl{ position:relative; z-index:1; font-size:12.5px; font-weight:700; text-transform:uppercase; letter-spacing:.03em; color:rgba(255,255,255,.88); margin-top:12px; }
.stat-card .val{ position:relative; z-index:1; font-family:'Sora',sans-serif; font-weight:700; font-size:25px; margin-top:4px; color:#fff; }

.container{ padding:18px 16px 40px; max-width:1080px; margin:0 auto; }
.grid-stats{ display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin-bottom:20px; }
.avatar-circle{ width:42px; height:42px; border-radius:50%; background:linear-gradient(135deg,#8B5CF6,#7C3AED); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:800; font-size:15px; flex-shrink:0; box-shadow:0 3px 10px rgba(124,58,237,.35); }

/* ---- Supplier cards grid ---- */
.suppliers-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:16px; }
@media(max-width:560px){ .suppliers-grid{ grid-template-columns:1fr; } }

.chart-hint{ display:flex; gap:18px; flex-wrap:wrap; margin-bottom:14px; padding:9px 14px; background:var(--surface); border:1px solid var(--line); border-radius:11px; }
.chart-hint-item{ display:flex; align-items:center; gap:7px; font-size:12px; font-weight:600; color:var(--ink-muted); }
.dot{ width:9px; height:9px; border-radius:50%; display:inline-block; flex-shrink:0; }

.supplier-card-link{ display:block; }
.supplier-card{
  background:var(--surface); border:2px solid var(--accent, var(--line)); border-radius:18px; padding:16px;
  box-shadow:0 6px 16px var(--accent-tint, rgba(16,24,40,.05));
  transition: transform .15s ease, box-shadow .15s ease;
  display:grid; grid-template-columns: minmax(110px,1fr) auto minmax(100px,1fr);
  align-items:center; gap:12px;
}
.supplier-card:hover{ transform:translateY(-3px); box-shadow:0 14px 28px var(--accent-tint, rgba(16,24,40,.1)); }
@media(max-width:480px){
  .supplier-card{ grid-template-columns:1fr; justify-items:center; text-align:center; }
}

.supplier-card-left{ display:flex; align-items:center; gap:10px; min-width:0; }
.supplier-card-name{ font-weight:700; font-size:14.5px; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.supplier-card-phone{ font-size:11.5px; color:var(--ink-muted); display:flex; align-items:center; gap:5px; margin-top:2px; }

.supplier-card-center{ display:flex; flex-direction:column; align-items:center; }
.supplier-pie-legend{ display:flex; flex-direction:column; gap:3px; margin-top:8px; }
.supplier-pie-legend span{ display:flex; align-items:center; gap:5px; font-size:10.5px; color:var(--ink-muted); font-weight:600; white-space:nowrap; }
.supplier-pie-legend b{ color:var(--ink); font-weight:700; }

.supplier-card-right{ display:flex; flex-direction:column; gap:7px; min-width:0; }
.supplier-total-btn{ display:flex; flex-direction:column; padding:7px 12px; border-radius:11px; line-height:1.3; }
.supplier-total-btn .lbl{ font-size:9.5px; text-transform:uppercase; letter-spacing:.03em; font-weight:700; opacity:.8; }
.supplier-total-btn .val{ font-size:13px; font-weight:800; white-space:nowrap; }

@media print{
  body{ background:#fff !important; }
  body *{ visibility:hidden; }
  #print-area, #print-area *{ visibility:visible; }
  #print-area{ position:absolute; top:0; left:0; width:100%; padding:24px; color:#000; }
}

/* ---- Responsive: desktop shows centered topbar nav + logout, hides hamburger ---- */
/* Placed last on purpose so it always wins the cascade over earlier same-selector rules. */
@media(min-width:1024px){
  .topbar-center{ display:flex; }
  .topbar-logout-desktop{ display:inline-flex; }
  .hamburger{ display:none; }
}
