:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  --ink: #111b3c;
  --muted: #718096;
  --navy: #111b3c;
  --navy-soft: #172757;
  --cyan: #08b9d7;
  --blue: #2981c4;
  --blue-dark: #1d6fa8;
  --paper: #ffffff;
  --canvas: #f4f7fb;
  --line: #dfe7f0;
  --success: #1daf82;
  --warning: #ba7a00;
  --danger: #e85353;
  --shadow: 0 18px 50px rgba(17, 27, 60, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 250px; padding: 28px 18px; display: flex; flex-direction: column; color: white; background: linear-gradient(180deg, #111b3c, #162757); }
.brand { min-height: 68px; margin: 0 9px 30px; display: flex; align-items: center; gap: 12px; }
.brand img { width: 50px; height: 50px; object-fit: contain; }
.brand span { padding-left: 12px; border-left: 1px solid rgba(255,255,255,.25); color: var(--cyan); font-size: .72rem; font-weight: 900; letter-spacing: .13em; }
.primary-nav { display: grid; align-content: start; gap: 3px; }
.nav-heading { margin: 0 12px 8px; color: #6f81a6; font-size: .64rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav-heading-spaced { margin-top: 23px; }
.nav-item { position: relative; width: 100%; min-height: 45px; padding: 11px 13px; display: flex; align-items: center; gap: 12px; color: #aab7d0; background: transparent; border: 0; border-radius: 10px; font-weight: 700; text-align: left; }
.nav-icon { width: 19px; height: 19px; display: inline-flex; flex: 0 0 19px; }
.nav-icon svg { width: 100%; height: 100%; }
.nav-item:hover, .nav-item:focus-visible, .nav-item.active { color: white; background: rgba(255,255,255,.09); }
.nav-item.active::before { content: ""; position: absolute; left: 0; width: 3px; height: 21px; border-radius: 4px; background: var(--cyan); }
.sidebar-footer { margin-top: auto; padding: 20px 5px 0; border-top: 1px solid rgba(255,255,255,.11); }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 38px; color: white; background: linear-gradient(135deg, var(--cyan), var(--blue)); border-radius: 50%; font-size: .72rem; font-weight: 800; }
.user-chip div { min-width: 0; }
.user-chip strong, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: .82rem; }
.user-chip small { margin-top: 2px; color: #9facc7; font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; }
.logout-link { margin-top: 13px; padding: 5px 0; color: #9facc7; background: transparent; border: 0; font-size: .8rem; font-weight: 700; }
.logout-link:hover { color: white; }
.main-wrap { min-height: 100vh; margin-left: 250px; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 104px; padding: 22px 36px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: white; border-bottom: 1px solid #e9eef5; }
.topbar h1 { margin: 3px 0 0; font-size: 1.55rem; font-weight: 760; letter-spacing: -.03em; }
.eyebrow { margin: 0 0 5px; color: var(--cyan); font-size: .7rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.connection-state { padding: 8px 11px; color: #0b8c67; background: #e5f8f1; border-radius: 99px; font-size: .76rem; font-weight: 750; }
.menu-button { display: none; width: 42px; height: 42px; padding: 0; color: var(--ink); background: transparent; border: 0; font-size: 1.45rem; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(8, 17, 42, .55); border: 0; }

main { max-width: 1600px; margin: 0 auto; padding: 30px 36px 72px; }
.view { display: none; }
.view.active { display: block; }
.section-heading { margin-bottom: 24px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.55rem); letter-spacing: -0.035em; }
.section-heading p:not(.eyebrow) { max-width: 720px; margin: 8px 0 0; color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.metric-card, .panel { background: var(--paper); border: 1px solid #e6edf5; border-radius: 15px; box-shadow: var(--shadow); }
.metric-card { padding: 24px; display: grid; gap: 4px; }
.metric-card span { color: var(--muted); font-weight: 700; }
.metric-card strong { margin: 8px 0 2px; color: var(--navy); font-size: 2.4rem; }
.metric-card small { color: var(--muted); }
.panel { padding: clamp(18px, 3vw, 28px); }
.next-step-panel { margin-top: 22px; display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.next-step-panel h3 { margin: 0; font-size: 1.4rem; }
.next-step-panel p:not(.eyebrow) { max-width: 750px; margin: 8px 0 0; color: var(--muted); }

.button { min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; transition: 140ms ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: 0.55; cursor: wait; transform: none; }
.button-primary { color: white; background: linear-gradient(135deg, var(--cyan), var(--blue)); box-shadow: 0 8px 20px rgba(8, 185, 215, .18); }
.button-primary:hover { background: linear-gradient(135deg, #08a9c5, #246fac); }
.button-secondary { color: var(--navy); background: white; border-color: #bac7d1; }
.button-quiet { min-height: 36px; color: white; background: transparent; border-color: rgba(255,255,255,0.3); }
.full-width { width: 100%; }

.toolbar { margin-bottom: 22px; display: flex; gap: 10px; }
.search-field { flex: 1; }
input, select, textarea { width: 100%; padding: 10px 12px; color: var(--ink); background: white; border: 1px solid #b9c6cf; border-radius: 9px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14); }
label { display: grid; gap: 7px; color: #394957; font-size: 0.88rem; font-weight: 720; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 14px; color: #7b879b; background: #fafbfd; text-align: left; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f7f9fa; }
.code-cell { color: var(--blue-dark); font-family: "Cascadia Mono", Consolas, monospace; font-weight: 700; }
.status-pill { display: inline-flex; padding: 5px 9px; color: var(--success); background: #e7f4ee; border-radius: 999px; font-size: 0.76rem; font-weight: 800; }
.empty-state { margin: 26px 0 0; padding: 28px; color: var(--muted); background: #f7f9fa; border-radius: 12px; text-align: center; }

.scan-panel { margin-bottom: 18px; background: linear-gradient(135deg, white, #f1f8fa); }
.scan-form { max-width: 820px; }
.scan-form > div { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 8px; }
.scan-form input { min-height: 50px; font-family: "Cascadia Mono", Consolas, monospace; font-size: 1.05rem; }
.device-title { display: flex; justify-content: space-between; gap: 20px; }
.device-title h3 { margin: 0; font-size: 1.55rem; }
.detail-grid { margin: 26px 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.detail-grid div { padding: 15px; background: #f6f8fa; border-radius: 11px; }
.detail-grid dt { color: var(--muted); font-size: 0.76rem; font-weight: 800; text-transform: uppercase; }
.detail-grid dd { margin: 7px 0 0; overflow-wrap: anywhere; font-weight: 700; }
.move-form { padding: 20px; background: #eef4f6; border-radius: 13px; display: grid; grid-template-columns: 1fr 1fr 2fr auto; align-items: end; gap: 12px; }
.movement-section { margin-top: 28px; }
.movement-section h4 { margin-bottom: 14px; }
.movement-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.movement-list li { padding: 12px 14px; border-left: 3px solid var(--blue); background: #f7f9fa; }
.movement-list small { display: block; margin-top: 4px; color: var(--muted); }

.dialog { width: min(760px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 32px 90px rgba(10, 28, 43, 0.28); }
.dialog::backdrop { background: rgba(13, 29, 43, 0.62); backdrop-filter: blur(3px); }
.dialog form { padding: 28px; }
.login-dialog { width: min(430px, calc(100% - 32px)); }
.login-dialog form { display: grid; gap: 16px; }
.login-brand { display: flex; align-items: center; gap: 11px; color: var(--blue-dark); font-size: .72rem; font-weight: 850; letter-spacing: .12em; }
.login-brand img { width: 42px; height: 42px; object-fit: contain; }
.login-dialog h2 { margin: 0; font-size: 2rem; }
.login-dialog p:not(.eyebrow):not(.form-error) { margin: -8px 0 4px; color: var(--muted); }
.dialog-heading { margin-bottom: 24px; display: flex; justify-content: space-between; gap: 18px; }
.dialog-heading h2 { margin: 0; }
.icon-button { width: 38px; height: 38px; color: var(--muted); background: #eef2f4; border: 0; border-radius: 50%; font-size: 1.5rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.wide-field { grid-column: 1 / -1; }
.dialog-actions { margin-top: 24px; display: flex; justify-content: end; gap: 10px; }
.form-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 0.86rem; }
.message { margin-bottom: 22px; padding: 13px 16px; color: var(--navy); background: #dff0f5; border-left: 4px solid var(--blue); border-radius: 7px; }
.message.error { color: #752424; background: #fbe9e9; border-left-color: var(--danger); }

@media (max-width: 900px) {
  .metric-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .move-form { grid-template-columns: 1fr 1fr; }
  .move-form .wide-field { grid-column: 1 / -1; }
  .move-form button { grid-column: 1 / -1; }
}

@media (max-width: 780px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 20px 0 50px rgba(0,0,0,.2); }
  .main-wrap { margin-left: 0; }
  .menu-button { display: inline-grid; place-items: center; flex: 0 0 42px; }
  .topbar { min-height: 90px; padding: 18px 20px; justify-content: flex-start; }
  .topbar-actions { margin-left: auto; }
  main { padding: 24px 20px 60px; }
}

@media (max-width: 620px) {
  main { padding: 24px 16px 52px; }
  .topbar { min-height: 78px; padding: 15px 16px; }
  .connection-state { display: none; }
  .topbar h1 { font-size: 1.25rem; }
  .section-heading, .next-step-panel { align-items: stretch; flex-direction: column; }
  .section-heading .button, .next-step-panel .button { width: 100%; }
  .form-grid, .detail-grid, .move-form { grid-template-columns: 1fr; }
  .wide-field, .move-form .wide-field, .move-form button { grid-column: auto; }
  .scan-form > div { grid-template-columns: 1fr; }
  .dialog form { padding: 22px 18px; }
}
