:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #1f2a37;
  --muted: #637387;
  --accent: #0d6efd;
  --accent-2: #f97316;
  --border: #dde5ef;
  --radius: 16px;
  --radius-sm: 12px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: linear-gradient(160deg, #eef3f9 0%, #f7fafc 52%, #f2f7ff 100%);
  font-family: "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  min-height: 100vh;
  position: relative;
}

.aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(55% 40% at 10% 10%, rgba(13, 110, 253, 0.12), transparent 60%),
    radial-gradient(45% 35% at 90% 0%, rgba(249, 115, 22, 0.1), transparent 70%);
}

.container {
  width: min(1120px, 92vw);
  margin: 14px auto 10px;
  position: relative;
  z-index: 1;
}

.hero {
  margin-bottom: var(--space-2);
  animation: rise 360ms ease-out;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero h1 {
  margin: 0 0 var(--space-1);
  font-size: clamp(1.15rem, 2.4vw, 1.6rem);
  font-weight: 600;
}

.hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.92rem;
}

.card {
  background: color-mix(in oklab, var(--surface) 90%, white 10%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.06);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}

.controls {
  animation: rise 420ms ease-out;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  align-items: start;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.manual-card h2 {
  margin: 0;
  font-size: 1rem;
}

.completion-container {
  width: min(1360px, 95vw);
}

.manual-card {
  display: flex;
  flex-direction: column;
  min-height: clamp(560px, calc(100vh - 180px), 960px);
}

.manual-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.manual-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 10px;
}

.manual-filters label {
  margin-bottom: 0;
}

.manual-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #334155;
}

.manual-check input {
  width: auto;
}

.manual-summary {
  color: var(--muted);
  font-size: 0.86rem;
}

.manual-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: none;
  min-height: clamp(360px, calc(100vh - 350px), 760px);
  background: #fff;
}

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

.manual-table th,
.manual-table td {
  border-bottom: 1px solid #edf2f8;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

.manual-table th {
  position: sticky;
  top: 0;
  background: #f8fbff;
  z-index: 1;
  color: #334155;
}

.manual-row-missing {
  background: #fff5f5;
}

.manual-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.76rem;
  border: 1px solid transparent;
}

.manual-badge-missing {
  color: #b91c1c;
  background: #fee2e2;
  border-color: #fecaca;
}

.manual-badge-ok {
  color: #0f766e;
  background: #ccfbf1;
  border-color: #99f6e4;
}

.manual-source-manual {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #bfdbfe;
}

.manual-source-auto {
  color: #475569;
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.manual-input {
  width: 120px;
  padding: 5px 8px;
  margin-right: 6px;
}

.manual-confirm-btn {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.8rem;
}

.manual-confirm-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.completion-status {
  margin-top: 8px;
}

.controls .panel {
  min-width: 0;
}

.controls form {
  display: block;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-3);
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1rem;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
}

button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #136ef6, #277fff);
  color: #fff;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
  font-size: 0.92rem;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

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

.ghost-btn {
  background: #fff;
  color: #0d6efd;
  border: 1px solid #bdd3fa;
}

.link-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.stock-list {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  max-height: 148px;
  overflow: auto;
}

.stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 0.9rem;
}

.stock-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
}

.stock-check input {
  width: auto;
}

.stock-delete-btn {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #f1c0c0;
  padding: 4px 10px;
}

.stock-delete-btn:hover {
  filter: none;
  background: #fff5f5;
}

.hint {
  color: var(--muted);
  margin: 6px 0 0;
  font-size: 0.82rem;
}

.chart-wrap {
  animation: rise 480ms ease-out;
  background: #fff;
  min-height: 0;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: clamp(280px, calc(100vh - 340px), 500px);
}

#price-chart {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.range-bar {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.range-nav {
  position: relative;
  margin-top: 10px;
  height: 84px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f7fd 100%);
  overflow: hidden;
}

#range-overview {
  width: 100%;
  height: 100%;
  display: block;
}

.range-overlay {
  position: absolute;
  inset: 0;
  user-select: none;
  touch-action: none;
}

.range-mask {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.56);
  border-right: 1px solid rgba(99, 115, 135, 0.25);
  pointer-events: none;
}

.range-mask.right {
  border-right: 0;
  border-left: 1px solid rgba(99, 115, 135, 0.25);
}

.range-window {
  position: absolute;
  top: 0;
  bottom: 0;
  border: 2px solid #0d6efd;
  background: rgba(13, 110, 253, 0.08);
  cursor: grab;
}

.range-window:active {
  cursor: grabbing;
}

.range-grip {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14px;
  background: rgba(255, 255, 255, 0.88);
}

.range-grip::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 24px;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.35);
  box-shadow: -3px 0 0 rgba(15, 23, 42, 0.25), 3px 0 0 rgba(15, 23, 42, 0.25);
}

.range-grip.left {
  left: -1px;
  border-right: 1px solid rgba(13, 110, 253, 0.35);
  cursor: ew-resize;
}

.range-grip.right {
  right: -1px;
  border-left: 1px solid rgba(13, 110, 253, 0.35);
  cursor: ew-resize;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.range-inputs input {
  width: 132px;
  padding: 6px 8px;
}

.range-sep {
  color: var(--muted);
}

.range-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-btn {
  background: #fff;
  color: #334155;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

.range-btn:hover {
  background: #f7fbff;
  filter: none;
}

.status {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 6px;
}

.footer {
  width: min(1120px, 92vw);
  margin: 0 auto 10px;
  display: flex;
  justify-content: space-between;
  color: #7b8a9f;
  font-size: 0.8rem;
  position: relative;
  z-index: 1;
}

.login-container {
  width: min(460px, 92vw);
  margin: 10vh auto 0;
  position: relative;
  z-index: 1;
}

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.06);
  padding: 28px;
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-card p {
  margin: 0 0 16px;
  color: var(--muted);
}

.login-error {
  color: #b91c1c !important;
}

.login-form {
  display: grid;
  gap: 10px;
}

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

@media (max-width: 700px) {
  .container {
    width: min(1140px, 96vw);
  }

  .hero-top {
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .manual-table-wrap {
    min-height: 52vh;
  }

  .manual-table th,
  .manual-table td {
    padding: 7px 8px;
  }

  .card {
    padding: var(--space-2);
  }

  .range-inputs input {
    width: 124px;
  }

  #price-chart {
    height: 100% !important;
  }

  .chart-canvas-wrap {
    height: clamp(250px, 44vh, 340px);
  }

  .range-nav {
    height: 74px;
  }

  .footer {
    flex-direction: column;
    gap: 6px;
  }
}
