:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #68738a;
  --line: #e4e8f0;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --blue: #1769e0;
  --blue-dark: #1057c0;
  --shadow: 0 14px 40px rgba(31, 45, 78, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: "DM Sans", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 30px 20px; background: #101a30; color: #fff; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 32px; color: white; text-decoration: none; font: 800 20px "Manrope", sans-serif; }
.brand-mark { display: grid; place-items: center; width: 36px; aspect-ratio: 1; border-radius: 11px; background: linear-gradient(135deg, #3b82f6, #1555ca); box-shadow: 0 7px 20px #061b4699; }
nav { display: grid; gap: 8px; }
.nav-item { color: #9eabc2; text-decoration: none; padding: 12px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: center; font-weight: 600; }
.nav-item:hover, .nav-item.active { color: #fff; background: #1b2944; }
.nav-icon { width: 20px; text-align: center; font-size: 18px; }
.sidebar-note { margin-top: auto; display: flex; align-items: flex-start; gap: 10px; padding: 15px; border: 1px solid #2c3a55; border-radius: 12px; background: #142039; }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 13px; }
.sidebar-note small { color: #8997b0; font-size: 11px; margin-top: 3px; }
.status-dot { width: 8px; height: 8px; background: #3ddc97; border-radius: 50%; margin-top: 4px; box-shadow: 0 0 0 4px #3ddc9720; }

main { width: min(1180px, 100%); margin: 0 auto; padding: 36px 48px 60px; }
.topbar, .section-heading, .dialog-header, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.eyebrow { color: #8290a7; letter-spacing: .13em; font-size: 10px; font-weight: 800; margin: 0 0 5px; }
h1, h2, h3 { font-family: "Manrope", sans-serif; margin: 0; }
h1 { font-size: 29px; letter-spacing: -.035em; }
h2 { font-size: 20px; }
.button { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; transition: .18s ease; display: inline-flex; justify-content: center; align-items: center; gap: 7px; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--blue); box-shadow: 0 8px 18px #1769e02b; }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: #41506a; background: #eef1f6; }
.button.danger { color: #be3346; background: #fff0f1; }
.button.small { padding: 8px 11px; font-size: 12px; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 30px 0 34px; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: 0 7px 24px rgba(31,45,78,.035); }
.metric-icon { width: 42px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 11px; font-size: 19px; }
.metric-icon.blue { background: #eaf2ff; color: #1769e0; }
.metric-icon.green { background: #e8f9f1; color: #159867; }
.metric-icon.purple { background: #f2ebff; color: #814bd2; }
.metric-card strong, .metric-card span { display: block; }
.metric-card strong { font: 800 23px "Manrope"; }
.metric-card div span { color: var(--muted); font-size: 12px; margin-top: 2px; }

.section-heading { margin-bottom: 18px; }
.section-heading p { color: var(--muted); margin: 5px 0 0; font-size: 13px; }
.search-field { min-width: 240px; padding: 9px 12px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; background: white; color: #8290a7; }
.search-field input { width: 100%; border: 0; outline: 0; color: var(--ink); }
.batch-toolbar { margin-bottom: 15px; padding: 11px 13px; border: 1px solid #cfe0fa; border-radius: 11px; background: #edf4ff; display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.batch-toolbar[hidden] { display: none; }
.batch-toolbar > div { display: flex; align-items: center; gap: 10px; }
.batch-toolbar strong { color: #24548f; font-size: 12px; }
.text-button { border: 0; background: transparent; color: var(--blue); padding: 5px; font-size: 11px; font-weight: 700; }
.plate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.plate-card { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 18px; box-shadow: 0 8px 25px rgba(31,45,78,.04); transition: .2s ease; }
.plate-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.plate-card-top { display: flex; align-items: center; gap: 12px; }
.select-plate { align-self: flex-start; display: grid; place-items: center; width: 22px; height: 22px; margin: -2px -4px 0 -4px; }
.select-plate input { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.company-avatar { width: 42px; aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; color: #fff; font: 800 18px "Manrope"; }
.company-info { min-width: 0; flex: 1; }
.company-info h3 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-info p { margin: 3px 0 0; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-badge { color: #16815c; background: #eaf8f2; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-badge.inactive { color: #91631d; background: #fff5db; }
.plate-stats { display: flex; gap: 18px; margin: 18px 0 15px; padding: 13px 0; border-block: 1px solid #eef0f4; }
.plate-stats div { flex: 1; }
.plate-stats strong, .plate-stats span { display: block; }
.plate-stats strong { font: 700 14px "Manrope"; }
.plate-stats span { color: var(--muted); font-size: 10px; margin-top: 2px; }
.production-field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 5px 10px; margin-bottom: 13px; }
.production-field > span { grid-column: 1/-1; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.production-field select { min-width: 0; width: 100%; padding: 7px 9px; border: 1px solid #dfe4ec; border-radius: 8px; background: #fff; color: #3d4c64; font-size: 11px; font-weight: 600; }
.production-field small { color: #738097; font: 700 10px ui-monospace, monospace; }
.plate-actions { display: flex; gap: 8px; }
.plate-actions .button:first-child { flex: 1; }

.empty-state { text-align: center; padding: 65px 20px; background: #fff; border: 1px dashed #d7ddea; border-radius: 16px; }
.empty-state h3 { font-size: 18px; }
.empty-state p { color: var(--muted); max-width: 430px; margin: 8px auto 18px; font-size: 13px; }
.empty-art { width: 80px; height: 68px; margin: 0 auto 20px; display: grid; place-items: center; position: relative; color: var(--blue); background: #edf4ff; border-radius: 17px; font-size: 27px; }
.empty-art i { position: absolute; right: -7px; top: -7px; display: grid; place-items: center; width: 27px; height: 27px; background: #35c58b; color: #fff; border-radius: 50%; font-style: normal; font-size: 13px; }

.how-it-works { margin-top: 38px; background: #edf2fa; border-radius: 15px; padding: 20px 24px; display: flex; align-items: center; }
.how-it-works > div:not(.connector) { display: flex; align-items: center; gap: 12px; flex: 1; }
.how-it-works div > span { flex: 0 0 auto; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: #fff; font-size: 12px; font-weight: 800; }
.how-it-works p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.how-it-works strong { color: var(--ink); display: block; font-size: 12px; }
.connector { width: 28px; border-top: 1px dashed #b4bed0; margin-inline: 8px; }

dialog { width: min(520px, calc(100% - 28px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 28px 90px #13213c3d; color: var(--ink); }
dialog::backdrop { background: #111a2f99; backdrop-filter: blur(3px); }
#plateForm { padding: 25px; }
.dialog-header { align-items: flex-start; margin-bottom: 22px; }
.icon-button { border: 0; background: #f0f2f6; color: #6d788d; width: 31px; height: 31px; border-radius: 50%; font-size: 20px; line-height: 1; }
#plateForm > label:not(.switch-row), .field-row label { display: grid; gap: 7px; color: #48566e; font-size: 12px; font-weight: 700; margin-bottom: 15px; }
.destination-field .inline-field { display: flex; align-items: stretch; gap: 7px; }
.destination-field .inline-field input { flex: 1; min-width: 0; }
.destination-field .inline-field .button { flex: 0 0 auto; white-space: nowrap; }
.destination-field > small { color: var(--muted); font-size: 10px; font-weight: 500; }
#plateForm input:not([type="checkbox"]):not([type="color"]) { min-width: 0; width: 100%; border: 1px solid #dce1e9; padding: 11px 12px; border-radius: 9px; outline: 0; color: var(--ink); }
#plateForm select { min-width: 0; width: 100%; border: 1px solid #dce1e9; padding: 11px 12px; border-radius: 9px; outline: 0; color: var(--ink); background: #fff; }
#inventoryCodeField small { color: var(--muted); font-size: 10px; font-weight: 500; }
#plateForm input:focus { border-color: #73a4ee; box-shadow: 0 0 0 3px #1769e012; }
.field-row { display: grid; grid-template-columns: 1fr 88px; gap: 14px; }
#plateForm input[type="color"] { width: 100%; height: 41px; border: 1px solid #dce1e9; padding: 4px; border-radius: 9px; background: #fff; }
.input-prefix { display: flex; align-items: center; border: 1px solid #dce1e9; border-radius: 9px; overflow: hidden; }
.input-prefix:focus-within { border-color: #73a4ee; box-shadow: 0 0 0 3px #1769e012; }
.input-prefix > span { padding-left: 11px; color: #8290a7; }
.input-prefix input { border: 0 !important; box-shadow: none !important; padding-left: 2px !important; }
.switch-row { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 15px; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 12px; }
.switch-row small { color: var(--muted); margin-top: 3px; font-size: 10px; }
.switch-row input { width: 37px; height: 20px; accent-color: var(--blue); }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }
.form-error { color: #bd2d42; min-height: 18px; margin: 0; font-size: 12px; }

.details-dialog { width: min(740px, calc(100% - 28px)); }
.details-shell { display: grid; grid-template-columns: 250px 1fr; }
.plate-preview { padding: 28px; color: #fff; display: flex; flex-direction: column; justify-content: center; text-align: center; min-height: 390px; }
.plate-preview p { font-size: 10px; letter-spacing: .05em; margin: 0 0 4px; }
.plate-preview h3 { font-size: 23px; line-height: 1.1; }
.preview-body { margin-top: 25px; background: #fff; border-radius: 12px; padding: 20px 15px 14px; color: var(--ink); }
.preview-body img { width: 135px; height: 135px; }
.preview-body small { display: block; margin-top: 7px; font-weight: 700; }
.details-panel { padding: 25px; }
.details-panel .dialog-header { margin-bottom: 18px; }
.url-box { background: #f4f6fa; border: 1px solid var(--line); border-radius: 10px; padding: 11px; margin: 8px 0 15px; font-size: 11px; color: #4b5970; word-break: break-all; }
.detail-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.detail-actions { display: grid; gap: 9px; }
.detail-actions .button { width: 100%; }
.nfc-support { padding: 10px; background: #fff8e5; color: #815f18; border-radius: 9px; font-size: 11px; line-height: 1.45; margin-top: 13px; }
.nfc-support.ok { color: #136a4d; background: #eaf8f2; }
.danger-zone { display: flex; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.nfc-queue-shell { padding: 26px; }
.queue-progress { height: 6px; overflow: hidden; margin: 8px 0 9px; border-radius: 999px; background: #e7ebf2; }
.queue-progress i { display: block; height: 100%; border-radius: inherit; background: #36bd87; transition: width .25s ease; }
.queue-position { margin: 0 0 22px; color: var(--muted); font-size: 11px; }
.queue-instruction { display: grid; gap: 4px; margin: 14px 0; padding: 13px; border-radius: 10px; background: #edf4ff; color: #41638f; }
.queue-instruction strong { color: #224e86; font-size: 12px; }
.queue-instruction span { font-size: 11px; line-height: 1.45; }
.queue-complete { padding: 50px 28px; text-align: center; }
.queue-complete p { color: var(--muted); margin: 7px 0 20px; }
.queue-check { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 50%; color: #fff; background: #35bd87; font-size: 25px; }

.qc-shell { padding: 26px; }
.qc-intro { color: var(--muted); font-size: 12px; line-height: 1.5; margin: -7px 0 17px; }
.qc-camera { min-height: 170px; display: grid; place-items: center; overflow: hidden; border: 1px dashed #bfcbe0; border-radius: 12px; background: #f1f5fb; color: #6a7890; text-align: center; font-size: 12px; line-height: 1.45; }
.qc-camera video { display: block; width: 100%; max-height: 270px; object-fit: cover; }
.qc-actions { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-top: 12px; }
.qc-actions input { min-width: 0; width: 100%; border: 1px solid #dce1e9; border-radius: 9px; padding: 10px 11px; outline: 0; color: var(--ink); }
.qc-result { display: grid; gap: 3px; min-height: 19px; margin-top: 13px; font-size: 11px; }
.qc-result strong { font-size: 12px; }
.qc-result.success { color: #146c4e; }
.qc-result.error { color: #b52e43; }
.qc-result.info { color: var(--muted); }

.toast { position: fixed; z-index: 10; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: #152039; color: #fff; padding: 11px 16px; border-radius: 9px; font-size: 12px; opacity: 0; pointer-events: none; transition: .25s ease; box-shadow: var(--shadow); }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 15px 20px; flex-direction: row; align-items: center; }
  .brand { padding: 0; }
  .sidebar nav, .sidebar-note { display: none; }
  main { padding: 25px 20px 45px; }
  .plate-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar { align-items: flex-end; }
  .topbar-actions { flex-direction: column-reverse; align-items: stretch; }
  .topbar .button { font-size: 0; padding: 11px; }
  .topbar .button span { font-size: 20px; }
  .metrics { grid-template-columns: 1fr; gap: 9px; }
  .metric-card { padding: 13px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .batch-toolbar { align-items: stretch; flex-direction: column; }
  .batch-toolbar > div { justify-content: space-between; }
  .search-field { min-width: 0; }
  .how-it-works { display: grid; gap: 13px; }
  .connector { display: none; }
  .details-shell { grid-template-columns: 1fr; }
  .plate-preview { min-height: 320px; }
  .field-row { grid-template-columns: 1fr 75px; }
  .destination-field .inline-field { display: grid; }
  .destination-field .inline-field .button { width: 100%; }
  .qc-actions { grid-template-columns: 1fr; }
  .qc-actions .button { width: 100%; }
}
