:root {
  --ink: #102a43;
  --ink-soft: #486581;
  --navy: #102a43;
  --blue: #1463ff;
  --blue-dark: #0c4ed6;
  --teal: #0f766e;
  --teal-soft: #e7f7f3;
  --amber: #b45309;
  --amber-soft: #fff4dc;
  --red: #b42318;
  --red-soft: #fff0ef;
  --line: #d9e2ec;
  --panel: #ffffff;
  --page: #f3f6fa;
  --muted: #66788a;
  --shadow: 0 18px 45px rgba(16, 42, 67, 0.09);
  --radius: 16px;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% 8%, rgba(20, 99, 255, 0.07), transparent 24rem),
    var(--page);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.16;
  letter-spacing: -0.035em;
}

h2 {
  font-size: 1.15rem;
}

.muted,
.panel-head p,
.page-heading p,
.login-intro {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.brand-mark,
.brand-tile {
  display: grid;
  place-items: center;
  background: var(--blue);
  color: white;
  font-weight: 900;
  letter-spacing: -0.08em;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  min-height: 100vh;
}

.login-aside {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(40px, 8vw, 110px);
  overflow: hidden;
  color: white;
  background:
    linear-gradient(145deg, rgba(9, 35, 58, 0.96), rgba(16, 60, 94, 0.92)),
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(255,255,255,.04) 22px 23px);
}

.login-aside .eyebrow {
  color: #79d8cf;
}

.login-aside h1 {
  max-width: 650px;
  margin: 22px 0;
  font-size: clamp(2.6rem, 5.3vw, 5rem);
  letter-spacing: -0.055em;
}

.login-aside .login-intro {
  max-width: 560px;
  color: #b8c9d8;
  font-size: 1.05rem;
  line-height: 1.8;
}

.brand-mark {
  width: 54px;
  height: 54px;
  margin-bottom: 48px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 15px;
  background: rgba(255,255,255,.1);
}

.flow-line {
  display: flex;
  align-items: center;
  max-width: 520px;
  margin-top: 56px;
  color: #cfe0ed;
  font-size: .84rem;
  font-weight: 700;
}

.flow-line i {
  height: 1px;
  flex: 1;
  margin: 0 10px;
  background: linear-gradient(90deg, #4a728f, #69cec2);
}

.login-card {
  align-self: center;
  width: min(430px, calc(100% - 40px));
  margin: 40px auto;
  padding: 38px;
  border: 1px solid rgba(217, 226, 236, .85);
  border-radius: 24px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.login-card h2 {
  margin-bottom: 8px;
  font-size: 1.8rem;
}

.login-card > label,
.user-form > label {
  display: block;
  margin-top: 22px;
}

.login-help {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: .82rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: white;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(20, 99, 255, .12);
}

input::placeholder,
textarea::placeholder {
  color: #98a8b7;
}

.button,
.nav-button {
  white-space: nowrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 800;
  transition: transform .12s, background .15s, border-color .15s;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:disabled {
  cursor: wait;
  opacity: .6;
  transform: none;
}

.button.primary {
  background: var(--blue);
  color: white;
}

.button.primary:hover {
  background: var(--blue-dark);
}

.button.secondary {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.button.secondary:hover {
  border-color: #a7b8c8;
  background: #f8fafc;
}

.button.danger {
  border-color: #f1beb9;
  background: var(--red-soft);
  color: var(--red);
}

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: .78rem;
}

.button.wide {
  width: 100%;
  margin-top: 22px;
}

.text-button {
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
}

.icon-button {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 9px;
  background: transparent;
  color: inherit;
}

.form-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--red-soft);
  color: var(--red);
  font-size: .84rem;
  line-height: 1.45;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 72px;
  padding: 0 clamp(18px, 3.5vw, 54px);
  color: white;
  background: rgba(16, 42, 67, .97);
  box-shadow: 0 6px 24px rgba(16, 42, 67, .16);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: white;
  text-decoration: none;
}

.brand-tile {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: .8rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: .94rem;
}

.brand small {
  margin-top: 2px;
  color: #91a8ba;
  font-size: .58rem;
  letter-spacing: .13em;
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.nav-button {
  min-height: 42px;
  padding: 0 15px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #b9c8d4;
  font-size: .86rem;
  font-weight: 700;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255,255,255,.09);
  color: white;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-copy {
  text-align: right;
}

.user-copy strong,
.user-copy span {
  display: block;
}

.user-copy strong {
  font-size: .86rem;
}

.user-copy span {
  margin-top: 3px;
  color: #aebfcb;
  font-size: .68rem;
}

.workspace {
  width: min(1420px, calc(100% - 36px));
  margin: 0 auto;
  padding: 38px 0 70px;
}

.view-section {
  animation: enter .24s ease-out;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-heading h1 {
  margin-bottom: 7px;
}

.page-heading p:last-child {
  margin-bottom: 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shift-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid #cfe0d8;
  border-radius: 999px;
  background: #f1fbf8;
  color: var(--teal);
  font-size: .8rem;
  font-weight: 800;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 5px rgba(16,185,129,.12);
}

.panel {
  border: 1px solid rgba(217, 226, 236, .9);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 7px 25px rgba(16, 42, 67, .045);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.panel-head h2 {
  margin-bottom: 5px;
}

.panel-head p {
  margin-bottom: 0;
  font-size: .8rem;
}

.scanner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, .7fr);
  gap: 20px;
}

.scan-panel,
.recent-panel {
  padding: 24px;
}

.scan-form {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid #d9e5f2;
  border-radius: 13px;
  background: #f8fafc;
}

.action-field {
  max-width: 480px;
}

.barcode-field {
  margin-top: 15px;
}

.scan-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

#scanner-input {
  height: 60px;
  padding: 0 17px;
  border-color: #b8cce0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: .025em;
}

.scan-input-row .button {
  min-width: 120px;
  min-height: 60px;
  font-size: 1rem;
}

.exception-fields {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.scan-result {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 92px;
  margin-top: 18px;
  padding: 18px 20px;
  border-radius: 13px;
  background: #eef2f6;
  color: var(--ink-soft);
}

.scan-result .result-symbol {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  background: white;
  font-size: 1.7rem;
  font-weight: 900;
}

.scan-result strong {
  color: var(--ink);
  font-size: 1.06rem;
}

.scan-result p {
  margin: 5px 0 0;
  font-size: .82rem;
}

.scan-result.success {
  background: var(--teal-soft);
  color: #35655f;
}

.scan-result.success .result-symbol {
  background: var(--teal);
  color: white;
}

.scan-result.error {
  background: var(--red-soft);
  color: #7a302a;
}

.scan-result.error .result-symbol {
  background: var(--red);
  color: white;
}

.scan-result .result-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 8px;
  font-family: Consolas, monospace;
  font-size: .78rem;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.recent-list {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.recent-item {
  padding: 12px;
  border: 1px solid #e5edf4;
  border-radius: 10px;
  background: #fbfcfd;
}

.recent-item strong {
  display: block;
  overflow: hidden;
  font-family: Consolas, monospace;
  font-size: .76rem;
  text-overflow: ellipsis;
}

.recent-item span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  color: var(--muted);
  font-size: .7rem;
}

.empty-copy {
  margin: 18px 0;
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}

.camera-panel {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 1fr;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
  padding: 14px;
  border-radius: 12px;
  background: #0f2233;
  color: white;
}

.camera-panel video {
  width: 100%;
  max-height: 210px;
  border-radius: 8px;
  background: #07131d;
  object-fit: cover;
}

.camera-actions {
  display: grid;
  gap: 12px;
  justify-items: start;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 240px 120px auto;
  gap: 13px;
  align-items: end;
  margin-bottom: 16px;
  padding: 18px;
}

.table-panel {
  overflow: hidden;
}

.table-panel > .panel-head {
  padding: 20px;
}

.table-meta {
  display: flex;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .76rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #fafbfd;
  color: var(--muted);
  font-size: .7rem;
  letter-spacing: .04em;
}

tbody tr:hover {
  background: #f8fbff;
}

.cell-main {
  display: block;
  font-weight: 800;
}

.cell-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: .7rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 99px;
  background: #edf4ff;
  color: #174ea6;
  font-size: .7rem;
  font-weight: 800;
}

.status-badge.finished {
  background: #edf7f1;
  color: #1e6b46;
}

.status-badge.overdue {
  background: var(--red-soft);
  color: var(--red);
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.status-badge.paused {
  background: var(--amber-soft);
  color: var(--amber);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 18px;
  color: var(--muted);
  font-size: .76rem;
}

.order-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 20px;
  align-items: start;
}

.order-main,
.order-side,
.user-form {
  padding: 22px;
}

.three-fields,
.four-fields,
.prescription-grid {
  display: grid;
  gap: 12px;
}

.three-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.four-fields {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.three-fields + label,
.item-card > label {
  display: block;
  margin-top: 13px;
}

.order-items {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.item-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
}

.item-card-head,
.prescription-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.item-card-head h3 {
  margin: 0;
}

.prescription-head {
  margin: 18px 0 9px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.prescription-head small {
  color: var(--muted);
}

.lens-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.lens-side {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 13px;
  border-radius: 10px;
  background: white;
}

.lens-side b {
  grid-column: 1 / -1;
  color: var(--blue);
}

.order-side {
  position: sticky;
  top: 94px;
}

.check-list {
  display: grid;
  gap: 12px;
  padding-left: 20px;
  color: var(--ink-soft);
  font-size: .82rem;
  line-height: 1.55;
}

.created-result {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #bae6d9;
  border-radius: 11px;
  background: var(--teal-soft);
  color: #225f55;
  font-size: .8rem;
}

.created-result code {
  display: block;
  margin: 7px 0 10px;
  color: var(--ink);
  font-weight: 800;
}

.admin-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.user-form .button {
  margin-top: 20px;
}

.detail-dialog {
  width: min(900px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: white;
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(5, 27, 45, .35);
}

.detail-dialog::backdrop {
  background: rgba(8, 27, 43, .62);
  backdrop-filter: blur(3px);
}

.dialog-head {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: white;
}

.dialog-head h2 {
  margin: 0;
}

.dialog-head .icon-button {
  border-color: var(--line);
  color: var(--ink-soft);
}

.detail-content {
  padding: 24px;
}

.detail-hero,
.detail-columns {
  display: grid;
  gap: 16px;
}

.detail-hero {
  grid-template-columns: 1fr auto;
  align-items: start;
  padding: 18px;
  border-radius: 12px;
  background: #f7fafc;
}

.detail-hero h3 {
  margin: 0 0 7px;
  font-family: Consolas, monospace;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  color: var(--muted);
  font-size: .8rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.detail-columns {
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
}

.info-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.info-card h4 {
  margin: 0 0 12px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 15px;
}

.info-grid span {
  color: var(--muted);
  font-size: .73rem;
}

.info-grid strong {
  display: block;
  margin-top: 2px;
  font-size: .84rem;
}

.timeline {
  display: grid;
  gap: 0;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.timeline h4 {
  margin: 0 0 15px;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 125px 1fr auto;
  gap: 14px;
  padding: 0 0 18px 20px;
  border-left: 2px solid #d8e4ef;
  font-size: .8rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}

.timeline-item::before {
  position: absolute;
  top: 3px;
  left: -6px;
  width: 10px;
  height: 10px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
  content: "";
}

.timeline-item time,
.timeline-item small {
  color: var(--muted);
  font-size: .72rem;
}

.exception-note {
  margin-top: 12px;
  padding: 11px;
  border-radius: 9px;
  background: var(--amber-soft);
  color: #6b420c;
  font-size: .78rem;
}

.toast-region {
  position: fixed;
  z-index: 100;
  top: 84px;
  right: 20px;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100% - 40px));
}

.toast {
  padding: 12px 15px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  font-size: .82rem;
  animation: enter .2s ease-out;
}

.toast.error {
  background: #81251e;
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 8px 0 10px;
  }

  .user-area {
    grid-column: 2;
    grid-row: 1;
  }

  .scanner-grid,
  .order-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .order-side {
    position: static;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-aside {
    min-height: 42vh;
    padding: 48px;
  }

  .login-aside h1 {
    margin: 14px 0;
    font-size: clamp(2.2rem, 9vw, 3.6rem);
  }

  .flow-line {
    margin-top: 24px;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 10px 14px;
  }

  .brand small,
  .user-copy span {
    display: none;
  }

  .workspace {
    width: min(100% - 22px, 1420px);
    padding-top: 24px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .scan-panel,
  .recent-panel,
  .order-main,
  .order-side,
  .user-form {
    padding: 16px;
  }

  .scan-form {
    padding: 14px;
  }

  .scan-input-row,
  .exception-fields,
  .filter-bar,
  .three-fields,
  .four-fields,
  .lens-grid,
  .detail-columns,
  .camera-panel {
    grid-template-columns: 1fr;
  }

  .scan-input-row .button {
    min-height: 50px;
  }

  .detail-hero {
    grid-template-columns: 1fr;
  }

  .detail-actions {
    justify-content: flex-start;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .login-aside {
    min-height: 36vh;
    padding: 34px 24px;
  }

  .login-aside .login-intro,
  .flow-line {
    display: none;
  }

  .login-card {
    margin: 22px auto;
    padding: 26px 22px;
  }
}

@media print {
  body {
    background: white;
  }

  .topbar,
  .page-heading,
  .detail-actions,
  .dialog-head .icon-button {
    display: none;
  }

  .detail-dialog {
    position: static;
    width: 100%;
    max-height: none;
    box-shadow: none;
  }
}
