:root {
  --page: #eaf2fb;
  --panel: #ffffff;
  --border: #dce6f2;
  --text: #1c1e21;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-light: #eff4ff;
  --ok: #157a3d;
  --ok-bg: #e3f6e6;
  --warn: #92600a;
  --warn-bg: #fdf1d9;
  --err: #b1332b;
  --err-bg: #fbe4e2;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--page); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 14px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 8px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
code { background: var(--accent-light); padding: 1px 5px; border-radius: 4px; }
pre { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 8px; overflow-x: auto; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 12px 28px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo { height: 34px; width: auto; }
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12.5px; }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.main-nav a { padding: 7px 11px; border-radius: 8px; color: var(--text); font-weight: 500; }
.main-nav a:hover { background: var(--accent-light); text-decoration: none; }
.main-nav a.active { background: var(--accent-light); color: var(--accent); }
.main-nav a.logout { color: var(--muted); margin-left: 8px; }
.pill { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; text-align: center; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 24px 28px 40px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 30px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px; margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.order-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.ok { color: var(--ok); }
.err { color: var(--err); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.kpi-val { font-size: 24px; font-weight: 700; }
.kpi-lbl { color: var(--muted); font-size: 12.5px; }
.kpi-warn { border-color: #f3c9c5; background: #fff8f7; }
.kpi-warn .kpi-val { color: var(--err); }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid #eef3f9; vertical-align: top; }
.tbl tfoot td { border-bottom: 0; padding: 5px 8px; }
.tbl tfoot tr.total td { font-weight: 700; border-top: 1px solid var(--border); padding-top: 9px; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #f6f9fe; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef0f2; color: #5b6472; }
.st-open, .st-pending { background: var(--accent-light); color: var(--accent); }
.st-in_progress { background: var(--warn-bg); color: var(--warn); }
.st-shipped, .st-completed { background: var(--ok-bg); color: var(--ok); }
.st-cancelled, .st-failed, .st-returned { background: var(--err-bg); color: var(--err); }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #c4ead0; }
.flash-error { background: var(--err-bg); color: var(--err); border-color: #f3c9c5; }
.flash-warning { background: var(--warn-bg); color: var(--warn); border-color: #f2dcae; }

label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 10px; }
input, select { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #cdd8e6; border-radius: 7px; font: inherit; font-weight: 400; background: #fff; color: var(--text); }
input:focus, select:focus { outline: 2px solid #bfd3fb; border-color: var(--accent); }
input[type=checkbox] { display: inline; width: auto; margin: 0 5px 0 0; }
input[readonly] { background: #f8fafc; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 90px 1fr 140px; gap: 10px; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 7px; border: 1px solid #cdd8e6; background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f4f7fb; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--err); border-color: #f0c3bf; }
.btn-small { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; padding: 10px; margin-top: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; }
.btn-link:hover { color: var(--err); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }

.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search input[type=search] { width: 300px; margin: 0; }
.search select, .search input[type=date] { width: auto; margin: 0; }
.search .check { display: flex; align-items: center; margin: 0; font-weight: 500; white-space: nowrap; }
.filters { margin-bottom: 14px; }
.inline-add { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.inline-add input { margin: 0; }
.inline-add input[type=file] { width: auto; }
input.qty { width: 74px; margin: 0; }
.notes input { margin-top: 5px; padding: 4px 7px; font-size: 12px; border-color: #e3e9f2; }
.keybox { margin-top: 8px; font-size: 14px !important; }

.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.product { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.pimg { height: 150px; padding: 10px; background: #fff; border-bottom: 1px solid #eef3f9; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pimg img { width: 100%; height: 100%; object-fit: contain; display: block; }
.noimg { color: var(--muted); font-size: 12px; }
.pbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.pbody h3 { margin: 0; font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.pman { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmeta { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pprice { font-weight: 700; font-size: 15px; margin-top: 3px; }
.puvp { color: var(--muted); font-size: 11.5px; }
.pstock { font-size: 12px; font-weight: 600; }
.pstock.ok { color: var(--ok); }
.pstock.no { color: var(--muted); }
.padd { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.padd input { width: 58px; margin: 0; padding: 6px 7px; }
.padd .btn { flex: 1; padding: 6px 8px; font-size: 12.5px; }

.catalog-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.cat-tree { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; padding: 14px 12px; margin-bottom: 0; }
.cat-tree h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px 6px; }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list .cat-list { padding-left: 12px; border-left: 1px solid #e6edf6; margin-left: 9px; }
.cat-tree a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--text); font-size: 13px; line-height: 1.3; }
.cat-tree a:hover { background: var(--accent-light); text-decoration: none; }
.cat-tree a.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.cat-tree a.leaf { padding-left: 22px; }
.cat-tree .cat-all { font-weight: 600; margin-bottom: 4px; }
.cat-tree details > summary { list-style: none; display: flex; align-items: center; cursor: pointer; }
.cat-tree details > summary::-webkit-details-marker { display: none; }
.cat-tree details > summary::before { content: "▸"; width: 14px; flex: 0 0 14px; color: var(--muted); font-size: 11px; text-align: center; transition: transform .15s; }
.cat-tree details[open] > summary::before { transform: rotate(90deg); }
.cat-tree details > summary > a { flex: 1; }
.pager { display: flex; gap: 6px; align-items: center; margin: 18px 0; flex-wrap: wrap; }
.pager a { padding: 5px 10px; border-radius: 6px; background: #fff; border: 1px solid var(--border); }
.pager a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
address { font-style: normal; line-height: 1.6; }
.tracking { font-weight: 600; margin-top: 6px; }
.steps { padding-left: 20px; margin: 0 0 12px; }
.steps li { margin-bottom: 8px; }
.checks { list-style: none; padding: 0; margin: 0 0 16px; }
.checks li { padding-left: 26px; position: relative; margin-bottom: 10px; }
.checks li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }

.login-grid { display: grid; grid-template-columns: 400px 1fr; gap: 40px; max-width: 980px; margin: 30px auto; align-items: start; }
.login-card.single { max-width: 420px; margin: 40px auto; }
.login-info { padding-top: 10px; }
.login-info h2 { font-size: 20px; margin-bottom: 16px; }
.doc table { margin-bottom: 10px; }

@media (max-width: 900px) {
  .grid-2, .grid-3, .order-grid, .login-grid, .catalog-layout { grid-template-columns: 1fr; }
  .cat-tree { position: static; max-height: 300px; }
  header.top { padding: 10px 14px; }
  .wrap { padding: 16px 14px 30px; }
  .search input[type=search] { width: 100%; }
  .tbl { display: block; overflow-x: auto; }
}
