:root {
  --purple: #312783;
  --pink: #E6007E;
  --dark: #121319;
  --yellow: #F9B233;
  --bg: #f4f5f8;
  --card: #fff;
  --line: #e6e8ef;
  --muted: #64748b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
}
@font-face {
  font-family: "Line Printer";
  src: url("/static/fonts/LinePrinter.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
a { color: var(--purple); }
img { max-width: 100%; height: auto; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #121319 0%, #312783 55%, #E6007E 140%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 24px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-hero {
  background: #fff;
  padding: 28px 32px 18px;
  display: flex;
  justify-content: center;
  border-bottom: 3px solid #E6007E;
}
.login-hero img {
  width: 100%;
  max-width: 280px;
  height: auto;
  display: block;
}
.login-body { padding: 22px 32px 32px; }
.login-card h1 { margin: 0 0 6px; font-size: 1.4rem; }
.login-card p { margin: 0 0 22px; color: var(--muted); font-size: .92rem; }
.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}
.side {
  background: var(--dark);
  color: #fff;
  padding: 0 16px 22px;
}
.brand-block {
  display: block;
  text-decoration: none;
  color: inherit;
  background: #fff;
  margin: 0 -16px 14px;
  padding: 18px 16px 16px;
  border-bottom: 3px solid #E6007E;
}
.brand-logo {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}
.brand-kicker { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #f9b233; font-weight: 800; }
.brand { font-weight: 800; font-size: 1.05rem; margin: 0 2px 14px; line-height: 1.3; color: #fff; }
.nav a {
  display: block;
  color: #d6d8e4;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 600;
}
.nav a:hover, .nav a.active { background: #312783; color: #fff; }
.main { padding: 28px; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}
h1.page { margin: 0; font-size: 1.6rem; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: .92rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}
.stat b { display: block; font-size: 1.7rem; margin-top: 6px; }
.stat span { color: var(--muted); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.dash-kpis {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.spend-hero {
  background: linear-gradient(135deg, #121319 0%, #312783 70%, #E6007E 140%);
  color: #fff;
  border: 0;
}
.spend-hero span { color: #f9b233; }
.spend-hero b { font-size: 1.85rem; letter-spacing: -0.02em; }
.spend-hero p { margin: 10px 0 0; color: rgba(255,255,255,.8); font-size: .88rem; font-weight: 600; }
.gauge-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.gauge-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 12px 18px;
  text-align: center;
}
.gauge { width: 132px; height: 132px; display: block; margin: 0 auto 8px; }
.gauge-track, .gauge-val {
  fill: none;
  stroke-width: 11;
}
.gauge-track { stroke: #eceef4; }
.gauge-val {
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
}
.gauge-num {
  font-size: 22px;
  font-weight: 800;
  text-anchor: middle;
  fill: #121319;
  font-family: Inter, system-ui, sans-serif;
}
.gauge-label { font-weight: 800; font-size: .95rem; }
.gauge-cap { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  font-size: .88rem;
}
.bar-row span { font-weight: 700; }
.bar-row b { text-align: right; font-size: .86rem; white-space: nowrap; }
.bar-row small { display: block; color: var(--muted); font-weight: 600; font-size: .72rem; }
.bar {
  height: 10px;
  background: #eceef4;
  border-radius: 999px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #312783, #E6007E);
  border-radius: 999px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  font-size: .9rem;
}
.btn-pink { background: var(--pink); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-ghost { background: #fff; color: var(--purple); border: 1px solid var(--line); }
.btn-danger { background: #b91c1c; color: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.flash {
  background: #ecfdf3;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-weight: 600;
}
.flash.err { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
th { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: .8rem; font-weight: 700; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d6d9e4;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}
textarea { min-height: 90px; }
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.s-in_store { background: #eef2ff; color: #312783; }
.s-in_use { background: #ecfdf3; color: #166534; }
.s-repair { background: #fffbeb; color: #92400e; }
.s-damaged { background: #fff7ed; color: #9a3412; }
.s-written_off { background: #f1f5f9; color: #475569; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters > * { flex: 1; min-width: 160px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.muted { color: var(--muted); }
.sticker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 36px;
  align-items: flex-start;
}
.sticker-frame {
  width: 38mm;
  height: 25mm;
}
.sticker {
  width: 38mm;
  height: 25mm;
  box-sizing: border-box;
  border: 2px solid var(--purple);
  border-radius: 3px;
  padding: 1.2mm 1.4mm 1mm;
  background: #fff;
  display: grid;
  grid-template-columns: 13.4mm 1fr;
  grid-template-rows: 13.4mm auto 1fr;
  column-gap: 2mm;
  row-gap: 0.3mm;
  align-items: start;
  overflow: hidden;
  page-break-inside: avoid;
  break-inside: avoid;
  color: #000;
  font-family: "Line Printer", monospace;
  font-weight: 400;
}
.sticker-qr {
  grid-column: 1;
  grid-row: 1;
  width: 13.4mm;
  height: 13.4mm;
  background: #fff;
}
.sticker-brand {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  height: 13.4mm;
  width: max-content;
  max-width: 100%;
  justify-self: end;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}
.sticker-brand img,
.sticker-mark {
  width: auto;
  height: 8mm;
  max-width: 100%;
  object-fit: contain;
  object-position: center top;
}
.sticker-asset {
  font-size: 7.2pt;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1;
  margin-top: 1.1mm;
  color: #000;
  text-align: center;
  width: auto;
  white-space: nowrap;
}
.sticker .item {
  grid-column: 1 / -1;
  grid-row: 2;
  font-size: 11pt;
  font-weight: 400;
  line-height: 1;
  color: #000;
  margin: 0.2mm 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sticker .code {
  grid-column: 1 / -1;
  grid-row: 3;
  align-self: end;
  font-size: 12pt;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  color: #000;
  white-space: nowrap;
  margin: 0;
}
.print-help ol { margin: 8px 0 12px; padding-left: 20px; }
.print-help li { margin: 4px 0; font-size: .9rem; }
.thumb { width: 100%; max-height: 280px; object-fit: cover; border-radius: 16px; border: 1px solid var(--line); }
.field-note { margin: 6px 0 0; font-size: .8rem; color: var(--muted); }
.field-limit {
  margin: 6px 0 0;
  font-size: .85rem;
  font-weight: 700;
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 8px 10px;
}
.warn { background: #fffbeb; border-color: #fde68a; }
.sign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; margin-top: 56px; }
.sign-line { border-top: 1px solid #121319; margin-top: 64px; padding-top: 8px; font-size: .85rem; font-weight: 700; }
.print-sheet { overflow: hidden; }
.print-sheet h1 { margin-bottom: 4px; }
.print-letterhead {
  background: #fff;
  padding: 8px 4px 16px;
  margin: -6px 0 18px;
  display: flex;
  align-items: center;
  border-bottom: 3px solid #E6007E;
}
.print-letterhead img {
  height: 78px;
  width: auto;
  max-width: 100%;
  display: block;
}
@media print {
  html, body { margin: 0; padding: 0; background: #fff; }
  .side, .no-print, .flash { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .sticker-grid { display: block; gap: 0; }
  .sticker-frame + .sticker-frame {
    page-break-before: always;
    break-before: page;
  }
  .sticker-frame, .sticker {
    width: 38mm;
    height: 25mm;
    border: 0;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
  }
  .sticker .code,
  .sticker .item,
  .sticker-asset { color: #000 !important; }
  .sticker, .sticker-brand img {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-sheet { border: 0; box-shadow: none; border-radius: 0; padding: 12px; }
  .print-letterhead {
    margin: 0 0 18px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
.tag-body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(160deg, #121319 0%, #312783 52%, #E6007E 140%);
  padding: 20px 14px 40px;
  font-family: Inter, system-ui, sans-serif;
}
.tag-wrap { max-width: 430px; margin: 0 auto; }
.tag-card {
  background: #fff;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.tag-brand {
  background: #fff;
  padding: 16px 18px 12px;
  text-align: center;
  border-bottom: 3px solid #E6007E;
}
.tag-brand img { height: 58px; width: auto; }
.tag-photo { width: 100%; height: 240px; object-fit: cover; display: block; background: #eceef4; }
.tag-photo-empty {
  height: 160px;
  display: grid;
  place-items: center;
  background: #f4f5f8;
}
.tag-photo-empty img { height: 78px; width: auto; }
.tag-inner { padding: 16px 18px 20px; }
.tag-code {
  font-weight: 800;
  letter-spacing: .03em;
  color: #312783;
  font-size: .92rem;
}
.tag-name { font-size: 1.5rem; font-weight: 800; margin: 4px 0 6px; line-height: 1.2; }
.tag-type { color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.tag-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: .95rem;
}
.tag-row span { color: var(--muted); font-weight: 600; }
.tag-row b { text-align: right; font-weight: 800; }
.tag-foot {
  text-align: center;
  color: rgba(255,255,255,.82);
  font-size: .8rem;
  margin: 16px 0 0;
  font-weight: 600;
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .grid, .form-grid, .dash-kpis, .gauge-grid, .report-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; }
}
