:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --text: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --brand: #111827;
  --brand-soft: #f2f4f7;
  --accent: #0f766e;
  --accent-soft: #dff7f2;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Source Han Sans SC", "PingFang SC", "Noto Sans SC", sans-serif;
  background: linear-gradient(155deg, #eef2ff 0%, #f8fafc 55%, #effaf4 100%);
}

.layout {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 248px;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand strong {
  display: block;
  letter-spacing: 0.02em;
}

.brand p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin: 0 8px 12px;
  background: #fafafa;
}

.auth-user {
  font-size: 12px;
  color: #344054;
  margin-bottom: 8px;
  word-break: break-all;
}

.logout-btn {
  width: 100%;
  font-size: 12px;
  padding: 8px;
  background: #475467;
}

.menu {
  display: grid;
  gap: 8px;
}

.menu-btn {
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.menu-btn:hover {
  background: var(--brand-soft);
  color: var(--text);
}

.menu-btn.active {
  background: var(--brand);
  color: #fff;
}

.main {
  flex: 1;
  padding: 26px;
}

.tab {
  display: none;
  animation: enter 0.25s ease;
}

.tab.active {
  display: block;
}

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

.section-head {
  margin-bottom: 16px;
}

.section-head h1 {
  margin: 0;
  font-size: 28px;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.kpi-grid,
.panel-grid {
  display: grid;
  gap: 14px;
}

.perspective-grid {
  display: grid;
  gap: 10px;
}

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

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

.perspective-head strong {
  font-size: 14px;
}

.tag {
  background: #e7f8f4;
  color: #0f766e;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

.share-table {
  width: 100%;
  border-collapse: collapse;
}

.share-table td {
  border-bottom: 1px dashed #e4e7ec;
  padding: 6px 4px;
  font-size: 12px;
}

.mini-bar {
  width: 120px;
  height: 6px;
  background: #ecf0f3;
  border-radius: 999px;
  overflow: hidden;
}

.mini-bar > span {
  display: block;
  height: 100%;
  background: #111827;
}

.trend-list {
  display: grid;
  gap: 8px;
}

.trend-item {
  display: grid;
  grid-template-columns: 72px 1fr 48px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.trend-track {
  height: 8px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}

.trend-track > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #111827);
}

.extra-list {
  display: grid;
  gap: 8px;
}

.extra-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.extra-item strong {
  display: block;
  font-size: 13px;
  margin-bottom: 5px;
}

.ok-note {
  color: #067647;
  font-weight: 600;
  margin: 0;
}

.warn-note {
  color: #b42318;
  font-weight: 600;
  margin: 0 0 10px;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.warn-pill {
  background: #fee4e2;
  color: #912018;
  border: 1px solid #fecdca;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.kpi-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
  padding: 14px;
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
}

.panel-head.split {
  flex-wrap: wrap;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: linear-gradient(160deg, #fff 0%, #f9fafb 100%);
}

.kpi .label {
  font-size: 13px;
  color: var(--muted);
}

.kpi .value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
}

.list-stack {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
}

.insight-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  background: #fff;
}

.insight-row:hover {
  border-color: #cbd5e1;
}

.insight-row.active {
  border-color: #1f2937;
  background: #111827;
  color: #fff;
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.bar {
  width: 100%;
  background: #edf0f2;
  border-radius: 999px;
  overflow: hidden;
  height: 7px;
}

.bar > span {
  display: block;
  height: 100%;
  background: #111827;
}

.insight-row.active .bar {
  background: #344054;
}

.insight-row.active .bar > span {
  background: #fff;
}

.sub-list {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  padding-top: 8px;
  display: grid;
  gap: 5px;
  font-size: 12px;
}

.sub-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

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

input,
select,
button {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: 2px solid #99f6e4;
  outline-offset: 1px;
}

button {
  border: none;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  opacity: 0.95;
}

.link-btn {
  background: transparent;
  color: #0f766e;
  padding: 2px 4px;
  font-size: 12px;
}

.mode-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.mode-btn {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.mode-btn.active {
  background: var(--brand);
  color: #fff;
}

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

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

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

.week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.week-nav span {
  min-width: 150px;
  text-align: center;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 10px 8px;
  font-size: 13px;
  white-space: nowrap;
}

.grid-table td,
.grid-table th {
  text-align: center;
}

.grid-table select,
.grid-table input {
  min-width: 96px;
  padding: 7px;
}

.remove-row {
  background: var(--danger);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.delete-entity {
  background: #b42318;
  border: none;
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.day-total {
  font-weight: 700;
  background: #f8fafc;
}

.day-total.over {
  background: #fee4e2;
  color: #912018;
}

.batch-warning {
  margin-top: 10px;
  font-size: 13px;
  color: #667085;
}

.batch-warning.alert {
  color: #912018;
  font-weight: 600;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  border-radius: 9px;
  padding: 9px 12px;
  opacity: 0;
  transition: opacity 0.2s;
}

.toast.show {
  opacity: 1;
}

.auth-gate {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: grid;
  place-items: center;
  z-index: 50;
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  width: min(90vw, 420px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e4e7ec;
  box-shadow: 0 20px 40px rgba(16, 24, 40, 0.2);
  padding: 24px;
}

.auth-card h2 {
  margin: 0 0 10px;
}

.auth-card p {
  margin: 0 0 16px;
  color: #667085;
  font-size: 14px;
}

.auth-login-btn {
  display: inline-block;
  background: #111827;
  color: #fff;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
}

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

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

@media (max-width: 840px) {
  .layout {
    display: block;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .main {
    padding: 14px;
  }

  .form-6,
  .form-3 {
    grid-template-columns: 1fr;
  }
}
