:root {
  --bg: #eef2f4;
  --panel: #ffffff;
  --soft: #f7fafb;
  --text: #17242e;
  --muted: #667780;
  --line: #dce4e8;
  --line-strong: #c8d3d9;
  --green: #13866f;
  --green-soft: #e6f5f1;
  --blue: #2e6fa8;
  --blue-soft: #e8f1fa;
  --amber: #a86910;
  --amber-soft: #fff3df;
  --red: #bb4738;
  --red-soft: #fdeceb;
  --shadow: 0 7px 20px rgba(23, 36, 46, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  padding: 18px 13px;
  background: #17242e;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: #20a086;
  display: grid;
  place-items: center;
  font-weight: 800;
}

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

.brand span {
  margin-top: 2px;
  color: #b5c2c9;
  font-size: 11px;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #cbd5da;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.nav-button svg {
  width: 16px;
  height: 16px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 9px;
  align-items: center;
}

.sidebar-foot strong,
.sidebar-foot span {
  display: block;
}

.sidebar-foot span {
  margin-top: 2px;
  color: #aebbc2;
  font-size: 10px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5dd2b7;
  box-shadow: 0 0 0 4px rgba(93, 210, 183, 0.12);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 5px 0 0;
  font-size: 26px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

#pairDialog {
  width: min(420px, calc(100% - 24px));
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 20px;
}

#pairDialog::backdrop { background: rgba(0, 0, 0, .35); }
#pairDialog h2 { font-size: 20px; }
#pairDialog img { display: block; margin: 12px auto; }

.button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  text-decoration: none;
}

.button:hover {
  border-color: var(--green);
  color: var(--green);
}

.button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.button.danger {
  border-color: var(--red);
  color: var(--red);
}

.button svg {
  width: 15px;
  height: 15px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  width: 100%;
  text-align: left;
  color: inherit;
  font: inherit;
  min-width: 0;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric:hover,
.metric:focus-visible {
  border-color: var(--green);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(19, 134, 111, 0.12), var(--shadow);
}

.metric.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 5px 0;
  font-size: 25px;
}

.metric.amber strong {
  color: var(--amber);
}

.metric.red strong {
  color: var(--red);
}

.metric.green strong {
  color: var(--green);
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
}

.panel-head {
  min-height: 46px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head > div {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-head svg {
  width: 16px;
  height: 16px;
  color: var(--green);
}

.panel-head > span {
  color: var(--muted);
  font-size: 11px;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.panel-body {
  padding: 12px 13px 14px;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  gap: 14px;
}

.stack {
  min-width: 0;
}

.task-form {
  padding: 13px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.task-form label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.task-form label.wide {
  grid-column: span 3;
}

.task-form input,
.task-form select,
.task-form textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 0 9px;
  color: var(--text);
}

.task-form textarea {
  min-height: 72px;
  padding-top: 8px;
  resize: vertical;
}

.task-form input:focus,
.task-form select:focus,
.task-form textarea:focus {
  border-color: var(--green);
  outline: 2px solid rgba(19, 134, 111, 0.12);
}

.form-actions {
  grid-column: span 3;
  display: flex;
  justify-content: flex-end;
}

.task-list,
.outbox-list,
.notification-list {
  display: grid;
  gap: 9px;
}

.task-card,
.outbox-card,
.notification-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: var(--soft);
  padding: 10px 11px;
}

.task-card.overdue {
  border-left-color: var(--red);
}

.task-card-head,
.outbox-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.task-card strong,
.outbox-card strong,
.notification-card strong {
  overflow-wrap: anywhere;
}

.task-meta,
.outbox-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.task-actions,
.outbox-actions {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.badge {
  flex: 0 0 auto;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
}

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

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

.badge.green {
  background: var(--green-soft);
  color: var(--green);
}

.outbox-message {
  margin: 8px 0 0;
  padding: 9px;
  border-radius: 5px;
  background: #fff;
  color: #34444e;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty {
  min-height: 74px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--green);
  padding: 4px 0;
}

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

.detail-block {
  min-width: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.detail-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.detail-value {
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 140px 90px minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.footnote {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 12px;
  border-radius: 6px;
  background: #17242e;
  color: #fff;
  box-shadow: 0 12px 30px rgba(23, 36, 46, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mobile-task-page {
  background: #e9eff2;
}

.mobile-shell {
  width: min(720px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 14px 30px;
}

.mobile-head {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-head strong,
.mobile-head span {
  display: block;
}

.mobile-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-task-title > span {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.mobile-task-title h1 {
  margin: 5px 0 14px;
  font-size: 23px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.mobile-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.mobile-actions .button {
  min-height: 44px;
  flex: 1 1 150px;
}

.mobile-label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-label textarea,
.mobile-label input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 9px;
  color: var(--text);
  font: inherit;
}

.mobile-label textarea {
  min-height: 120px;
  resize: vertical;
}

#completePanel:not([hidden]) {
  border: 2px solid #49a66f;
  background: #f4fff8;
  box-shadow: 0 12px 28px rgba(37, 116, 69, 0.14);
}

#completePanel .panel-head {
  background: #e4f8eb;
}

#completePanel .panel-head strong {
  color: #185c35;
}

.attach-guide {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 11px 12px;
  border-left: 4px solid #2f9b5d;
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.attach-guide strong {
  color: #185c35;
  font-size: 14px;
}

.attach-file-label {
  padding: 12px;
  border: 2px dashed #63b980;
  border-radius: 6px;
  background: #fff;
  color: #185c35;
  font-size: 13px;
  font-weight: 700;
}

.attach-file-label input[type="file"] {
  border: 1px solid #9ccfad;
  background: #f6fff8;
  cursor: pointer;
}

.attach-file-label input[type="file"]:hover,
.attach-file-label input[type="file"]:focus {
  border-color: #2f9b5d;
  outline: 3px solid rgba(47, 155, 93, 0.14);
}

.mobile-progress {
  min-height: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-foot {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.assistant-shell {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.install-banner {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: var(--green-soft);
  color: #185c35;
}

.install-banner span {
  font-size: 13px;
  line-height: 1.6;
}

@media (min-width: 821px) {
  .install-banner {
    display: none;
  }
}

.assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.assistant-form,
.assistant-result {
  display: grid;
  gap: 12px;
}

.assistant-result textarea {
  min-height: 250px;
}

.assistant-qr-panel {
  margin-top: 14px;
}

.assistant-qr-body {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.assistant-qr-body img {
  width: 100%;
  max-width: 310px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.assistant-qr-body h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

@media (max-width: 820px) {
  .assistant-layout {
    grid-template-columns: 1fr;
  }

  .assistant-qr-body {
    grid-template-columns: 1fr;
  }
}

.inbox-section { margin-bottom: 20px; border-bottom: 1px solid var(--line-strong); padding-bottom: 16px; }
.delivery-note { padding: 10px 0; color: var(--blue); line-height: 1.6; }
.employee-inboxes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.inbox-person { min-width: 0; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.inbox-person > span { display: block; }
.delivery-status { color: var(--blue); line-height: 1.6; }
.inbox-tabs { display: flex; border-bottom: 1px solid var(--line-strong); margin-bottom: 16px; }
.inbox-tabs button { flex: 1; min-height: 44px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); }
.inbox-tabs button[aria-selected="true"] { color: var(--green); border-color: var(--green); font-weight: 700; }
.mobile-head > div:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.button { overflow-wrap: anywhere; white-space: normal; padding-top: 6px; padding-bottom: 6px; }
.button:disabled { opacity: .5; cursor: wait; }
.task-card-head, .outbox-head { flex-wrap: wrap; }
#backInbox { margin-bottom: 12px; }
@media (max-width: 760px) { .employee-inboxes { grid-template-columns: 1fr; } }

@media (max-width: 1050px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 16px 12px 24px;
  }

  .topbar {
    flex-direction: column;
  }

  .top-actions,
  .top-actions .button {
    width: 100%;
  }

  .top-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-actions .button { min-height: 44px; min-width: 0; }

  .metrics,
  .task-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .task-form label.wide,
  .form-actions {
    grid-column: span 1;
  }

  .form-actions .button {
    width: 100%;
  }

  .timeline-row {
    grid-template-columns: 1fr;
  }
}
