/* ==================== FONTS ==================== */
@font-face {
  font-family: "Colizeum-Brand";
  src: url("../fonts/Colizeum-Brand.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "TTSquares";
  src: url("../fonts/TTSquares-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "TTSquares";
  src: url("../fonts/TTSquares-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ==================== VARIABLES ==================== */
:root {
  --bg:       #08090d;
  --bg2:      #0b0d15;
  --card:     #0f1119;
  --card2:    #13161f;
  --line:     #1c2030;
  --line2:    #252a3a;
  --text:     #e8ecf4;
  --muted:    #7a8299;
  --yellow:   #ffd200;
  --yellow-2: #ffc400;
  --yellow-dim: rgba(255,210,0,.18);
  --yellow-glow: rgba(255,210,0,.35);
  --danger:   #ff4d4f;
  --success:  #28c76f;
  --radius:   12px;
  --ease:     cubic-bezier(.4,0,.2,1);
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: var(--bg); }
::-webkit-scrollbar-thumb        { background: var(--line2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover  { background: var(--yellow); }

/* ==================== BASE ==================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  background-color: var(--bg);
  color: var(--text);
  font-family: "TTSquares", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 400;
  /* subtle dot grid */
  background-image: radial-gradient(circle, #1a1e2e 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
}

/* page fade-in — финальный keyframe без transform,
   чтобы main.container не создавал stacking context
   и не перекрывал Bootstrap backdrop (z-index 1040) */
main.container {
  animation: pageIn .28s var(--ease) both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; }
}

/* ==================== NAVBAR ==================== */
.cz-nav {
  background: #0b0d15;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 24px rgba(0,0,0,.6);
}

.cz-nav-inner { gap: .5rem; }

.cz-brand {
  font-family: "Colizeum-Brand", "TTSquares", sans-serif;
  color: var(--yellow);
  letter-spacing: 1.5px;
  font-size: 1.3rem;
  text-shadow: 0 0 16px rgba(255,210,0,.5), 0 0 40px rgba(255,210,0,.2);
  transition: text-shadow .2s var(--ease);
}
.cz-brand:hover {
  color: var(--yellow);
  text-shadow: 0 0 24px rgba(255,210,0,.8), 0 0 60px rgba(255,210,0,.4);
}

.cz-nav .nav-link {
  color: var(--muted);
  font-weight: 700;
  font-size: .875rem;
  letter-spacing: .4px;
  padding: .5rem .75rem;
  border-radius: 8px;
  position: relative;
  transition: color .18s var(--ease), background .18s var(--ease);
}
.cz-nav .nav-link:hover {
  color: var(--yellow);
  background: rgba(255,210,0,.07);
}
/* animated underline */
.cz-nav .nav-link::after {
  content: '';
  position: absolute;
  bottom: 2px; left: 50%;
  width: 0; height: 2px;
  background: var(--yellow);
  border-radius: 1px;
  box-shadow: 0 0 6px var(--yellow);
  transition: width .18s var(--ease), left .18s var(--ease);
}
.cz-nav .nav-link:hover::after { width: 60%; left: 20%; }

.cz-user {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .3px;
}

/* logout button in nav */
.cz-nav .btn-outline-light {
  padding: .3rem .9rem;
  font-size: .8rem;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 28px rgba(0,0,0,.35);
  transition: box-shadow .2s var(--ease);
}

/* ==================== FORMS ==================== */
.form-control, .form-select {
  background: #080a12 !important;
  border: 1px solid var(--line);
  color: var(--text) !important;
  caret-color: var(--text);
  border-radius: 8px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.form-control::placeholder { color: #474f6a; opacity: 1; }
.form-control:focus, .form-select:focus {
  background: #080a12 !important;
  color: var(--text) !important;
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255,210,0,.12), 0 0 14px rgba(255,210,0,.08);
  outline: none;
}
.form-label  { color: var(--text) !important; font-weight: 700; font-size: .85rem; letter-spacing: .3px; }
.form-text   { color: var(--muted) !important; font-size: .8rem; }

/* hide native number-input spin buttons — typing/keyboard arrows still work */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input:-webkit-autofill,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text) !important;
  box-shadow: 0 0 0px 1000px #080a12 inset !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-out 0s;
}

/* ==================== BUTTONS ==================== */
.btn {
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: .3px;
  transition: all .18s var(--ease);
  position: relative;
  overflow: hidden;
}
/* ripple shimmer on hover */
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.12) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform .4s var(--ease);
}
.btn:hover::before { transform: translateX(100%); }

.btn-primary {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #0a0b0f;
  box-shadow: 0 2px 14px rgba(255,210,0,.28);
}
.btn-primary:hover {
  background: var(--yellow-2);
  border-color: var(--yellow-2);
  color: #0a0b0f;
  box-shadow: 0 4px 22px rgba(255,210,0,.5);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(255,210,0,.3);
}

.btn-outline-light {
  border-color: var(--line2);
  color: var(--muted);
  background: transparent;
}
.btn-outline-light:hover {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #0a0b0f;
  box-shadow: 0 4px 18px rgba(255,210,0,.35);
  transform: translateY(-1px);
}
.btn-outline-light:active { transform: translateY(0); }

.btn-secondary {
  background: var(--card2);
  border-color: var(--line2);
  color: var(--muted);
}
.btn-secondary:hover {
  background: var(--line2);
  border-color: var(--line2);
  color: var(--text);
}

.btn-close { filter: invert(1) brightness(.6); transition: filter .15s; }
.btn-close:hover { filter: invert(1) brightness(1); }

/* ==================== TABLES ==================== */
.table {
  color: var(--text);
  --bs-table-bg: transparent;
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg: transparent;
  margin-bottom: 0;
}
.table thead th {
  background: #080a14;
  color: var(--yellow);
  border-color: var(--line);
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 11px 16px;
  white-space: nowrap;
}
.table tbody td {
  border-color: var(--line);
  color: var(--text);
  padding: 11px 16px;
  vertical-align: middle;
  font-size: .9rem;
}
/* striped */
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background: rgba(255,255,255,.018);
}

.table-hover tbody tr { transition: background .15s var(--ease); }
.table-hover tbody tr:hover td {
  background: rgba(255,210,0,.045) !important;
}

/* clickable rows */
.cz-row { transition: background .15s var(--ease); cursor: pointer; }
.cz-row:hover td {
  background: rgba(255,210,0,.06) !important;
  box-shadow: inset 3px 0 0 var(--yellow);
}

.table-rounded {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 4px 24px rgba(0,0,0,.28);
}
.table-rounded.table-responsive { overflow-x: auto; overflow-y: hidden; }

/* breaks a wide element out of the centered Bootstrap .container so it CAN use the
   full viewport width, but only actually does so if its content needs it — the child
   is centered and sized to its own content (shrink-to-fit), not stretched to 100vw */
.cz-full-bleed {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  padding-left: clamp(1rem, 4vw, 3rem);
  padding-right: clamp(1rem, 4vw, 3rem);
  box-sizing: border-box;
  display: flex;
  justify-content: center;
}
.cz-full-bleed > * { max-width: 100%; }

/* per-row autosave indicator (scan.html-style feedback, but tiny/inline) */
.cz-save-indicator {
  display: inline-block;
  margin-left: 6px;
  opacity: 0;
  transition: opacity .3s ease;
}
.cz-save-indicator.cz-save-ok  { color: var(--success); opacity: 1; }
.cz-save-indicator.cz-save-err { color: var(--danger); opacity: 1; }

/* narrow, fixed-width qty inputs — don't let Bootstrap's .form-control (width:100%)
   soak up leftover space once the table stretches full-bleed */
.cz-qty-input {
  width: 64px !important;
  min-width: 64px;
  flex: 0 0 auto;
}

/* shortage highlight: positive = real unaccounted loss, zero/negative = fine.
   !important needed — .table tbody td { color: var(--text) } outranks a single
   class on specificity, regardless of source order. */
.cz-shortage-bad { color: var(--danger) !important; font-weight: 700; }
.cz-shortage-ok  { color: var(--success) !important; font-weight: 700; }

/* highlight the inventory row currently being edited (input focus), on top of
   the regular .table-hover mouse-hover state */
#invTable tbody tr:focus-within td {
  background: rgba(255,210,0,.09) !important;
  box-shadow: inset 3px 0 0 var(--yellow);
}

/* Sticky <thead> needs its scrolling ancestor's scrollport to actually scroll.
   Because this table's wrapper also needs horizontal scroll (overflow-x:auto),
   the browser forces overflow-y into a "non-visible" scroll container too — if
   that container's height is left auto (grows with content, never scrolls),
   sticky has nothing to stick against and just scrolls away with the page.
   Fix: give the wrapper a real bounded height (set via JS) so IT scrolls
   internally, and stick the header to the top of that panel, not the page. */
.cz-scroll-panel {
  overflow-y: auto !important;
}
#invTable thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

.table-rounded.products-table-wrap {
  display: inline-block;
  width: max-content;
  min-width: 100%;
  overflow: visible;
}
.products-table { width: max-content; min-width: 100%; }

.table-rounded.history-ops-wrap {
  display: inline-block;
  width: max-content;
  min-width: 100%;
  overflow: visible;
}
.history-ops { width: max-content; min-width: 100%; }
.history-ops th,
.history-ops td    { white-space: nowrap; }
.table-nowrap th,
.table-nowrap td   { white-space: nowrap; }

/* ==================== BADGES ==================== */
.badge-bar {
  background: rgba(255,210,0,.07);
  border: 1px solid rgba(255,210,0,.3);
  color: var(--yellow);
  border-radius: 999px;
  padding: .28rem .65rem;
  font-weight: 700;
  font-size: .72rem;
  letter-spacing: .4px;
  transition: all .15s var(--ease);
  display: inline-block;
}
.badge-bar:hover {
  background: rgba(255,210,0,.16);
  border-color: var(--yellow);
  box-shadow: 0 0 8px rgba(255,210,0,.22);
}

.link-yellow { color: var(--yellow); font-weight: 700; text-decoration: none; }
.link-yellow:hover { color: var(--yellow-2); text-decoration: underline; }

/* ==================== ALERTS ==================== */
.alert {
  border-radius: 10px;
  border-left-width: 3px;
  border-right-width: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  padding: .85rem 1.1rem;
  font-size: .9rem;
  animation: alertIn .25s var(--ease) both;
}
@keyframes alertIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.alert-success {
  background: rgba(40,199,111,.09);
  border-color: var(--success);
  color: #b6f0d1;
}
.alert-danger {
  background: rgba(255,77,79,.09);
  border-color: var(--danger);
  color: #ffc8c9;
}
.alert-warning {
  background: rgba(255,210,0,.09);
  border-color: var(--yellow);
  color: #fff0a8;
}

/* ==================== MODALS ==================== */
.modal-content {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line2);
  border-radius: 16px;
  box-shadow:
    0 24px 64px rgba(0,0,0,.7),
    0 0 0 1px rgba(255,210,0,.04),
    inset 0 1px 0 rgba(255,255,255,.04);
}
.modal-header {
  border-bottom: 1px solid var(--line);
  padding: 1.1rem 1.4rem;
}
.modal-title { font-weight: 700; font-size: 1rem; letter-spacing: .3px; }
.modal-footer { border-top: 1px solid var(--line); padding: .9rem 1.4rem; }
.modal-body   { padding: 1.2rem 1.4rem; }

.modal-backdrop.show { opacity: .65; }

.cz-modal .modal-dialog { max-width: 95vw; width: auto; }
.cz-modal .table-responsive { overflow-x: auto; }


/* ==================== LOGIN PAGE ==================== */
.login-wrap {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(255,210,0,.04);
}
.login-title {
  font-family: "Colizeum-Brand", "TTSquares", sans-serif;
  color: var(--yellow);
  text-shadow: 0 0 20px rgba(255,210,0,.4);
  font-size: 1.6rem;
  letter-spacing: 1px;
  margin-bottom: 1.6rem;
}

/* ==================== SECTION HEADINGS ==================== */
h4.mb-3, h4.mb-2, h4 {
  font-weight: 700;
  letter-spacing: .4px;
}
h5.mb-2, h5.mb-3, h5 {
  font-weight: 700;
  font-size: .95rem;
  color: var(--muted);
  letter-spacing: .5px;
  text-transform: uppercase;
}

/* ==================== DEBT HIGHLIGHT ==================== */
strong {
  font-weight: 700;
}
/* big debt number on user dashboard */
.mb-3 > strong {
  color: var(--yellow);
  font-size: 1.05em;
  text-shadow: 0 0 10px rgba(255,210,0,.25);
}

/* ==================== PERIOD BUTTONS (history) ==================== */
.btn.btn-primary.btn-sm,
.btn.btn-outline-light.btn-sm {
  font-size: .78rem;
  padding: .3rem .75rem;
  border-radius: 6px;
}

/* ==================== INPUTS WITH ICONS / SEARCH ==================== */
.input-icon-wrap { position: relative; }
.input-icon-wrap .form-control { padding-left: 2.2rem; }
.input-icon-wrap .input-icon {
  position: absolute;
  left: .7rem; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* ==================== AUTOCOMPLETE / NAME SEARCH ==================== */
.cz-autocomplete { position: relative; }

.cz-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--card2);
  border: 1px solid var(--line2);
  border-radius: 0 0 10px 10px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 200;
  display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,.55);
}
.cz-dropdown.open { display: block; }

.cz-dropdown-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.cz-dropdown-item:last-child { border-bottom: none; }
.cz-dropdown-item .di-price {
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.cz-dropdown-item:hover,
.cz-dropdown-item.cz-active {
  background: rgba(255,210,0,.08);
  color: var(--yellow);
}
.cz-dropdown-item:hover .di-price,
.cz-dropdown-item.cz-active .di-price { color: rgba(255,210,0,.55); }

.cz-dropdown-empty {
  padding: 12px 14px;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}

/* ==================== ICONS ==================== */
.cz-nav .nav-link i,
.cz-user i,
.btn i {
  margin-right: 5px;
  font-size: .95em;
  vertical-align: -1px;
}
h5.mb-2 i, h5.mb-3 i { margin-right: 6px; color: var(--yellow); }

/* ==================== SECTION HEADINGS ACCENT ==================== */
h5.mb-2, h5.mb-3 {
  display: flex;
  align-items: center;
  gap: .5rem;
  position: relative;
  padding-left: 12px;
}
h5.mb-2::before, h5.mb-3::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 16px;
  background: var(--yellow);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255,210,0,.5);
}

/* ==================== STAT TILE ==================== */
.cz-stat {
  display: inline-flex;
  flex-direction: column;
  gap: .2rem;
  background: linear-gradient(160deg, var(--card2), var(--card));
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: 1.1rem 1.6rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.03);
}
.cz-stat .cz-stat-label {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.cz-stat .cz-stat-value {
  color: var(--yellow);
  font-family: "Colizeum-Brand", "TTSquares", sans-serif;
  font-size: 1.9rem;
  line-height: 1.2;
  text-shadow: 0 0 18px rgba(255,210,0,.35);
}

/* ==================== FEEDBACK PILL (scan/defect result) ==================== */
.cz-feedback {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .88rem;
  border: 1px solid transparent;
  animation: feedbackIn .22s var(--ease) both;
}
.cz-feedback.cz-feedback-info {
  background: rgba(255,210,0,.08);
  border-color: rgba(255,210,0,.25);
  color: var(--yellow);
}
.cz-feedback.cz-feedback-success {
  background: rgba(40,199,111,.1);
  border-color: rgba(40,199,111,.35);
  color: #6bf0ac;
}
.cz-feedback.cz-feedback-danger {
  background: rgba(255,77,79,.1);
  border-color: rgba(255,77,79,.35);
  color: #ff9294;
}
@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==================== EMPTY STATE ==================== */
.cz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: .85rem;
}
.cz-empty i { font-size: 1.6rem; color: var(--line2); }

/* ==================== TABLE ROW REVEAL ==================== */
.table tbody tr {
  animation: tableRowIn .3s var(--ease) both;
}
.table tbody tr:nth-child(n+1)  { animation-delay: 0ms; }
.table tbody tr:nth-child(n+2)  { animation-delay: 20ms; }
.table tbody tr:nth-child(n+3)  { animation-delay: 40ms; }
.table tbody tr:nth-child(n+4)  { animation-delay: 60ms; }
.table tbody tr:nth-child(n+5)  { animation-delay: 80ms; }
.table tbody tr:nth-child(n+6)  { animation-delay: 100ms; }
.table tbody tr:nth-child(n+7)  { animation-delay: 120ms; }
.table tbody tr:nth-child(n+8)  { animation-delay: 140ms; }
@keyframes tableRowIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .cz-nav .nav-link { padding: .4rem .5rem; font-size: .8rem; }
  .table tbody td, .table thead th { padding: 9px 10px; font-size: .82rem; }
  .card { border-radius: 10px; }
  .modal-content { border-radius: 12px; }
}
