:root {
  color-scheme: light;
  --ink: #17201f;
  --muted: #61706d;
  --line: #d8e0dd;
  --soft: #eef4f1;
  --paper: #fbfcfb;
  --panel: #ffffff;
  --accent: #0e7c67;
  --accent-strong: #075f50;
  --gold: #b7791f;
  --danger: #bb3e3e;
  --shadow: 0 10px 30px rgba(23, 32, 31, 0.08);
}

body[data-page="dashboard"],
body[data-page="login"],
body[data-page="portal"] {
  min-height: 100vh;
  color-scheme: dark;
  --ink: #f3f7ff;
  --muted: #93a7c8;
  --line: rgba(142, 165, 205, 0.22);
  --soft: #0c1a2e;
  --paper: #06101f;
  --panel: #0d1c31;
  --accent: #e23748;
  --accent-strong: #ff6876;
  --gold: #f3b84f;
  --danger: #ff6876;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.mobile-shell {
  width: min(560px, calc(100% - 22px));
  padding-bottom: 150px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
}

.owner-topbar {
  padding-top: 18px;
}

.topbar h1,
.section-head h2 {
  margin: 0;
  line-height: 1.16;
}

.topbar h1 {
  font-size: 30px;
}

.section-head h2 {
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ghost-link,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.nav-actions,
.control-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.notice,
.status-line,
.insight-band,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
}

.notice,
.status-line {
  padding: 12px 14px;
}

.control-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 12px;
}

.entry-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.zero-outbound-reason[hidden] {
  display: none;
}

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

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.compact-notice {
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

body[data-page="dashboard"] .field input,
body[data-page="login"] .field input,
body[data-page="portal"] .field input {
  background: #081527;
}

.compact-field input {
  min-height: 42px;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(60, 195, 159, 0.15);
}

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

.order-items-section {
  display: grid;
  gap: 12px;
  padding-top: 6px;
}

.form-section-head,
.order-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-section-head span,
.order-item-head span {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.form-section-head h2,
.order-item-head h3 {
  margin: 2px 0 0;
  font-size: 18px;
}

.entry-action-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.entry-add-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.entry-add-panel > div:first-child {
  display: grid;
  gap: 2px;
}

.entry-add-panel span {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.entry-add-panel strong {
  color: var(--ink);
  font-size: 15px;
}

.item-head-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.item-type-button {
  min-height: 36px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  border-radius: 7px;
  background: var(--soft);
  color: var(--accent-strong);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 800;
}

.order-items {
  display: grid;
  gap: 12px;
}

.order-item {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.secondary-button,
.remove-item-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 13px;
  font-weight: 750;
  cursor: pointer;
}

.compact-button {
  white-space: nowrap;
}

.accent-button {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.remove-item-button {
  min-height: 34px;
  color: var(--danger);
}

.standard-cost-help {
  display: block;
  padding: 9px 10px;
  border-left: 3px solid var(--accent);
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.segmented-control button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.segmented-control button.active {
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: 0 2px 10px rgba(23, 32, 31, 0.08);
}

.film-materials {
  display: grid;
  gap: 18px;
}

.film-material {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.film-material-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.film-material-head span {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.film-material-head h4 {
  margin: 2px 0 0;
  font-size: 16px;
}

.usage-presets {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.usage-preset-button {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.usage-preset-button.clear {
  color: var(--muted);
}

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

.part-option {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.part-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--soft);
}

.part-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.part-option span,
.part-option small {
  display: block;
  min-width: 0;
}

.part-option span {
  font-size: 13px;
  font-weight: 750;
}

.part-option small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.usage-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.usage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.usage-row span,
.usage-row small {
  display: block;
}

.usage-row b {
  font-size: 13px;
}

.usage-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.usage-row input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
  text-align: right;
}

.usage-empty {
  padding: 12px 0;
  color: var(--muted);
  font-size: 12px;
}

.add-material-button {
  width: 100%;
}

.film-project-summary {
  border-left-color: var(--gold);
}

.sticky-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom));
  background: rgba(251, 252, 251, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.order-total-summary {
  width: min(560px, calc(100% - 22px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 10px;
}

.order-total-summary span,
.order-total-summary small {
  display: block;
}

.order-total-summary span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.order-total-summary small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.order-total-summary strong {
  color: var(--accent-strong);
  font-size: 26px;
  line-height: 1;
}

.primary-button {
  width: min(560px, calc(100% - 22px));
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #07110f;
  font-weight: 800;
  cursor: pointer;
}

.inline-button {
  width: auto;
  min-height: 42px;
  padding: 0 16px;
  margin: 0;
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.kpi-card,
.board-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi-card {
  min-height: 124px;
  padding: 16px;
}

.kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.kpi-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.kpi-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.35;
}

.kpi-card.positive strong {
  color: var(--accent-strong);
}

.kpi-card.negative strong {
  color: var(--danger);
}

.insight-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
}

.insight-item {
  min-width: 0;
  line-height: 1.45;
}

.insight-item b {
  display: block;
  color: var(--ink);
  margin-bottom: 5px;
}

.board-section {
  margin-top: 16px;
  padding: 16px;
}

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

.section-meta {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.chart-wrap {
  overflow-x: auto;
  padding-bottom: 6px;
}

.monthly-chart {
  display: grid;
  gap: 10px;
  min-width: 720px;
}

.month-row {
  display: grid;
  grid-template-columns: 82px 1fr 190px;
  gap: 12px;
  align-items: center;
}

.month-label {
  color: var(--muted);
  font-weight: 800;
}

.bar-track,
.mini-track {
  border-radius: 8px;
  background: color-mix(in srgb, var(--soft) 75%, #000 25%);
  overflow: hidden;
  position: relative;
}

.bar-track {
  height: 36px;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent), #ff7d88);
}

.month-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.month-meta b {
  display: block;
  color: var(--ink);
}

.month-meta em {
  font-style: normal;
}

.table-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.compact-table table {
  min-width: 620px;
}

.record-table table {
  min-width: 1120px;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  white-space: nowrap;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.product-cell {
  max-width: 320px;
  white-space: normal;
  line-height: 1.45;
}

.split-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.wide-left {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
}

.leader-list,
.recent-list,
.cost-list {
  display: grid;
  gap: 10px;
}

.leader-row,
.recent-row,
.cost-row {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.leader-top,
.recent-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.leader-name,
.recent-name {
  font-weight: 800;
}

.leader-detail,
.recent-detail {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.mini-track {
  height: 8px;
}

.mini-track span {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 8px;
  background: var(--gold);
}

.login-shell {
  min-height: 100vh;
  width: min(460px, calc(100% - 28px));
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.login-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel h1 {
  margin: 0;
  font-size: 28px;
}

.login-copy {
  margin: 10px 0 18px;
  color: var(--muted);
}

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

.login-button {
  width: 100%;
}

.login-status {
  margin-top: 14px;
}

.login-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-back:hover,
.login-back:focus-visible {
  color: var(--ink);
}

.login-back svg {
  width: 17px;
  height: 17px;
}

.portal-shell {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.portal-header h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
}

.portal-logout {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: 0 0 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1c31;
  color: var(--muted);
  cursor: pointer;
}

.portal-logout:hover,
.portal-logout:focus-visible {
  border-color: var(--accent);
  color: var(--ink);
}

.portal-logout:disabled {
  cursor: wait;
  opacity: 0.6;
}

.portal-logout svg,
.project-icon svg,
.project-action svg {
  width: 20px;
  height: 20px;
}

.portal-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 18px;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: #0a182a;
}

.portal-status-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--accent-strong);
}

.portal-status-icon svg {
  width: 22px;
  height: 22px;
}

.portal-status div {
  display: grid;
  gap: 3px;
}

.portal-status small {
  color: var(--muted);
}

.portal-projects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.portal-icp {
  margin-top: 28px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.portal-icp a {
  color: inherit;
  font-weight: 600;
}

.portal-icp a:hover,
.portal-icp a:focus-visible {
  color: var(--ink);
}

.project-entry {
  position: relative;
  display: flex;
  min-height: 250px;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1c31;
  box-shadow: var(--shadow);
}

.active-project {
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.active-project:hover,
.active-project:focus-visible {
  border-color: var(--accent);
  background: #102139;
  transform: translateY(-2px);
  outline: none;
}

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

.project-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(226, 55, 72, 0.42);
  border-radius: 8px;
  background: rgba(226, 55, 72, 0.1);
  color: var(--accent-strong);
}

.project-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.project-state svg {
  width: 14px;
  height: 14px;
}

.project-state.online {
  color: #80d7bd;
}

.project-state.waiting {
  color: var(--muted);
}

.project-copy {
  max-width: calc(100% - 54px);
}

.project-copy p {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.project-copy h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1.25;
}

.project-copy span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.project-action {
  position: absolute;
  right: 22px;
  bottom: 22px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
}

.project-action.locked {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.future-project {
  box-shadow: none;
  opacity: 0.68;
}

.future-project .project-icon {
  border-color: var(--line);
  background: #0a1728;
  color: var(--muted);
}

.portal-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: none;
  max-width: min(380px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #0d1c31;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.portal-toast.visible {
  display: block;
}

.empty-state {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 14px 0;
}

.good {
  color: var(--accent-strong);
}

.bad {
  color: var(--danger);
}

@media (max-width: 1040px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-panel,
  .insight-band,
  .split-section,
  .wide-left {
    grid-template-columns: 1fr;
  }

  .control-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .portal-shell {
    width: min(100% - 24px, 560px);
    padding: 28px 0 40px;
  }

  .portal-header h1 {
    font-size: 26px;
  }

  .portal-projects {
    grid-template-columns: 1fr;
  }

  .project-entry {
    min-height: 210px;
    padding: 18px;
  }

  .project-action {
    right: 18px;
    bottom: 18px;
  }

  .dashboard-shell {
    width: min(100% - 22px, 680px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 25px;
  }

  .form-section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .entry-action-group {
    width: 100%;
    justify-content: stretch;
  }

  .entry-action-group button {
    flex: 1 1 0;
  }

  .entry-add-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .item-head-actions {
    align-items: stretch;
  }

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

  .ghost-link,
  .icon-button,
  .inline-button {
    min-height: 38px;
    padding: 0 10px;
  }
}
