:root {
  --header: #757171;
  --accent: #ff7b00;
  --accent-dark: #c95f00;
  --line: #dedede;
  --text: #222;
  --muted: #666;
  --danger: #b42318;
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: #fff; }
button, input, select { font: inherit; }
button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 9px 14px; cursor: pointer; }
button, th, .tab, .actions, .topbar { user-select: none; }
button:hover { border-color: var(--accent); }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.danger { background: #fff; border-color: #e5b8b4; color: var(--danger); }
.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.hidden { display: none !important; }

.login-view, .password-view { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, #fff 0, #f6f6f6 100%); padding: 24px; }
.login-panel { width: min(420px, 100%); border: 1px solid var(--line); border-radius: 8px; padding: 32px; display: grid; gap: 18px; background: #fff; box-shadow: 0 18px 40px rgba(0,0,0,.08); }
.login-panel h1, .topbar h1 { margin: 0; }
.serial-view, .scanner-view { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #fff; }
.serial-panel, .scanner-panel { width: min(560px, 100%); display: grid; gap: 16px; border: 1px solid var(--line); border-radius: 8px; padding: 24px; box-shadow: 0 18px 40px rgba(0,0,0,.08); }
.serial-panel h1, .scanner-panel h1 { margin: 0; }
.scanner-frame { aspect-ratio: 4 / 3; background: #111; border: 3px solid var(--accent); border-radius: 8px; overflow: hidden; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.manual-serial-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.serial-details { display: grid; gap: 0; margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.serial-details div { display: grid; grid-template-columns: 110px 1fr; min-height: 38px; border-bottom: 1px solid var(--line); }
.serial-details div:last-child { border-bottom: 0; }
.serial-details dt { margin: 0; padding: 10px; background: var(--header); color: #fff; font-weight: 700; }
.serial-details dd { margin: 0; padding: 10px; min-width: 0; overflow-wrap: anywhere; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 0; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select { border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; min-width: 0; background: #fff; }
input[readonly] { background: #f7f7f7; color: #333; }
.message { min-height: 20px; color: var(--danger); margin: 0; }

.shell { min-height: 100vh; }
.topbar { background: var(--header); color: #fff; display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 18px 28px; }
.topbar .eyebrow { color: #fff; opacity: .86; }
.user-box { display: flex; align-items: center; gap: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 10px 24px 0; overflow-x: auto; }
.tab { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 0; min-width: 86px; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.workspace { padding: 20px 24px 32px; }
.panel { display: grid; gap: 16px; }

.asset-form, .filters, .master-form { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; align-items: end; }
.asset-form .wide { grid-column: span 2; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; max-height: 58vh; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th { background: var(--header); color: #fff; position: sticky; top: 0; z-index: 1; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 13px; }
tbody tr.selectable { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: #fff4ea; }
.check { display: flex; align-items: center; gap: 8px; align-self: end; min-height: 39px; color: var(--text); }
.check input { width: 18px; height: 18px; flex: 0 0 18px; margin: 0; padding: 0; }

dialog { border: 0; border-radius: 8px; padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.24); min-width: min(360px, calc(100vw - 32px)); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toast { position: fixed; right: 18px; bottom: 18px; background: #222; color: #fff; padding: 12px 16px; border-radius: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.18); }

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 16px; }
  .workspace { padding: 14px; }
  .asset-form, .filters, .master-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .asset-form .wide { grid-column: span 2; }
  .manual-serial-form { grid-template-columns: 1fr; }
}
