/* UAEDEV Jewellery ERP — theme on top of Bootstrap 5.3 */

:root {
  --erp-gold: #a8823a;
  --erp-gold-strong: #8c6a2b;
  --erp-gold-soft: #f4ead6;
  --erp-ink: #151a21;
  --erp-ink-2: #1e252f;
  --erp-ivory: #f7f5f0;
  --erp-line: #e7e2d8;
  --erp-radius: .75rem;
  --erp-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-link-color: var(--erp-gold-strong);
  --bs-link-hover-color: #6f5320;
  --bs-link-color-rgb: 140, 106, 43;
  --bs-link-hover-color-rgb: 111, 83, 32;
  --bs-focus-ring-color: rgba(168, 130, 58, .35);
}
:root:not([data-bs-theme="dark"]) body { background: var(--erp-ivory); }
[data-bs-theme="dark"] {
  --erp-gold: #d0aa5e;
  --erp-gold-strong: #e0bd75;
  --erp-gold-soft: #3a2f1b;
  --erp-line: #2c333d;
  --bs-body-bg: #0f1318;
  --bs-body-color: #e5e1d8;
  --bs-tertiary-bg: #161b22;
  --bs-link-color: #e0bd75;
  --bs-link-hover-color: #f0d49a;
  --bs-link-color-rgb: 224, 189, 117;
  --bs-link-hover-color-rgb: 240, 212, 154;
}
[data-bs-theme="dark"] body { background: #0f1318; }

/* Buttons & badges */
.btn-gold {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--erp-gold-strong);
  --bs-btn-border-color: var(--erp-gold-strong);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #765824;
  --bs-btn-hover-border-color: #765824;
  --bs-btn-active-bg: #6a4f20;
  --bs-btn-active-border-color: #6a4f20;
  --bs-btn-disabled-bg: var(--erp-gold-strong);
  --bs-btn-disabled-border-color: var(--erp-gold-strong);
  --bs-btn-focus-shadow-rgb: 168, 130, 58;
  font-weight: 600;
  letter-spacing: .01em;
}
[data-bs-theme="dark"] .btn-gold { --bs-btn-color: #1a1408; --bs-btn-bg: #d0aa5e; --bs-btn-border-color: #d0aa5e; --bs-btn-hover-bg: #e0bd75; --bs-btn-hover-color: #1a1408; }
.badge-gold { background: var(--erp-gold-soft); color: var(--erp-gold-strong); border: 1px solid var(--erp-gold); }
.text-gold { color: var(--erp-gold); }
.btn-icon { width: 2.5rem; height: 2.5rem; display: inline-grid; place-items: center; border-radius: 50%; color: inherit; }
.btn-icon:hover { background: rgba(127, 127, 127, .12); }
.req { color: #b4232c; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--erp-gold); }
.form-check-input:checked { background-color: var(--erp-gold-strong); border-color: var(--erp-gold-strong); }

/* Shell */
.skip-link { position: absolute; top: .5rem; left: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: .5rem; }
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  --bs-offcanvas-width: 264px;
  --bs-offcanvas-bg: var(--erp-ink);
  width: 264px; flex-shrink: 0; background: var(--erp-ink); color: #c9c4b8;
  display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  /* Bootstrap makes .offcanvas-lg transparent at this width; keep the dark rail */
  .app-sidebar.offcanvas-lg { position: sticky; top: 0; height: 100vh; background-color: var(--erp-ink) !important; }
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark {
  width: 2.5rem; height: 2.5rem; border-radius: .65rem; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(140deg, #e3c27f, #a8823a 55%, #7b5d26); color: #1b1408; font-size: 1.2rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-family: var(--erp-serif); color: #f3ede1; font-size: 1.02rem; font-weight: 600; }
.brand-sub { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: #9c927f; }
.sidebar-nav { padding: .75rem .75rem; flex: 1; overflow-y: auto; }
.nav-group-label { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: #7f786b; padding: 1rem .75rem .4rem; }
.sidebar-link {
  display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: .55rem;
  color: #c9c4b8; text-decoration: none; font-size: .925rem; position: relative;
}
.sidebar-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; color: #8e8778; }
.sidebar-link:hover { background: var(--erp-ink-2); color: #fff; }
.sidebar-link.active { background: linear-gradient(90deg, rgba(208,170,94,.18), rgba(208,170,94,.04)); color: #f6e7c3; }
.sidebar-link.active i { color: #d9b56c; }
.sidebar-link.active::before { content: ""; position: absolute; left: -.75rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 0 3px 3px 0; background: #d0aa5e; }
.sidebar-link:focus-visible { outline: 2px solid #d0aa5e; outline-offset: 2px; }
.sidebar-foot { padding: .9rem 1.25rem; font-size: .72rem; color: #6c665a; border-top: 1px solid rgba(255,255,255,.06); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.5rem; background: color-mix(in srgb, var(--bs-body-bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--erp-line);
}
.topbar-title { font-family: var(--erp-serif); font-size: 1.35rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--erp-line); border-radius: 2rem; padding: .25rem .75rem .25rem .25rem; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--erp-gold-soft); color: var(--erp-gold-strong); }
.app-content { padding: 1.5rem; flex: 1; position: relative; }
.app-content:focus { outline: none; }
@media (max-width: 575.98px) {
  .app-content { padding: 1rem; }
  .app-topbar { padding: .6rem 1rem; }
  .topbar-title { font-size: 1.15rem; }
}
.toast-zone { position: fixed; right: 1rem; bottom: 1rem; z-index: 1090; max-width: 360px; }

/* Typography details */
code { color: #8a5a22; }
[data-bs-theme="dark"] code { color: #e0bd75; }
.panel a:not(.btn), .page-actions a.btn-link, .card-header a { text-decoration: none; }
.panel a:not(.btn):hover, .page-actions a.btn-link:hover, .card-header a:hover { text-decoration: underline; }

/* Panels */
.panel { border: 1px solid var(--erp-line); border-radius: var(--erp-radius); box-shadow: 0 1px 2px rgba(20, 20, 20, .03); }
.panel > .card-header {
  background: transparent; font-weight: 600; font-size: .9rem; border-bottom: 1px solid var(--erp-line); padding: .8rem 1rem;
}
.panel .table > :not(caption) > * > * { padding: .7rem 1rem; }
.panel .table thead th { font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--bs-secondary-color); font-weight: 600; background: var(--bs-tertiary-bg); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1 1 520px; }
.filter-bar .form-control, .filter-bar .form-select { flex: 1 1 150px; max-width: 280px; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; position: sticky; bottom: 0; padding: .75rem 0; background: linear-gradient(transparent, var(--bs-body-bg) 35%); }
:root:not([data-bs-theme="dark"]) .form-actions { background: linear-gradient(rgba(247,245,240,0), var(--erp-ivory) 35%); }
.form-narrow { max-width: 520px; }
.detail-list { display: grid; grid-template-columns: minmax(110px, 35%) 1fr; gap: .55rem 1rem; margin: 0 0 1rem; }
.detail-list dt { font-weight: 500; color: var(--bs-secondary-color); font-size: .875rem; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.empty-state { text-align: center; color: var(--bs-secondary-color); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; color: var(--erp-gold); opacity: .7; }
.empty-state p { margin: 0; }
.action-code { color: var(--bs-body-color); background: var(--bs-tertiary-bg); padding: .1rem .4rem; border-radius: .3rem; font-size: .8rem; }
.hash { font-size: .72rem; word-break: break-all; }
.json-block { margin: 0; padding: 1rem; font-size: .8rem; max-height: 360px; overflow: auto; white-space: pre-wrap; }
.role-option { padding: .45rem 0 .45rem 1.75rem; border-bottom: 1px dashed var(--erp-line); }
.role-option:last-child { border-bottom: 0; }
.perm-group .form-check { margin-bottom: .35rem; }
.temp-password code { letter-spacing: .06em; }

/* Dashboard */
.welcome-band {
  border-radius: var(--erp-radius); padding: 1.5rem 1.75rem; margin-bottom: 1.25rem; color: #efe8da;
  background: radial-gradient(120% 140% at 100% 0%, rgba(208,170,94,.35), transparent 55%), linear-gradient(120deg, #151a21, #232b36);
}
.welcome-band .text-body-secondary { color: #b9b1a1 !important; }
.eyebrow { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: #d9b56c; }
.welcome-title { font-family: var(--erp-serif); font-size: 1.75rem; margin: 0 0 .25rem; }
.stat-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .9rem; align-items: center;
  padding: 1rem 1.1rem; border: 1px solid var(--erp-line); border-radius: var(--erp-radius); background: var(--bs-body-bg);
  text-decoration: none; color: inherit; transition: border-color .15s, transform .15s;
}
.stat-card:hover { border-color: var(--erp-gold); transform: translateY(-1px); color: inherit; }
.stat-icon { grid-row: span 2; width: 2.6rem; height: 2.6rem; border-radius: .6rem; display: grid; place-items: center; background: var(--erp-gold-soft); color: var(--erp-gold-strong); font-size: 1.15rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .8rem; color: var(--bs-secondary-color); }
.roadmap { list-style: none; padding: 0; margin: 0 0 1rem; font-size: .9rem; }
.roadmap li { padding: .3rem 0; color: var(--bs-secondary-color); }
.roadmap li i { margin-right: .5rem; }
.roadmap li.done { color: var(--bs-body-color); }
.roadmap li.done i { color: var(--erp-gold); }

/* Auth pages */
.auth-body {
  min-height: 100vh;
  background: radial-gradient(90% 70% at 85% 0%, rgba(208,170,94,.28), transparent 60%), radial-gradient(70% 60% at 0% 100%, rgba(208,170,94,.12), transparent 60%), #12161c !important;
}
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-brand { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.5rem; color: #f3ede1; }
.auth-brand .brand-mark { width: 3rem; height: 3rem; font-size: 1.4rem; }
.auth-brand-name { font-family: var(--erp-serif); font-size: 1.4rem; font-weight: 600; }
.auth-brand-sub { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: #a89f8c; }
.auth-card { width: 100%; max-width: 440px; background: var(--bs-body-bg); border-radius: 1rem; padding: 2rem; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.auth-title { font-family: var(--erp-serif); font-size: 1.6rem; margin-bottom: .25rem; }
.auth-lead { color: var(--bs-secondary-color); font-size: .92rem; margin-bottom: 1.5rem; }
.auth-foot { margin-top: 1.25rem; font-size: .75rem; color: #7d7667; letter-spacing: .06em; }
@media (max-width: 575.98px) { .auth-card { padding: 1.5rem; } }

/* Errors */
.error-panel { max-width: 520px; margin: 3rem auto; text-align: center; }
.error-code { font-family: var(--erp-serif); font-size: 4rem; color: var(--erp-gold); line-height: 1; }
.error-message { margin: 1rem 0 1.5rem; color: var(--bs-secondary-color); }

/* Phase 2: branding, wizard, master data */
.brand-logo { width: 2.5rem; height: 2.5rem; object-fit: contain; border-radius: .5rem; background: #fff; padding: .15rem; flex-shrink: 0; }
.auth-logo { max-height: 3.25rem; max-width: 9rem; object-fit: contain; background: #fff; border-radius: .6rem; padding: .25rem; }
.logo-preview { min-height: 5rem; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--erp-line); border-radius: var(--erp-radius); padding: 1rem; background: var(--bs-tertiary-bg); }
.logo-preview img { max-height: 6rem; max-width: 100%; object-fit: contain; }
.overview-logo { width: 5rem; height: 5rem; object-fit: contain; border: 1px solid var(--erp-line); border-radius: .6rem; padding: .25rem; background: #fff; }
.wizard-steps { display: flex; gap: .25rem; margin-bottom: 1.25rem; overflow-x: auto; padding-bottom: .25rem; }
.wizard-step { flex: 1 0 auto; display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; border-radius: .6rem; text-decoration: none; color: var(--bs-secondary-color); border: 1px solid var(--erp-line); background: var(--bs-body-bg); font-size: .85rem; white-space: nowrap; }
.wizard-step:hover { border-color: var(--erp-gold); color: var(--bs-body-color); }
.wizard-num { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .78rem; background: var(--bs-tertiary-bg); }
.wizard-step.past .wizard-num { background: var(--erp-gold-soft); color: var(--erp-gold-strong); }
.wizard-step.current { border-color: var(--erp-gold); color: var(--bs-body-color); font-weight: 600; box-shadow: 0 0 0 3px rgba(168,130,58,.12); }
.wizard-step.current .wizard-num { background: var(--erp-gold-strong); color: #fff; }
@media (max-width: 767.98px) { .wizard-label { display: none; } .wizard-step.current .wizard-label { display: inline; } }
.currency-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .25rem .75rem; }
.numbering-table td, .numbering-table th { vertical-align: middle; }
.numbering-table input[data-prefix] { max-width: 7rem; }
@media (max-width: 767.98px) {
  .numbering-table thead { display: none; }
  .numbering-table tr { display: grid; grid-template-columns: 6.5rem 1fr; gap: .4rem .5rem; padding: .75rem 0; border-bottom: 1px solid var(--erp-line); }
  .numbering-table th[scope="row"] { grid-column: 1 / -1; font-weight: 600 !important; padding: 0; border: 0; }
  .numbering-table td { padding: 0; border: 0; }
  .numbering-table td:last-child { grid-column: 1 / -1; }
  .numbering-table input[data-prefix] { max-width: none; }
}
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { position: relative; padding: .4rem 0 .4rem 1.75rem; border-bottom: 1px dashed var(--erp-line); }
.checklist li:last-child { border-bottom: 0; }
.checklist li i { position: absolute; left: 0; top: .5rem; color: var(--bs-tertiary-color); }
.checklist li.done i { color: var(--erp-gold); }
.checklist li.done a { color: var(--bs-secondary-color); }
.checklist-progress { width: 100%; height: .4rem; border: 0; border-radius: 1rem; background: var(--bs-tertiary-bg); overflow: hidden; appearance: none; display: block; }
.checklist-progress::-webkit-progress-bar { background: var(--bs-tertiary-bg); border-radius: 1rem; }
.checklist-progress::-webkit-progress-value { background: var(--erp-gold); border-radius: 1rem; }
.checklist-progress::-moz-progress-bar { background: var(--erp-gold); border-radius: 1rem; }
.setup-banner { border-color: var(--erp-gold); background: linear-gradient(120deg, var(--erp-gold-soft), transparent 60%), var(--bs-body-bg); }
.branch-card { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.branch-card:hover { border-color: var(--erp-gold); transform: translateY(-1px); color: inherit; }
.branch-card.inactive { opacity: .6; }
.branch-code { font-family: var(--bs-font-monospace); font-weight: 700; font-size: .8rem; padding: .15rem .5rem; border-radius: .35rem; background: var(--erp-gold-soft); color: var(--erp-gold-strong); }
.tree-indent { display: inline-block; width: 0; }
.tree-indent[data-depth="1"] { width: 1.25rem; } .tree-indent[data-depth="2"] { width: 2.5rem; } .tree-indent[data-depth="3"] { width: 3.75rem; } .tree-indent[data-depth="4"], .tree-indent[data-depth="5"] { width: 5rem; }
.grading-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-block; min-width: 2.4rem; text-align: center; padding: .3rem .6rem; border: 1px solid var(--erp-line); border-radius: 2rem; font-size: .82rem; font-weight: 600; text-decoration: none; color: var(--bs-body-color); background: var(--bs-body-bg); }
a.chip:hover { border-color: var(--erp-gold); color: var(--erp-gold-strong); }
.chip.inactive { opacity: .45; text-decoration: line-through; }
.masked { letter-spacing: .1em; color: var(--bs-tertiary-color); cursor: help; }
.repeater-row { padding: .5rem 0; border-bottom: 1px dashed var(--erp-line); }
.repeater-row:last-child { border-bottom: 0; }
.nav-tabs .nav-link { color: var(--bs-secondary-color); }
.nav-tabs .nav-link.active { color: var(--bs-body-color); font-weight: 600; border-bottom-color: var(--bs-body-bg); }

/* Phase 3: rates and inventory */
.rate-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.rate-card { border: 1px solid var(--erp-line); border-radius: var(--erp-radius); padding: .8rem 1rem; background: var(--bs-body-bg); }
.rate-card.empty { opacity: .7; }
.rate-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; }
.rate-label { font-family: var(--erp-serif); font-size: 1.35rem; font-weight: 600; color: var(--erp-gold-strong); }
.rate-row { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.rate-row strong { font-size: 1.05rem; }
.rate-tola { margin-top: .2rem; font-variant-numeric: tabular-nums; }
.rate-meta { font-size: .72rem; color: var(--bs-tertiary-color); margin-top: .35rem; }
.rate-empty { color: var(--bs-tertiary-color); font-size: .85rem; padding: .5rem 0; }
.rate-entry input { min-width: 6rem; }
.rate-strip { display: flex; flex-wrap: wrap; gap: .75rem 2rem; }
.rate-strip > div { display: flex; align-items: baseline; gap: .6rem; }
.history-scroll { max-height: 420px; overflow-y: auto; }
.stat-card.static:hover { transform: none; border-color: var(--erp-line); }
.fine-output { font-family: var(--bs-font-monospace); font-size: 1.1rem; font-weight: 600; padding: .4rem .75rem; border-radius: .4rem; background: var(--erp-gold-soft); color: var(--erp-gold-strong); }
.inv-tabs .nav-link { color: var(--bs-secondary-color); border-radius: 2rem; padding: .35rem .9rem; }
.inv-tabs .nav-link.active { background: var(--erp-ink); color: #f6e7c3; }
[data-bs-theme="dark"] .inv-tabs .nav-link.active { background: var(--erp-gold-soft); color: var(--erp-gold-strong); }
.scan-box { min-width: 240px; }
.check-col { width: 2.25rem; }
.item-photo { width: 100%; max-height: 260px; object-fit: contain; background: #fff; border-bottom: 1px solid var(--erp-line); border-radius: var(--erp-radius) var(--erp-radius) 0 0; }
.barcode-box { background: #fff; border: 1px solid var(--erp-line); border-radius: .5rem; padding: .5rem .5rem .25rem; color: #000; }
.barcode-box svg { width: 100%; height: 48px; display: block; }
.price-big { font-family: var(--erp-serif); font-size: 1.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .app-sidebar, .app-topbar, .page-actions, .form-actions { display: none !important; }
  .app-content { padding: 0; }
}
