:root {
  color-scheme: light;
  --bg: #eef5ff;
  --bg-2: #ffffff;
  --text: #0c1726;
  --muted: #5d6b7c;
  --line: rgba(22, 44, 72, .12);
  --glass: rgba(255, 255, 255, .68);
  --glass-strong: rgba(255, 255, 255, .86);
  --primary: #0b74de;
  --primary-2: #043b79;
  --danger: #d92828;
  --success: #18a957;
  --brown: #8a5a2b;
  --purple: #7d3fd1;
  --dark: #161b22;
  --shadow: 0 24px 70px rgba(15, 47, 94, .18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f;
  --bg-2: #0f1b2b;
  --text: #f5f8ff;
  --muted: #a8b6c8;
  --line: rgba(222, 236, 255, .14);
  --glass: rgba(13, 25, 41, .72);
  --glass-strong: rgba(17, 31, 51, .9);
  --shadow: 0 24px 70px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(11, 116, 222, .25), transparent 36rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.page { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 22px 0 44px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 900; letter-spacing: .2px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px; color: white; background: linear-gradient(135deg, #0b74de, #031d3d); box-shadow: var(--shadow); }
.brand-mark i { font-size: 1.1rem; }
.nav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.nav a, .nav button, .btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--glass);
  border-radius: 8px;
  padding: 10px 13px;
  cursor: pointer;
  backdrop-filter: blur(18px);
}
.nav a, .nav button { display: inline-flex; align-items: center; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; }
.btn.primary { color: white; background: var(--primary); border-color: transparent; }
.btn.danger { color: white; background: var(--danger); border-color: transparent; }
.btn.success { color: white; background: var(--success); border-color: transparent; }
.btn.full { width: 100%; }
.card, .panel {
  border: 1px solid var(--line);
  background: var(--glass);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}
.panel { padding: 22px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.actions { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; align-items: stretch; margin-bottom: 18px; }
.weight-display { display: grid; place-items: center; min-height: 170px; text-align: center; }
.weight-display strong { font-size: clamp(2.4rem, 8vw, 5.6rem); line-height: 1; color: var(--primary); }
.weight-display span { color: var(--muted); font-weight: 800; text-transform: uppercase; font-size: .82rem; display: inline-flex; gap: 8px; align-items: center; }
.big-action {
  min-height: 132px;
  padding: 18px;
  color: white;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: clamp(1.15rem, 3vw, 1.7rem);
  font-weight: 900;
  border: 0;
}
.big-action span { display: inline-flex; gap: 10px; align-items: center; }
.big-action small { font-size: .86rem; opacity: .88; font-weight: 700; }
.blue { background: linear-gradient(135deg, #0b74de, #064682); }
.red { background: linear-gradient(135deg, #dc2626, #861515); }
.green { background: linear-gradient(135deg, #16a34a, #0f6530); }
.brown { background: linear-gradient(135deg, #8a5a2b, #4f3016); }
.purple { background: linear-gradient(135deg, #7d3fd1, #3c1974); }
.gray { background: linear-gradient(135deg, #2d3748, #111827); }
h1, h2, h3 { margin: 0 0 14px; line-height: 1.12; }
p { color: var(--muted); line-height: 1.55; }
.muted { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { font-size: .86rem; font-weight: 800; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--text);
  background: var(--glass-strong);
  outline: none;
}
.field textarea { min-height: 92px; resize: vertical; }
.field small.field-help { color: var(--muted); line-height: 1.45; }
.api-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.api-key-row input[readonly] {
  background: rgba(148, 163, 184, .14);
  color: var(--text);
}
.span-2 { grid-column: span 2; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--glass); }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: .78rem; font-weight: 900; background: rgba(11, 116, 222, .12); color: var(--primary); }
.badge.warn { color: #ad6200; background: rgba(245, 158, 11, .14); }
.badge.ok { color: var(--success); background: rgba(24, 169, 87, .14); }
.badge.err { color: var(--danger); background: rgba(217, 40, 40, .14); }
.alert { padding: 13px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--glass-strong); }
.alert.error { border-color: rgba(217, 40, 40, .35); }
.alert.success { border-color: rgba(24, 169, 87, .35); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(460px, 100%); padding: 28px; }
.logo-preview { max-width: 220px; max-height: 90px; object-fit: contain; }
.weight-submit-bar {
  grid-column: span 2;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 16px;
  align-items: stretch;
  margin-top: 8px;
}
.weight-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(11, 116, 222, .12), rgba(255, 255, 255, .45));
  display: grid;
  gap: 8px;
}
.weight-box small {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 900;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.weight-meta {
  display: block;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.4;
}
.weight-box strong {
  font-size: clamp(2.7rem, 6vw, 4.8rem);
  line-height: 1;
  color: var(--primary);
}
.weight-box-inline {
  margin-bottom: 2px;
}
.weight-box-inline strong {
  font-size: clamp(2.1rem, 5vw, 3.4rem);
}
.submit-box {
  display: grid;
  align-content: center;
  gap: 12px;
  min-width: 240px;
}
.checkbox-inline {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
}
.ticket { width: min(820px, 100%); margin: 20px auto; background: white; color: #111827; padding: 28px; border: 1px solid #d1d5db; }
.ticket.narrow { width: 300px; font-size: 12px; padding: 12px; }
.ticket table { min-width: 0; }
.ticket th, .ticket td { color: #111827; padding: 7px 0; }
.ticket-header { text-align: center; margin-bottom: 14px; }
.print-actions { width: min(820px, 100%); margin: 18px auto; display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 820px) {
  .page { width: min(100% - 18px, 1180px); padding-top: 12px; }
  .topbar, .hero { grid-template-columns: 1fr; display: grid; }
  .grid.two, .grid.three, .grid.actions, .form-grid { grid-template-columns: 1fr; }
  .api-key-row { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .big-action { min-height: 110px; }
  .weight-submit-bar { grid-template-columns: 1fr; }
  .submit-box { min-width: 0; }
  .nav { width: 100%; }
  .nav a, .nav button { flex: 1; text-align: center; }
}

@media print {
  body { background: white; }
  .topbar, .print-actions, .no-print { display: none !important; }
  .ticket { border: 0; box-shadow: none; margin: 0 auto; }
}
