:root {
  --bg: #f3f6f5;
  --panel: #ffffff;
  --ink: #1f2d2b;
  --muted: #61706f;
  --brand: #0f9d85;
  --brand-dark: #0a7b68;
  --line: #dfe8e5;
  --warn: #c44848;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 20% -10%, #daf1eb 0%, #f3f6f5 52%),
    radial-gradient(circle at 85% 110%, #dceff6 0%, #f3f6f5 45%);
}

.bg-shape {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(
      120deg,
      rgba(15, 157, 133, 0.06) 0%,
      rgba(15, 157, 133, 0) 32%
    ),
    linear-gradient(300deg, rgba(66, 125, 169, 0.06) 0%, rgba(66, 125, 169, 0) 26%);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(820px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 20px rgba(46, 79, 72, 0.12);
}

.auth-card h1 {
  margin: 0 0 8px;
}

.auth-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr;
  max-width: 420px;
  gap: 12px;
}

.auth-form {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
  background: #fbfdfc;
}

.auth-links {
  display: flex;
  gap: 14px;
  margin-top: 4px;
}

.auth-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 27, 25, 0.42);
  z-index: 50;
  padding: 16px;
}

.auth-modal.active {
  display: flex;
}

.auth-modal-card {
  width: min(460px, 100%);
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(28, 58, 53, 0.2);
  padding: 14px;
}

.auth-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.auth-modal-head h3 {
  margin: 0;
}

.app-shell.app-hidden {
  display: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: 26px 18px;
  background: linear-gradient(180deg, #0f8f78, #0d6f5e);
  color: #fff;
}

.sidebar h1 {
  margin: 0 0 20px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
}

.user-badge {
  margin: 0 0 12px;
  font-size: 13px;
  color: #d8f2ec;
}

.logout-btn {
  margin-top: 8px;
  width: 100%;
}

.nav-btn {
  width: 100%;
  border: 0;
  border-radius: 10px;
  margin-bottom: 10px;
  padding: 12px;
  color: #e5f9f4;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateX(2px);
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.24);
  font-weight: 700;
}

.content {
  padding: 20px;
}

.tab {
  display: none;
  animation: rise 0.35s ease;
}

.tab.active {
  display: block;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 6px 16px rgba(46, 79, 72, 0.06);
}

h2,
h3 {
  margin: 0 0 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  outline: none;
  color: var(--ink);
  background: #fff;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 157, 133, 0.14);
}

.actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.span-2 {
  grid-column: span 2;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: #e8f2f0;
  color: #28514a;
}

.btn.primary {
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  color: #fff;
}

.btn.ghost {
  border: 1px solid var(--line);
  background: #fff;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #edf2f0;
  text-align: left;
  font-size: 13px;
}

th {
  color: #4f6461;
  background: #f8fbfa;
}

.link-btn {
  border: 0;
  background: transparent;
  color: #178a74;
  cursor: pointer;
}

.link-btn.danger {
  color: var(--warn);
}

.product-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid #d8e7e3;
  object-fit: cover;
  display: block;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.top-gap {
  margin-top: 10px;
}

.compact-panel {
  padding-top: 12px;
  padding-bottom: 12px;
}

.search-row input {
  flex: 1;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.timeline {
  margin-top: 14px;
  border-left: 2px solid #d8ebe6;
  padding-left: 16px;
}

.stage-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-pill {
  border: 1px solid #bee4db;
  background: #edf8f5;
  color: #137b67;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.stage-check {
  display: grid;
  gap: 12px;
  margin-top: 8px;
  margin-bottom: 14px;
  border-left: 2px solid #cfe4df;
  padding-left: 16px;
}

.stage-check-item {
  position: relative;
}

.stage-check-item::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  left: -23px;
  top: 18px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #cfe4df;
}

.stage-check-item.done::before {
  background: var(--brand);
}

.stage-check-item.missing::before {
  background: #d8c9c9;
}

.stage-check-card {
  border: 1px solid #c9ddd8;
  border-radius: 20px;
  padding: 14px 18px;
  background: #f5fbf9;
}

.stage-check-item.missing .stage-check-card {
  border-color: #ead0d0;
  background: #fcf8f8;
}

.stage-check-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stage-check-head strong {
  font-size: 22px;
  line-height: 1.25;
}

.stage-state {
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.stage-check-item.missing .stage-state {
  color: #b16464;
}

.stage-check-actions {
  margin-top: 8px;
  display: flex;
  gap: 14px;
}

.stage-check-actions .link-btn {
  font-size: 18px;
}

.order-detail-row.collapsed {
  display: none;
}

.order-detail-cell {
  background: #f8fbfa;
  padding: 0;
}

.order-inline-progress {
  padding: 12px 10px 14px;
}

.inline-stage-check {
  margin-bottom: 0;
}

.inline-stage-check .stage-check-head strong {
  font-size: 28px;
}

.timeline-item {
  position: relative;
  margin-bottom: 12px;
}

.timeline-item .dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand);
  left: -23px;
  top: 14px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #d8ebe6;
}

.timeline-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.timeline-time {
  color: var(--muted);
  font-size: 12px;
}

.timeline-actions {
  margin-top: 6px;
  display: flex;
  gap: 10px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: auto;
    overflow: visible;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    align-items: center;
  }

  .sidebar h1 {
    grid-column: span 3;
    margin-bottom: 8px;
  }

  .content {
    padding: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
