/* AdvantEdge Inventory — design system borrowed from Haria CRM (Bootstrap 5 + these tokens). */

:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --surface: #ffffff;
  --canvas: #f6f7f9;
  --bs-body-font-family: "PT Sans Narrow", "Arial Narrow", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --brand: #0b7a75;        /* deep logo teal: white text on it passes contrast */
  --brand-soft: #096561;
  --brand-gradient: linear-gradient(180deg, #12a19a 0%, #0b7a75 18%, #07534f 100%);  /* logo teal #12a19a at the top */
  --accent: #0b7a75;
  --accent-soft: #e6f4f1;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 10px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--bs-body-font-family);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip { position: absolute; top: .5rem; left: .5rem; z-index: 1080; }

/* ---------------------------------------------------------------- layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--brand-gradient);
  color: rgba(255,255,255,.88);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-offcanvas .sidebar { height: 100%; position: static; width: 100%; }
@media (max-width: 991.98px) { .shell > .sidebar { display: none; } }

.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 6px 8px 20px; }
.brand small { color: rgba(255,255,255,.8); font-size: 12px; letter-spacing: .04em; }

.nav-group { margin-bottom: 14px; }
.nav-label {
  font-size: 10px; letter-spacing: .11em; text-transform: uppercase;
  color: rgba(255,255,255,.7); padding: 6px 10px;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px; color: rgba(255,255,255,.9); font-weight: 500;
  cursor: pointer; user-select: none;
}
.sidebar .nav-item:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.sidebar .nav-item.active { background: rgba(255,255,255,.18); color: #fff; }
.sidebar .nav-item.sub {
  /* Indent rail, aligned under the parent's icon. */
  margin-left: 18px; padding-left: 18px; border-left: 1px solid rgba(255, 255, 255, .12);
  border-radius: 0 8px 8px 0; font-weight: 400; font-size: 13px; color: rgba(255,255,255,.8);
}
.sidebar .nav-item.sub:hover { color: #fff; }
.sidebar .nav-item.sub.active { color: #fff; border-left-color: #fff; }

.nav-ico, .nav-caret {
  flex: none; width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: .8;
}
.nav-item.active .nav-ico { opacity: 1; }

/* Collapsible group — plain <details>, no JavaScript. */
.nav-collapse > summary { list-style: none; }
.nav-collapse > summary::-webkit-details-marker { display: none; }
.nav-collapse > summary:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.nav-caret { width: 14px; height: 14px; margin-left: auto; opacity: .55; transition: transform .16s ease; }
.nav-collapse[open] > summary .nav-caret { transform: rotate(90deg); }

.nav-count { margin-left: auto; font-size: 11px; color: rgba(255,255,255,.75); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.crumbs { font-size: 13px; color: var(--ink-faint); flex: 1; min-width: 0; }
.crumbs a { color: var(--ink-soft); }
.crumbs .sep { padding: 0 6px; color: var(--line); }
.topsearch { width: min(360px, 40vw); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; border: 0;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 600;
}

.page { padding: 22px; max-width: 1500px; width: 100%; }

/* ------------------------------------------------------------- typography */

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-faint); font-weight: 600; margin: 0 0 10px;
}

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ------------------------------------------------------------------ cards */

.card-crm {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 16px;
}
.card-crm > header {
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px;
}
.card-crm > header h2 { font-size: 13px; font-weight: 650; margin: 0; }
.card-crm > header .spacer { margin-left: auto; }
.card-body-crm { padding: 14px 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); font-weight: 600; }
.stat .value { font-size: 23px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.stat.accent { border-left: 3px solid var(--accent); }
.stat.warn { border-left: 3px solid var(--warn); }

/* ----------------------------------------------------------------- tables */

.table-crm { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-crm th {
  text-align: left; font-weight: 600; font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfcfd;
}
.table-crm tr.total td { font-weight: 700; border-top: 2px solid var(--brand); }
.table-crm td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table-crm tbody tr:hover { background: #fafbfc; }
.table-crm tbody tr:last-child td { border-bottom: 0; }
.table-crm .r { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.sort-link { color: inherit; }
.sort-link:hover { color: var(--brand-soft); }

.name-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.chip {
  width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 650;
}
.name-cell .meta { color: var(--ink-faint); font-size: 11.5px; }

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.badge-ok { background: var(--accent-soft); color: #08604e; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--line-soft); color: var(--ink-soft); }
.badge-risk-low { background: #e0f2fe; color: #075985; }
.badge-risk-mid { background: #ede9fe; color: #5b21b6; }
.badge-risk-high { background: #ffe4e6; color: #9f1239; }
.badge-info { background: #e0e7ff; color: #3730a3; }
.badge-type-minor { background: #fef3c7; color: #92400e; }
.badge-type-huf { background: #ede9fe; color: #5b21b6; }
.badge-type-company { background: #dbeafe; color: #1e40af; }
.badge-type-llp { background: #ccfbf1; color: #115e59; }

/* ------------------------------------------------------------------ misc */

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filters .form-control, .filters .form-select { min-width: 140px; }

.empty { text-align: center; padding: 44px 16px; color: var(--ink-soft); }
.empty .icon { font-size: 26px; opacity: .35; }
.empty h3 { font-size: 15px; font-weight: 600; margin: 8px 0 4px; color: var(--ink); }

.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--ink-faint); font-weight: 500; }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }

.bar { height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.form-section { border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 14px; }
.form-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.form-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 3px; }
.form-control, .form-select { font-size: 13px; }
.form-text { font-size: 11.5px; }

/* Help text folded into the label as a hoverable "i" — native title tooltip,
   no JS. tabindex + aria-label so it is reachable without a mouse. */
.hint-i {
  display: inline-grid; place-items: center; width: 14px; height: 14px;
  margin-left: 4px; border-radius: 50%; border: 1px solid var(--line);
  font-size: 9.5px; font-weight: 700; font-style: italic; line-height: 1;
  color: var(--ink-faint); background: var(--surface); cursor: help;
  vertical-align: text-top;
}
.hint-i:hover, .hint-i:focus-visible { border-color: var(--brand); color: var(--brand); }

.btn { font-size: 13px; }
.btn-brand { background: var(--brand); color: #fff; border: 1px solid var(--brand); }
.btn-brand:hover { background: var(--brand-soft); color: #fff; }

.row-error { background: #fff7f7 !important; }
.row-warn { background: #fffdf5 !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #12a19a 0%, #0b7a75 45%, #07534f 100%); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 30px; }

@media print {
  .sidebar, .topbar, .actions { display: none !important; }
  .page { padding: 0; }
}

/* Django's built-in auth forms render bare inputs — style them without touching the views. */
form input:not([class]), form select:not([class]), form textarea:not([class]) {
  display: block; width: 100%; padding: .375rem .75rem; font-size: 13px;
  border: 1px solid #ced4da; border-radius: 6px; background: #fff;
}

/* ------------------------------------------------------------------ brand */

.brand-logo { width: 100%; max-width: 180px; height: auto; display: block; }
.login-logo { width: 100%; max-width: 240px; height: auto; display: block; }

/* -------------------------------------------------------------- inventory */

.page-head .back { display: inline-block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 4px; }
.sku-title { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.02em; }

.stat-grid.compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat.danger { border-left: 3px solid var(--danger); }
.stat.info { border-left: 3px solid #4f46e5; }

.row-title { font-weight: 600; color: var(--ink); }
.min-w-0 { min-width: 0; }
.pills { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* Movement log and repair timeline: one event per line, newest first. */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--accent); }
.timeline .dot.out { background: var(--warn); }
.timeline .dot.in { background: var(--accent); }
.timeline .dot.adj { background: var(--ink-faint); }
.timeline .when { color: var(--ink-faint); font-size: 11.5px; }
.timeline .qty { font-weight: 650; font-variant-numeric: tabular-nums; }

.stock-row { background: var(--line-soft); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }

.check-grid { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check-grid > div { display: flex; align-items: center; gap: 6px; }
.check-grid label { font-size: 13px; font-weight: 500; color: var(--ink); margin: 0; }

trix-editor { min-height: 7rem; background: #fff; border: 1px solid #dee2e6 !important; border-radius: 6px; font-size: 13px; }
trix-toolbar .trix-button-group { margin-bottom: 6px; }
.rich { font-size: 13px; }
.rich > :last-child { margin-bottom: 0; }

.danger-zone { border-color: var(--danger-soft); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-soft); }
.btn-danger-soft:hover { background: var(--danger); color: #fff; }

.alert-danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.alert-success { background: var(--accent-soft); border-color: #b7e2d8; color: #08604e; }

/* "+ New" / "+ Add" shortcuts that sit on a field's label line (item form, admins only) */
.quick-add { float: right; padding: 0 2px; line-height: 1.5; text-decoration: none; }

/* ------------------------------------------------------------ phone floor
   Warehouse staff work from phones: Haria's desk density stays on wide
   screens, but below the lg breakpoint controls grow to a 44px tap target
   and inputs to 16px so iOS doesn't zoom on focus. */
@media (max-width: 991.98px) {
  .page { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .btn, .form-control, .form-select { min-height: 44px; font-size: 16px; }
  .btn.quick-add { min-height: 0; padding: 6px 8px; margin: -6px -8px 0 0; font-size: 15px; }
  .btn { display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { min-height: 40px; }
  .form-check-input { width: 1.25em; height: 1.25em; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .table-crm td, .table-crm th { padding: 11px 12px; }
  .topsearch { width: auto; flex: 1; }
  .stat-grid.compact { grid-template-columns: 1fr 1fr; }
}

/* ------------------------------------------------------------- page guide */

.guide { --bs-offcanvas-width: 340px; font-size: 14px; border-left: 3px solid var(--accent) !important; }
.guide-title { font-size: 16px; font-weight: 600; color: var(--brand); margin: 0; }
.guide-lead { color: var(--ink-soft); margin-bottom: 12px; }
.guide ol, .guide ul { padding-left: 18px; margin-bottom: 14px; }
.guide li { margin-bottom: 6px; }
.guide-sub { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin: 4px 0 6px; }
.btn-guide { color: var(--accent); border: 1px solid var(--accent); background: var(--surface); font-weight: 500; }
.btn-guide:hover, .btn-guide:focus-visible { background: var(--accent); color: #fff; }

/* ------------------------------------------------------------- photos */
.photo-preview { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; margin-bottom: 4px; }
.photo-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.photo-card { margin: 0; overflow: hidden; }
.photo-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--line-soft); }
.upload-list { list-style: none; padding: 0; margin: 12px 0 0; }
.upload-list li { display: flex; align-items: center; gap: 10px; padding: 4px 0; flex-wrap: wrap; }
.upload-list .name { flex: 1 1 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list progress { width: 120px; }

.item-grid { display: grid; gap: 12px; padding: 14px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.item-tile { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); color: var(--ink); text-decoration: none; }
.item-tile:hover { border-color: var(--brand); text-decoration: none; }
.item-tile img, .item-tile-empty { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--line-soft); }
.item-tile-empty { display: grid; place-items: center; font-weight: 700; color: var(--ink-faint); font-size: 22px; }
.item-tile-body { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 12px; min-width: 0; }
.item-tile .meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 8px; }
.thumb-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 10px; }
.thumb-strip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
@media (max-width: 575.98px) { .item-grid { grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; } }
