/* ===== Jewelry Stock Control — White + Gold theme ===== */
:root{
  --gold:#c9a227; --gold-deep:#a07e18; --gold-soft:#e8d49a; --gold-tint:#faf5e6;
  --ink:#2b2620; --muted:#8a8174; --line:#ece7da; --bg:#fbfaf7; --white:#fff;
  --radius:14px; --shadow:0 6px 24px rgba(160,126,24,.08); --nav-w:248px;
  --font:'Poppins',system-ui,Segoe UI,sans-serif; --font-body:'Inter',system-ui,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0}
body{font-family:var(--font-body);color:var(--ink);background:var(--bg);-webkit-font-smoothing:antialiased}
h1,h2,h3{font-family:var(--font);margin:0;font-weight:600}
a{color:inherit;text-decoration:none}
.muted{color:var(--muted);font-size:.85rem}
.hidden{display:none!important}

/* ---- Side nav ---- */
.sidenav{position:fixed;top:0;left:0;bottom:0;width:var(--nav-w);background:var(--white);
  border-right:1px solid var(--line);display:flex;flex-direction:column;padding:22px 16px;z-index:20}
.brand{display:flex;align-items:center;gap:10px;padding:8px 10px 22px;font-family:var(--font);font-size:1.25rem}
.brand-mark{color:var(--gold);font-size:1.4rem}
.brand-text strong{color:var(--gold-deep)}
.nav-link{display:flex;align-items:center;gap:12px;padding:13px 14px;border-radius:12px;
  color:var(--muted);font-weight:500;margin-bottom:6px;transition:.18s}
.nav-link:hover{background:var(--gold-tint);color:var(--ink)}
.nav-link.is-active{background:linear-gradient(135deg,var(--gold),var(--gold-deep));color:#fff;box-shadow:var(--shadow)}
.nav-ico{width:20px;height:20px;display:inline-block;background:currentColor;
  -webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center}
.ico-plus{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E")}
.ico-list{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E")}
.ico-cog{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z'/%3E%3C/svg%3E")}
.sidenav-foot{margin-top:auto;color:var(--gold-deep);font-size:.72rem;letter-spacing:.18em;text-transform:uppercase;text-align:center;opacity:.6}

/* ---- Content ---- */
.content{margin-left:var(--nav-w);min-height:100vh}
.topbar{padding:26px 32px 6px}
.topbar h1{font-size:1.5rem}
.page{padding:18px 32px 80px;max-width:1180px}

/* ---- Cards ---- */
.card{background:var(--white);border:1px solid var(--line);border-radius:var(--radius);
  box-shadow:var(--shadow);padding:22px;margin-bottom:22px}
.card-head h2{font-size:1.15rem}
.card-head .muted{margin:6px 0 0}

/* ---- Form ---- */
.grid{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-top:18px}
.id-grid{grid-template-columns:1.6fr .8fr .8fr .8fr 1.4fr}
.bill-grid{grid-template-columns:1.6fr .8fr 1fr 1.6fr}
.price-grid{grid-template-columns:repeat(7,1fr)}
.field{display:flex;flex-direction:column;gap:6px;min-width:0}
.field.span-2{grid-column:span 2}
label{font-size:.78rem;font-weight:600;color:var(--muted)}
input,select{font-family:var(--font-body);font-size:.92rem;padding:11px 12px;border:1px solid var(--line);
  border-radius:10px;background:#fff;color:var(--ink);width:100%}
input:focus,select:focus{outline:none;border-color:var(--gold);box-shadow:0 0 0 3px var(--gold-tint)}
.hint{color:var(--muted);font-size:.72rem}
.combo{display:flex;gap:8px}
.combo select{flex:1}
.add-btn{flex:0 0 auto;width:42px;border:1px solid var(--gold-soft);background:var(--gold-tint);
  color:var(--gold-deep);font-size:1.2rem;font-weight:600;border-radius:10px;cursor:pointer;transition:.15s}
.add-btn:hover{background:var(--gold);color:#fff;border-color:var(--gold)}

.field.calc output{padding:11px 12px;border-radius:10px;background:var(--gold-tint);
  border:1px dashed var(--gold-soft);font-weight:600;color:var(--gold-deep);display:block}
.id-preview .stockid-pill{padding:11px 12px;border-radius:10px;background:var(--ink);color:var(--gold-soft);
  font-family:var(--font);font-weight:600;letter-spacing:.04em;text-align:center}

.actions{display:flex;gap:12px;flex-wrap:wrap;margin-top:24px}
.btn-primary{background:linear-gradient(135deg,var(--gold),var(--gold-deep));color:#fff;border:none;
  padding:12px 22px;border-radius:11px;font-family:var(--font);font-weight:600;cursor:pointer;box-shadow:var(--shadow)}
.btn-primary:hover{filter:brightness(1.05)}
.btn-ghost{background:#fff;border:1px solid var(--line);padding:12px 18px;border-radius:11px;
  font-family:var(--font);font-weight:500;color:var(--muted);cursor:pointer}
.btn-ghost:hover{border-color:var(--gold-soft);color:var(--ink)}

/* ---- Lots & pieces (bill builder) ---- */
.lot{border:1px solid var(--gold-soft);padding:16px 18px}
.lot-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px}
.lot-head h3{font-size:1.05rem;color:var(--gold-deep)}
.lot-head h3 .lot-no{display:inline-block;min-width:1.4em;text-align:center}
.lot-remove,.piece-remove{border:none;background:transparent;color:var(--muted);font-size:1rem;cursor:pointer;width:30px;height:30px;border-radius:8px}
.lot-remove:hover,.piece-remove:hover{background:#fbeaea;color:#9b2c2c}
.pieces{display:flex;flex-direction:column;gap:14px;margin:10px 0 14px}
.piece{border:1px solid var(--line);border-radius:12px;padding:14px;background:var(--bg)}
.piece-head{display:flex;align-items:center;gap:12px;margin-bottom:10px}
.piece-tag{font-family:var(--font);font-weight:600;font-size:.85rem;color:var(--ink)}
.piece-id{font-family:var(--font);font-weight:600;color:#fff;background:var(--ink);padding:3px 10px;border-radius:20px;font-size:.78rem;letter-spacing:.03em}
.piece-head .piece-remove{margin-left:auto}
.piece-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}
.piece-grid .calc output{padding:11px 12px;border-radius:10px;background:var(--gold-tint);border:1px dashed var(--gold-soft);font-weight:600;color:var(--gold-deep);display:block}
.add-piece{align-self:flex-start}
.bill-total .stockid-pill{background:linear-gradient(135deg,var(--gold),var(--gold-deep));color:#fff;font-size:.95rem}

/* ---- Issued panel ---- */
.issued{border:1.5px solid var(--gold-soft)}
.issued-head{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:14px}
.stockid-big{font-family:var(--font);font-size:2rem;font-weight:700;color:var(--gold-deep);letter-spacing:.03em}
.issued-summary{margin-top:14px;color:var(--muted);font-size:.9rem;line-height:1.7}
.issued-summary b{color:var(--ink)}

/* ---- Report ---- */
.search-row{display:flex;gap:12px}
.search-row input{flex:1}
.filter-row{display:flex;gap:10px;flex-wrap:wrap;margin-top:14px}
.filter-row select{width:auto;min-width:140px}
.table-card{padding:0;overflow:hidden}
.table-meta{padding:14px 18px;border-bottom:1px solid var(--line);font-weight:600;color:var(--gold-deep)}
.table-scroll{overflow:auto}
.grid-table{border-collapse:collapse;width:100%;font-size:.84rem;white-space:nowrap}
.grid-table th,.grid-table td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--line)}
.grid-table thead th{position:sticky;top:0;background:var(--gold-tint);color:var(--gold-deep);font-family:var(--font);font-weight:600;z-index:1}
.grid-table tbody tr:hover{background:var(--gold-tint)}
.grid-table .num{text-align:right}
.grid-table .sid{font-family:var(--font);font-weight:600;color:var(--gold-deep)}
.grid-table .mode-tag{font-size:.7rem;padding:2px 8px;border-radius:20px;background:var(--gold-tint);border:1px solid var(--gold-soft);color:var(--gold-deep)}
.row-print{color:var(--gold-deep);font-weight:600}
.empty{padding:40px;text-align:center;color:var(--muted)}

/* ---- Manage page ---- */
.section-head{margin-bottom:16px}
.section-head h2{font-size:1.4rem;color:var(--gold-deep)}
.section-head .muted{margin-top:6px;max-width:760px}
.manage-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(290px,1fr));gap:18px;align-items:start}
.supplier-card{grid-column:1/-1}
.list-card{padding:16px 18px}
.list-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;padding-bottom:10px;border-bottom:1px solid var(--line)}
.list-head h3{font-size:1rem;color:var(--ink)}
.list-head .count{background:var(--gold-tint);color:var(--gold-deep);border:1px solid var(--gold-soft);font-size:.74rem;font-weight:600;padding:2px 10px;border-radius:20px}
.list-rows{display:flex;flex-direction:column;gap:8px;max-height:340px;overflow:auto;padding-right:2px}
.list-row{display:flex;align-items:center;gap:6px}
.list-row input{padding:8px 10px;font-size:.86rem}
.list-row .opt-val,.list-row .sup-name{flex:1;min-width:0}
.list-row .sup-code{flex:0 0 84px;text-transform:uppercase;font-weight:600}
.supplier-card .list-row{flex-wrap:nowrap}
.use{flex:0 0 auto;min-width:26px;text-align:center;font-size:.72rem;color:var(--muted);background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:3px 6px}
.row-save,.row-del{flex:0 0 auto;width:32px;height:32px;border:1px solid var(--line);background:#fff;border-radius:8px;cursor:pointer;font-size:.85rem;line-height:1}
.row-save{color:var(--gold-deep)}.row-save:hover{background:var(--gold);color:#fff;border-color:var(--gold)}
.row-del{color:#b06}.row-del:hover{background:#fbeaea;color:#9b2c2c;border-color:#e8b4b4}
.list-add{display:flex;gap:6px;margin-top:12px;padding-top:12px;border-top:1px dashed var(--line)}
.list-add input{flex:1;min-width:0;padding:8px 10px;font-size:.86rem}
.sup-add .add-code{flex:0 0 84px}
.add-row,.add-sup{flex:0 0 auto;width:40px;border:1px solid var(--gold-soft);background:var(--gold-tint);color:var(--gold-deep);font-size:1.1rem;font-weight:600;border-radius:8px;cursor:pointer}
.add-row:hover,.add-sup:hover{background:var(--gold);color:#fff;border-color:var(--gold)}

/* ---- Modal ---- */
.modal{position:fixed;inset:0;background:rgba(43,38,32,.45);display:flex;align-items:center;justify-content:center;z-index:50;padding:20px}
.modal-box{background:#fff;border-radius:var(--radius);padding:24px;width:100%;max-width:420px;box-shadow:0 20px 60px rgba(0,0,0,.25)}
.modal-box h3{font-size:1.15rem;margin-bottom:16px;color:var(--gold-deep)}
.modal-box .field{margin-bottom:14px}
.modal-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:8px}

/* ---- Toast ---- */
.toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);background:var(--ink);color:#fff;
  padding:13px 22px;border-radius:12px;font-size:.9rem;z-index:60;box-shadow:0 10px 30px rgba(0,0,0,.3);opacity:0;transition:.25s}
.toast.show{opacity:1;transform:translateX(-50%) translateY(-6px)}
.toast.err{background:#9b2c2c}

/* ---- Bottom nav (mobile only) ---- */
.bottomnav{display:none}

@media(max-width:860px){
  .sidenav{display:none}
  .content{margin-left:0}
  .topbar{padding:18px 18px 4px}
  .page{padding:14px 16px 96px}
  .grid,.id-grid,.price-grid,.bill-grid,.piece-grid{grid-template-columns:repeat(2,1fr)}
  .field.span-2{grid-column:span 2}
  .id-preview{grid-column:span 2}
  .issued-actions,.actions{flex-wrap:wrap}
  .bottomnav{display:flex;position:fixed;bottom:0;left:0;right:0;background:#fff;border-top:1px solid var(--line);
    z-index:30;box-shadow:0 -4px 20px rgba(160,126,24,.08);padding:6px env(safe-area-inset-right) calc(6px + env(safe-area-inset-bottom)) env(safe-area-inset-left)}
  .bottomnav a{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;padding:8px;
    color:var(--muted);font-size:.72rem;font-weight:600}
  .bottomnav a .nav-ico{width:22px;height:22px}
  .bottomnav a.is-active{color:var(--gold-deep)}
}
@media(max-width:480px){
  .grid,.id-grid,.price-grid{grid-template-columns:1fr 1fr}
  .search-row{flex-direction:column}
}
