:root {
  --black: #0a0a0a;
  --ink: #1a1a1a;
  --muted: #767676;
  --line: #e7e7e7;
  --soft: #f5f5f3;
  --white: #fff;
  --red: #e23d32;
  --green: #19754a;
  --amber: #9a6200;
  --blue: #1e5ed6;
  --radius: 18px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--soft);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--soft); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1fr) minmax(440px, 0.8fr); background: var(--black); }
.auth-brand { padding: 72px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: radial-gradient(circle at 70% 20%, #343434 0, transparent 32%), linear-gradient(145deg, #050505, #1b1b1b); }
.auth-brand img { width: min(340px, 72%); filter: invert(1); object-fit: contain; object-position: left center; }
.auth-brand p { margin: 0; color: #a7a7a7; letter-spacing: .18em; }
.auth-card { align-self: center; width: min(480px, calc(100% - 48px)); margin: 24px auto; padding: 48px; border-radius: 28px; background: #fff; box-shadow: 0 32px 90px rgba(0,0,0,.26); }
.auth-card h1 { margin: 5px 0 8px; font-size: 31px; letter-spacing: -.04em; }
.muted { color: var(--muted); line-height: 1.7; margin: 0 0 28px; }
.eyebrow { margin: 0; color: #8b8b8b; font-size: 11px; font-weight: 800; letter-spacing: .18em; }
form { display: grid; gap: 18px; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 650; color: #383838; }
label small { color: #999; font-size: 10px; font-weight: 400; line-height: 1.5; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: 17px; height: 17px; accent-color: #111; }
input, select, textarea { width: 100%; border: 1px solid #d9d9d9; border-radius: 11px; padding: 12px 13px; color: var(--ink); background: #fff; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(0,0,0,.08); }
textarea { resize: vertical; }
.primary-button, .secondary-button { border: 0; border-radius: 11px; padding: 12px 18px; font-weight: 750; }
.primary-button { color: #fff; background: var(--black); }
.primary-button:hover { background: #282828; }
.secondary-button { color: var(--ink); background: #ededed; }
.auth-card .primary-button { margin-top: 4px; min-height: 48px; }
.form-message { min-height: 20px; margin: 15px 0 0; color: var(--red); font-size: 13px; }

.app-shell { display: grid; grid-template-columns: 246px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px 20px; display: flex; flex-direction: column; color: #fff; background: var(--black); z-index: 10; }
.sidebar-brand { padding: 7px 10px 32px; display: grid; gap: 10px; border-bottom: 1px solid #292929; }
.sidebar-brand img { width: 132px; height: 28px; object-fit: contain; object-position: left center; filter: invert(1); }
.sidebar-brand span { color: #797979; font-size: 11px; letter-spacing: .16em; }
nav { display: grid; gap: 7px; padding: 24px 0; }
.nav-item { position: relative; width: 100%; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 5px; padding: 12px 14px; color: #999; text-align: left; border: 0; border-radius: 11px; background: transparent; }
.nav-item span { font-size: 18px; text-align: center; }
.nav-item:hover { color: #fff; background: #181818; }
.nav-item.is-active { color: #111; background: #fff; }
.nav-item b { min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; color: #fff; border-radius: 10px; background: var(--red); font-size: 10px; }
.sidebar-user { margin-top: auto; padding: 15px 8px 0; display: grid; grid-template-columns: 38px 1fr 28px; align-items: center; gap: 9px; border-top: 1px solid #292929; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; color: #111; border-radius: 8px; background: #fff; font-weight: 900; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { margin-top: 3px; color: #6f6f6f; font-size: 10px; }
.sidebar-user button { color: #777; border: 0; background: transparent; font-size: 18px; }
.sidebar-user button:hover { color: #fff; }

.main-panel { min-width: 0; }
.topbar { height: 106px; padding: 28px 38px 20px; display: flex; align-items: center; gap: 18px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 3px 0 0; font-size: 24px; letter-spacing: -.04em; }
.environment { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 9px 12px; color: #555; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; }
.environment i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px #fff0d1; }
.environment.is-live i { background: var(--green); box-shadow: 0 0 0 4px #d8f3e5; }
.menu-button { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.demo-notice { margin: 22px 38px 0; padding: 11px 15px; color: #775000; border: 1px solid #f0d79d; border-radius: 11px; background: #fff7e5; font-size: 12px; }
.content { padding: 28px 38px 60px; }
.view-head { margin-bottom: 22px; display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.view-head h2 { margin: 0; font-size: 21px; }
.view-head p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.view-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.small-button { padding: 9px 13px; color: #222; border: 1px solid #d8d8d8; border-radius: 9px; background: #fff; font-size: 12px; font-weight: 700; }
.small-button:hover { border-color: #111; }
.small-button.is-dark { color: #fff; border-color: #111; background: #111; }
.small-button.is-danger { color: var(--red); border-color: #efb9b5; }

.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 15px; margin-bottom: 28px; }
.stat-card { min-height: 137px; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.stat-card.is-black { color: #fff; border-color: #111; background: #111; }
.stat-label { color: #777; font-size: 12px; }
.is-black .stat-label { color: #999; }
.stat-value { font-size: 29px; font-weight: 850; letter-spacing: -.05em; }
.stat-foot { color: #aaa; font-size: 11px; }
.panel { margin-bottom: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.panel-head { padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 14px; color: #848484; text-align: left; white-space: nowrap; background: #fafafa; font-weight: 650; }
td { padding: 14px; vertical-align: middle; border-top: 1px solid #eeeeee; }
tbody tr:hover { background: #fcfcfc; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.strong { font-weight: 750; }
.subline { display: block; margin-top: 4px; color: #929292; font-size: 10px; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 99px; background: #eee; white-space: nowrap; font-size: 10px; font-weight: 700; }
.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.tag.green { color: var(--green); background: #e5f5ec; }
.tag.amber { color: var(--amber); background: #fff1d4; }
.tag.red { color: #b42920; background: #fde8e6; }
.tag.blue { color: var(--blue); background: #e8efff; }
.tag.gray { color: #666; background: #eee; }
.empty { padding: 70px 24px; color: #999; text-align: center; }
.empty strong { display: block; margin-bottom: 7px; color: #444; font-size: 16px; }
.filters { margin-bottom: 18px; display: grid; grid-template-columns: minmax(220px, 1fr) 170px 170px auto; gap: 10px; }
.filters input, .filters select { padding: 10px 12px; font-size: 12px; }
.code-mark { display: inline-block; padding: 6px 9px; border: 1px solid #bbb; border-radius: 7px; font-family: "SFMono-Regular", Consolas, monospace; font-weight: 800; letter-spacing: .06em; }
.product-list { display: grid; gap: 3px; max-width: 300px; }
.product-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-number { font-size: 20px; font-weight: 850; letter-spacing: -.04em; }
.stock-number.is-low { color: var(--red); }
.product-thumb { width: 52px; height: 52px; object-fit: contain; border: 1px solid #eee; border-radius: 8px; background: #fff; }
.product-cell { min-width: 260px; display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 11px; }
.product-placeholder { width: 52px; height: 52px; display: grid; place-items: center; color: #aaa; border: 1px solid #eee; border-radius: 8px; background: #f5f5f5; font-size: 18px; }
.movement-positive { color: var(--green); font-weight: 800; }
.movement-negative { color: var(--red); font-weight: 800; }
.media-editor { padding: 15px; display: grid; gap: 13px; border: 1px solid #dedede; border-radius: 13px; background: #fafafa; }
.media-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.media-editor-head strong, .media-editor-head small { display: block; }
.media-editor-head strong { font-size: 13px; }
.media-editor-head small { margin-top: 4px; color: #999; font-size: 10px; line-height: 1.4; }
.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.media-item { position: relative; min-width: 0; overflow: hidden; border: 1px solid #ddd; border-radius: 9px; background: #fff; }
.media-item img { width: 100%; aspect-ratio: 1; display: block; object-fit: contain; background: #fff; }
.detail-media-grid .media-item img { aspect-ratio: 3 / 4; object-fit: cover; object-position: top; }
.media-index { position: absolute; top: 5px; left: 5px; min-width: 22px; height: 22px; display: grid; place-items: center; color: #fff; border-radius: 99px; background: rgba(0,0,0,.72); font-size: 9px; }
.media-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid #eee; }
.media-actions button { height: 29px; padding: 0; border: 0; border-right: 1px solid #eee; background: #fff; font-size: 11px; }
.media-actions button:last-child { color: var(--red); border-right: 0; }
.media-actions button:disabled { color: #ccc; cursor: default; }
.upload-progress { padding: 24px 10px; color: #888; text-align: center; border: 1px dashed #ccc; border-radius: 9px; font-size: 11px; }

dialog { width: min(540px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 20px; background: #fff; box-shadow: 0 30px 90px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
.dialog-card { padding: 27px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; margin-bottom: 3px; }
.dialog-head h2 { margin: 4px 0 0; font-size: 23px; }
.close-button { width: 35px; height: 35px; display: grid; place-items: center; border: 0; border-radius: 50%; background: #eee; font-size: 22px; }
.order-summary { margin: 7px 0 3px; padding: 14px; color: #555; border-radius: 11px; background: var(--soft); font-size: 12px; line-height: 1.7; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { margin-top: 5px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 360px; padding: 13px 17px; color: #fff; border-radius: 11px; background: #111; box-shadow: 0 10px 35px rgba(0,0,0,.25); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; z-index: 50; font-size: 13px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: #b72c24; }
.loading { padding: 80px 20px; color: #888; text-align: center; }

@media (max-width: 1050px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .auth-screen { grid-template-columns: 1fr; background: #111; }
  .auth-brand { min-height: 170px; padding: 38px 28px 25px; }
  .auth-brand img { width: 190px; }
  .auth-card { margin-top: -34px; padding: 30px 24px; z-index: 2; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; width: 246px; transform: translateX(-105%); transition: transform .2s; box-shadow: 20px 0 50px rgba(0,0,0,.25); }
  .sidebar.is-open { transform: translateX(0); }
  .menu-button { display: block; }
  .topbar { height: 90px; padding: 20px 18px; }
  .demo-notice { margin: 14px 16px 0; }
  .content { padding: 22px 16px 45px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 120px; padding: 16px; }
  .stat-value { font-size: 24px; }
  .filters { grid-template-columns: 1fr; }
  .view-head { align-items: start; flex-direction: column; }
  .environment { padding: 7px 9px; }
  .environment { font-size: 0; }
  .environment::after { content: "DEV"; font-size: 10px; }
}

@media (max-width: 430px) {
  .stat-grid { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
