:root {
  --bg: #f3f7ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --border: #d9e3f2;
  --border-soft: #e7eef8;
  --text: #172033;
  --muted: #70809b;
  --primary: #2f67f6;
  --primary-soft: #ebf2ff;
  --shadow: 0 18px 40px rgba(50, 84, 155, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(47, 103, 246, 0.16), transparent 28%),
    linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
}

.app-shell {
  max-width: 1760px;
  margin: 0 auto;
  padding: 32px 32px 40px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

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

.brand-block h1 {
  margin: 0;
  font-size: 3rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.prototype-badge {
  display: inline-flex;
  align-items: center;
  height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--primary);
  background: linear-gradient(180deg, #f2f7ff 0%, #dfe9ff 100%);
  border: 1px solid #cfe0ff;
  font-size: 1.4rem;
  font-weight: 700;
}

.top-controls {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

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

.control-field select,
.primary-button {
  height: 68px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 24px rgba(69, 99, 164, 0.08);
  padding: 0 20px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.control-field select {
  min-width: 0;
}

.item-field { width: 360px; }
.compact-field { width: 220px; }

.primary-button {
  min-width: 180px;
  background: linear-gradient(180deg, #3b78ff 0%, #2c61ef 100%);
  border-color: #2d61ed;
  color: #fff;
  cursor: pointer;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(420px, 1fr);
  gap: 24px;
  align-items: start;
}

.card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(214, 225, 245, 0.95);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.table-card {
  padding: 18px 18px 12px;
}

.table-scroll {
  overflow: auto;
  border-radius: 22px;
  border: 1px solid var(--border-soft);
  background: var(--surface-strong);
}

.overview-table-wrap {
  overflow-x: hidden;
}

#item-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

#item-table col.col-item-overview { width: 31%; }
#item-table col.col-balance-overview { width: 20%; }
#item-table col.col-actual-overview { width: 18%; }
#item-table col.col-status-overview { width: 15%; }
#item-table col.col-action-overview { width: 8%; }

#item-table th,
#item-table td {
  padding: 18px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.98rem;
  vertical-align: middle;
  overflow: hidden;
}

#item-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbff;
  color: #2d3850;
  font-weight: 800;
  font-size: 1rem;
  white-space: nowrap;
}

#item-table thead th:first-child { border-top-left-radius: 18px; }
#item-table thead th:last-child { border-top-right-radius: 18px; }

#item-table tbody tr:last-child td {
  border-bottom: none;
}

#item-table tbody tr.selected-row {
  background: linear-gradient(90deg, rgba(47, 103, 246, 0.03), rgba(47, 103, 246, 0.08));
}

#item-table tbody tr:hover {
  background: rgba(244, 248, 255, 0.88);
}

.item-overview-cell {
  padding-right: 18px !important;
}

.item-overview-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.item-overview-main strong {
  font-size: 1.28rem;
  line-height: 1.28;
  color: #22304b;
  white-space: normal;
  overflow-wrap: anywhere;
}

.item-code {
  display: inline-block;
  font-weight: 800;
  color: #6e7f9d;
  font-size: 0.86rem;
  line-height: 1.4;
  letter-spacing: 0.03em;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.item-subtext {
  display: inline-block;
  margin-top: 10px;
  color: #8191ab;
  font-size: 0.88rem;
  white-space: nowrap;
}

.balance-col,
.balance-value {
  color: var(--primary);
  font-weight: 900;
}

.balance-value {
  font-size: 1.95rem;
  letter-spacing: -0.04em;
  text-shadow: 0 6px 16px rgba(47, 103, 246, 0.12);
}

.actual-value {
  font-size: 1.36rem;
  font-weight: 800;
  color: #22304b;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.98rem;
  font-weight: 900;
  border: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.status-normal {
  background: linear-gradient(180deg, #edf9f2 0%, #dff4e7 100%);
  color: #26924d;
  border-color: #d3eadc;
}

.status-pending {
  background: linear-gradient(180deg, #fff7eb 0%, #ffefd7 100%);
  color: #d68b1f;
  border-color: #f3dec0;
}

.status-alert {
  background: linear-gradient(180deg, #ffefee 0%, #ffe3e1 100%);
  color: #d14f47;
  border-color: #f2d0cd;
}

.select-row-btn {
  width: 52px;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  color: #2c3a52;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(98, 122, 171, 0.08);
}

.select-row-btn:hover,
.select-row-btn.is-active {
  color: var(--primary);
  border-color: #bfd2ff;
  background: #f6f9ff;
}

.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 6px 4px;
}


.table-summary {
  color: #56647e;
  font-size: 1.05rem;
  font-weight: 600;
}

.insight-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.trend-card {
  padding: 28px 28px 24px;
}

.section-header h2 {
  margin: 0 0 16px;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.selected-item-banner {
  padding: 18px 22px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
  border: 1px solid #dbe7ff;
  color: #2d3850;
  font-size: 1.1rem;
  font-weight: 700;
}

.selected-item-banner strong {
  color: var(--primary);
  font-size: 1.15rem;
  margin-right: 10px;
}

.chart-wrap {
  margin-top: 18px;
  border-radius: 22px;
  border: 1px solid var(--border-soft);
  background: #fff;
  padding: 18px 18px 10px;
  min-height: 420px;
}

#trend-chart {
  width: 100%;
  height: 360px !important;
}

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

.warehouse-card {
  padding: 24px 28px;
}

.warehouse-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 22px;
}

.metric-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 12px;
  margin: 0;
}

.metric-list dt {
  color: #2e3a53;
  font-size: 1rem;
  font-weight: 700;
}

.metric-list dd {
  margin: 0;
  text-align: right;
  color: #27334b;
  font-size: 1rem;
  font-weight: 700;
}

.metric-list dt.accent,
.metric-list dd.accent {
  color: var(--primary);
  font-weight: 900;
  font-size: 1.15rem;
}

.metric-list dt.divider,
.metric-list dd.divider {
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

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

  .brand-block h1 {
    font-size: 2.5rem;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 20px;
  }

  .app-header,
  .top-controls {
    align-items: stretch;
  }

  .app-header,
  .top-controls,
  .brand-block {
    flex-direction: column;
  }

  .item-field,
  .compact-field,
  .primary-button {
    width: 100%;
  }

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

  .brand-block h1 {
    font-size: 2.1rem;
  }

  #item-table th,
  #item-table td {
    padding: 14px 12px;
  }

  #item-table col.col-item-overview { width: 33%; }
  #item-table col.col-balance-overview { width: 20%; }
  #item-table col.col-actual-overview { width: 17%; }
  #item-table col.col-status-overview { width: 14%; }
  #item-table col.col-action-overview { width: 8%; }
}
