/* ============ Billi — Premium Billing Software Styles ============ */
:root {
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-d: #4f46e5;
  --accent: #06b6d4;
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1e2235;
  --muted: #6b7280;
  --border: #e6e8f0;
  --danger: #ef4444;
  --success: #10b981;
  --shadow: 0 10px 30px rgba(31, 38, 89, 0.08);
  --shadow-sm: 0 4px 14px rgba(31, 38, 89, 0.06);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
h1 { font-size: 26px; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0 0 14px; font-weight: 650; }
h4 { margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.hidden { display: none !important; }
a { color: var(--primary-d); text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
  border: none; cursor: pointer; font-size: 14px; font-weight: 600;
  padding: 11px 18px; border-radius: 10px; transition: .18s ease;
  display: inline-flex; align-items: center; gap: 6px; font-family: inherit;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.35); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(99,102,241,.45); }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-d); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.05); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f3c7c7; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ---------- Login / Register (split) ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-brand {
  background: linear-gradient(150deg, #4f46e5 0%, #7c3aed 50%, #06b6d4 120%);
  color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-brand::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px;
  background: rgba(255,255,255,.12); border-radius: 50%;
}
.auth-brand .logo-big { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.auth-brand .tag { font-size: 20px; font-weight: 600; max-width: 380px; line-height: 1.4; }
.auth-brand .feat { margin-top: 26px; display: grid; gap: 12px; }
.auth-brand .feat div { display: flex; gap: 10px; align-items: center; font-size: 14px; opacity: .95; }
.auth-brand .feat span { background: rgba(255,255,255,.18); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 24px; }
.auth-switch { margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: #fff; border-right: 1px solid var(--border); padding: 22px 16px;
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; padding: 4px 8px 18px; }
.brand .dot { width: 12px; height: 12px; border-radius: 4px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-btn {
  text-align: left; border: none; background: transparent; cursor: pointer; font-family: inherit;
  padding: 11px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; gap: 10px; transition: .15s;
}
.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.3); }
.logout { margin-top: 8px; }
.content { padding: 34px 40px; max-width: 1100px; }

/* ---------- Cards / grids ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.stat .s-num { font-size: 28px; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat .s-label { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
input, textarea, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text); transition: .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
textarea { resize: vertical; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
tbody tr:hover { background: #fafbff; }
.table-actions { display: flex; gap: 8px; }

/* ---------- Item lists (customers) ---------- */
.item-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.item-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: #fff; }
.ic-name { font-weight: 700; font-size: 15px; }
.ic-meta { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }
.ic-actions { display: flex; gap: 8px; }

/* ---------- Billing ---------- */
.bill-layout { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
.product-pick { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 18px; }
.pick-btn { background: #eef0ff; border: 1px solid #dfe2ff; color: var(--primary-d); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13px; font-family: inherit; transition: .15s; }
.pick-btn:hover { background: var(--primary); color: #fff; }
.qty-input { width: 70px; padding: 7px 8px; }
.bill-summary { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); position: sticky; top: 24px; }
.summary-line { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; }
.summary-total { border-top: 2px solid var(--border); margin-top: 6px; padding-top: 14px; font-weight: 800; font-size: 18px; }

/* ---------- Invoice ---------- */
.invoice { background: #fff; border-radius: 14px; box-shadow: var(--shadow); max-width: 820px; margin: 0 auto; position: relative; overflow: hidden; }
.inv-watermark { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: .04; pointer-events: none; }
.inv-inner { position: relative; padding: 40px; }
.inv-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--text); padding-bottom: 18px; }
.inv-head-left { display: flex; gap: 16px; align-items: center; }
.inv-logo { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; }
.inv-header .title { font-size: 24px; font-weight: 800; }
.inv-header .sub { font-size: 13px; color: #444; }
.inv-invoice-label { font-size: 22px; font-weight: 800; letter-spacing: 2px; color: var(--primary-d); }
.inv-fromto { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 22px 0; }
.ft-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.ft-name { font-weight: 700; font-size: 16px; margin: 4px 0; }
.inv-table { margin-top: 10px; }
.inv-table th { background: #f7f8ff; border-bottom: 1px solid var(--border); }
.inv-table .num { text-align: right; }
.inv-bottom { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: end; }
.inv-totals { background: #f7f8ff; border-radius: 12px; padding: 16px 18px; }
.inv-totals .row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; }
.inv-totals .grand { border-top: 1px solid #d9ddf5; margin-top: 6px; padding-top: 10px; font-weight: 800; font-size: 17px; }
.inv-terms { font-size: 13px; color: #444; }
.inv-sign { display: flex; justify-content: space-between; gap: 20px; margin-top: 30px; font-size: 12px; color: var(--muted); }
.inv-sign .line { border-top: 1px solid #999; padding-top: 6px; width: 180px; text-align: center; }
.inv-footer { text-align: center; margin-top: 26px; font-size: 13px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(20,24,48,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 26px; width: 100%; max-width: 440px; box-shadow: var(--shadow); position: relative; }
.modal-close { position: absolute; top: 12px; right: 16px; border: none; background: none; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #1e2235; color: #fff; padding: 12px 22px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); z-index: 200; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.empty { color: var(--muted); text-align: center; padding: 30px; font-size: 14px; }

/* ---------- Auth (index.html) ---------- */
.auth-logo { font-size: 40px; font-weight: 800; letter-spacing: -1px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.auth-tag { color: var(--muted); margin: 6px 0 26px; font-size: 15px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form h2 { font-size: 22px; margin-bottom: 2px; }
.auth-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.auth-form input { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; background: #fff; }
.auth-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }

/* ---------- App shell extras ---------- */
.brand-name { font-weight: 800; font-size: 22px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.org-badge { font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; word-break: break-word; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 12px; }
.right { text-align: right; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.stat-num { font-size: 28px; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick-btn { display: flex; align-items: center; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; font-weight: 600; font-size: 14px; color: var(--text); background: #fff; transition: .15s; }
.quick-btn:hover { border-color: var(--primary); color: var(--primary-d); transform: translateY(-1px); }
.mini-list { display: grid; gap: 8px; }
.mini-row { display: flex; justify-content: space-between; padding: 10px 12px; background: var(--bg); border-radius: 10px; font-size: 14px; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef2ff; color: var(--primary-d); vertical-align: middle; }
.badge-verified { background: #dcfce7; color: #166534; }
.company-search { position: relative; }
.search-wrap { position: relative; flex: 1; min-width: 260px; }
.suggest-box {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 40;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(31, 38, 89, 0.15);
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.suggest-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font: inherit;
}
.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover,
.suggest-item.active {
  background: #f5f3ff;
}

/* ---------- Forms / cards ---------- */
.form-card { max-width: 720px; }
.logo-row { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.logo-prev { width: 72px; height: 72px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); display: grid; place-items: center; font-size: 30px; overflow: hidden; }
.logo-prev img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Tables ---------- */
.tbl { margin-top: 4px; }
.tbl th, .tbl td { padding: 11px 10px; }

/* ---------- Billing ---------- */
.add-prod { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.add-prod select { flex: 1; min-width: 200px; }
.add-prod input { width: 90px; }
.bill-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 18px 0; flex-wrap: wrap; }
.totals { text-align: right; font-size: 15px; display: grid; gap: 4px; min-width: 220px; }
.totals .grand { font-size: 18px; font-weight: 800; margin-top: 4px; }
.iqty { width: 70px; padding: 6px 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; }
  .nav { flex-direction: row; }
  .logout { display: none; }
  .content { padding: 20px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .bill-layout, .inv-fromto, .inv-bottom { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .no-print, .toast, .modal { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .invoice { box-shadow: none; max-width: none; }
}

/* ---------- Bill type & GST toggle ---------- */
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.form-row label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.gst-toggle { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 600; }
.gst-toggle input { width: auto; }
#b-items.gst-off .col-gst { display: none; }
.badge-type { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }

.badge-warn{background:#fff7ed;color:#c2410c;border:1px solid #fed7aa}.payment-box{margin-top:18px;padding:14px;border:1px solid #e5e7eb;border-radius:12px;background:#fafafa}
@media(max-width:900px){.sidebar{position:relative;width:100%;height:auto}.app{display:block}.content{padding:18px}.nav{display:flex;flex-wrap:wrap}.nav-btn{font-size:13px}.stats{grid-template-columns:repeat(2,minmax(0,1fr))}.tbl{display:block;overflow-x:auto;white-space:nowrap}}
.badge-warn { background:#fff7ed; color:#c2410c; }
