/* AJ ABRASIVES Inventory — no build step required. Brand: navy #071D49, orange #F47B20. */
:root {
  --navy: #071D49; --navy-2: #0E2A63; --navy-soft: #E7EBF3; --orange: #F47B20; --orange-dark: #D9650F; --orange-soft: #FEF0E5;
  --ink: #1A2233; --muted: #5D6B82; --line: #D9DFE9; --bg: #F4F6FA; --card: #FFFFFF;
  --ok: #157F4A; --ok-soft: #E4F5EC; --warn: #A15C00; --warn-soft: #FFF4DC; --bad: #B42318; --bad-soft: #FDECEA; --info-soft: #E8F0FE;
  --radius: 10px; --shadow: 0 1px 2px rgba(7,29,73,.06), 0 2px 8px rgba(7,29,73,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--navy-2); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; color: var(--navy); }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; color: var(--navy); }
h3 { font-size: .98rem; margin: 0 0 .5rem; color: var(--navy); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; } .mt-s { margin-top: .5rem; } .hidden { display: none !important; }

/* Shell */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; height: 56px; padding: 0 1rem; background: var(--navy); color: #fff; border-bottom: 3px solid var(--orange); }
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--orange); display: grid; place-items: center; font-weight: 800; color: var(--navy); font-size: .8rem; }
.brand small { display: block; font-weight: 400; font-size: .72rem; opacity: .8; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: .85rem; text-align: right; line-height: 1.2; }
.topbar .user small { opacity: .75; display: block; }
.menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; padding: .25rem .4rem; cursor: pointer; }
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 56px); }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: .75rem 0 2rem; }
.sidebar .group { padding: .7rem 1rem .25rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.sidebar a { display: flex; justify-content: space-between; align-items: center; padding: .45rem 1rem; color: var(--ink); text-decoration: none; border-left: 3px solid transparent; }
.sidebar a:hover { background: var(--navy-soft); }
.sidebar a.active { background: var(--orange-soft); border-left-color: var(--orange); color: var(--navy); font-weight: 600; }
.sidebar .count { background: var(--orange); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .45rem; font-weight: 700; }
.content { padding: 1.25rem 1.5rem 3rem; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .75rem; margin-bottom: 1rem; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.demo-banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid #F3D9A4; padding: .4rem 1rem; font-size: .82rem; }
.demo-banner a { color: var(--warn); font-weight: 600; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.stat .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--navy); line-height: 1.2; }
.stat.alert-stat .value { color: var(--orange-dark); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; font-weight: 500; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1.1rem; padding: 0 1.1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #FAFBFD; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: #FAFBFE; }
tr.total td { font-weight: 700; background: var(--navy-soft); }
td .sub { display: block; font-size: .8rem; color: var(--muted); }
.qty-zero { color: #A3ADBF; }
.qty-low { color: var(--bad); font-weight: 700; }
.col-loc { background: rgba(7,29,73,.02); }

/* Badges */
.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--navy-soft); color: var(--navy); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.orange { background: var(--orange-soft); color: var(--orange-dark); }
.badge.demo { background: #FFF4DC; color: #8A4B00; border: 1px dashed #E2A23B; }

/* Forms */
form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem 1rem; }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field.span-2 { grid-column: span 2; } .field.full { grid-column: 1 / -1; }
label, .label { font-size: .8rem; font-weight: 600; color: #3B4860; }
.hint { font-size: .78rem; color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid #C5CDDB; border-radius: 7px; background: #fff; font: inherit; color: inherit; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(244,123,32,.35); border-color: var(--orange); }
textarea { min-height: 70px; resize: vertical; }
select[multiple] { min-height: 90px; }
input.qty { width: 90px; text-align: right; }
.check { display: flex; align-items: center; gap: .4rem; font-weight: 500; font-size: .9rem; }
.check input { width: 17px; height: 17px; }
.error-text { color: var(--bad); font-size: .8rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.filters .field { min-width: 140px; flex: 1 1 140px; max-width: 240px; }
.filters .field.wide { max-width: 340px; flex-basis: 240px; }
.lines td { vertical-align: middle; }
.lines input, .lines select { min-width: 80px; }
.lines input[type=checkbox] { min-width: 0; }
[data-serials] { min-width: 170px; }
[data-serials] .check { white-space: nowrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .9rem; border-radius: 7px; border: 1px solid var(--navy); background: #fff; color: var(--navy);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 38px; white-space: nowrap; }
.btn:hover { background: var(--navy-soft); }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn-navy { background: var(--navy); color: #fff; } .btn-navy:hover { background: var(--navy-2); }
.btn-danger { border-color: var(--bad); color: var(--bad); } .btn-danger:hover { background: var(--bad-soft); }
.btn-sm { padding: .2rem .55rem; min-height: 30px; font-size: .82rem; }
.btn-link { border: 0; background: none; padding: 0; min-height: 0; color: var(--navy-2); text-decoration: underline; font-weight: 500; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Alerts */
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert.success { background: var(--ok-soft); color: var(--ok); border-color: #B5E2C8; }
.alert.error { background: var(--bad-soft); color: var(--bad); border-color: #F5C2BC; }
.alert.info { background: var(--info-soft); color: var(--navy); border-color: #C6D6F5; }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: #F3D9A4; }
.alert ul { margin: .25rem 0 0 1.1rem; padding: 0; }

/* Workflow steps */
.steps { display: flex; gap: 0; margin: .25rem 0 1rem; flex-wrap: wrap; }
.steps .step { flex: 1 1 120px; padding: .45rem .6rem; background: #fff; border: 1px solid var(--line); font-size: .8rem; color: var(--muted); position: relative; }
.steps .step:first-child { border-radius: 8px 0 0 8px; } .steps .step:last-child { border-radius: 0 8px 8px 0; }
.steps .step.done { background: var(--navy); color: #fff; border-color: var(--navy); }
.steps .step.current { background: var(--orange); color: #fff; border-color: var(--orange); font-weight: 700; }

.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 .9rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--orange); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--orange); }

/* Pagination */
.pagination { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .75rem; align-items: center; }
.pagination a, .pagination span { padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: #fff; font-size: .85rem; }
.pagination .current { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, var(--orange) 160%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 1.75rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); border-top: 5px solid var(--orange); }
.auth-card .brand { color: var(--navy); margin-bottom: 1.2rem; }
.auth-card .brand small { color: var(--muted); }
.auth-card .field { margin-bottom: .8rem; }

/* Responsive */
@media (max-width: 980px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .menu-toggle { display: block; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 56px; left: 0; bottom: 0; width: 260px; z-index: 25; transform: translateX(-100%); transition: transform .2s; overflow-y: auto; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 1rem .9rem 3rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .topbar .user, .brand small { display: none; }
  .brand { white-space: nowrap; }
  .filters .field { max-width: none; }
  h1 { font-size: 1.25rem; }
}
@media print {
  .topbar, .sidebar, .no-print, .demo-banner { display: none !important; }
  .shell { display: block; } .content { padding: 0; } .card { box-shadow: none; }
}
