:root {
  color-scheme: dark;
  --bg: #11100e;
  --surface: #1b1a17;
  --surface-soft: #24221e;
  --ink: #f2eee5;
  --muted: #aaa397;
  --line: #39352e;
  --green: #b89a5d;
  --green-dark: #d0b06f;
  --blue: #8aa8b8;
  --amber: #d39a4a;
  --red: #d07066;
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.32);
}

.automation-import-form {
  display: grid;
  gap: 16px;
}

.automation-import-form textarea {
  min-height: 150px;
  line-height: 1.65;
}

.automation-candidate-list {
  display: grid;
  gap: 14px;
}

.automation-candidate {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.018);
}

.automation-candidate.pending {
  border-color: rgba(197, 157, 82, 0.45);
}

.automation-recognition-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.automation-recognition-grid > div {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 13px;
  background: #171614;
}

.automation-recognition-grid span,
.automation-operation-list > span {
  color: var(--muted);
  font-size: 13px;
}

.automation-recognition-grid strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.automation-operation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.automation-operation-list strong {
  padding: 6px 9px;
  border: 1px solid rgba(197, 157, 82, 0.32);
  border-radius: 4px;
  color: var(--green-dark);
  font-size: 13px;
}

.automation-warning {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid #c96c61;
  color: #e7a39b;
  background: rgba(201, 108, 97, 0.08);
}

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

@media (max-width: 560px) {
  .automation-recognition-grid {
    grid-template-columns: 1fr;
  }

  .automation-candidate {
    padding: 13px;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(184, 154, 93, 0.08), transparent 220px),
    var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #0f0e0c;
}

.login-screen.hidden {
  display: none;
}

.login-box {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
  padding: 0 0 10px;
  color: var(--ink);
}

.login-brand span {
  color: var(--muted);
}

.check-field {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.check-field input {
  width: auto;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: #0c0b0a;
  color: #f3f7f4;
  border-right: 1px solid #2f2b25;
}

.brand {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px 8px 22px;
}

.brand-logo-card {
  display: grid;
  width: 96px;
  min-width: 0;
  aspect-ratio: 73 / 40;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #f4f2ec;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.brand-logo-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-logo {
  width: min(260px, 100%);
  margin-bottom: 4px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #1f1d19;
  color: var(--green-dark);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 4px;
  color: #9d968a;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  color: #d8d0c2;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: #1f1c17;
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--green);
}

.nav .nav-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #d0b06f;
  font-size: 12px;
  font-weight: 800;
}

.main {
  min-width: 0;
  overflow-x: hidden;
  padding: 24px;
}

.topbar {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.role-switch {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.role-switch select {
  min-width: 168px;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #4a4337;
  background: #211f1b;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.sync-badge.offline {
  border-color: #60463a;
  background: #271d18;
  color: var(--amber);
}

.notice {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #5a4b32;
  background: #1f1b13;
  color: #d9c28c;
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
}

.metric {
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.panel-header h2,
.panel-header h3 {
  margin: 0;
}

.panel-body {
  min-width: 0;
  padding: 16px;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.form-section {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #4a4337;
  background: #171613;
}

.form-section strong {
  color: var(--ink);
}

.form-section span {
  color: var(--muted);
  font-size: 13px;
}

.project-entry-panel {
  border-color: #5a4b32;
}

.project-product-editor,
.project-product-list {
  display: grid;
  gap: 10px;
}

.project-product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid #4a4337;
  background: #171613;
}

.project-product-remove.icon-button {
  position: static;
  width: 40px;
  height: 40px;
  font-size: 22px;
}

.project-product-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.project-product-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-product-detail-list {
  display: grid;
  gap: 8px;
}

.project-product-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.project-product-detail-row span {
  color: var(--muted);
  font-size: 13px;
}

.embedded-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #4a4337;
  background: #171613;
}

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

.form-actions {
  display: flex;
  justify-content: flex-end;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  background: #171613;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 107, 85, 0.12);
}

.button {
  min-height: 40px;
  border: 1px solid var(--green);
  background: var(--green);
  color: #ffffff;
  padding: 9px 13px;
  font-weight: 700;
}

.button:hover {
  background: var(--green-dark);
}

.button.secondary {
  border-color: #4a4337;
  background: #24221e;
  color: var(--green-dark);
}

.button.secondary:hover {
  background: #2b2822;
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button.danger {
  border-color: #5b3432;
  background: #2a1716;
  color: var(--red);
}

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

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.filters input,
.filters select {
  width: min(260px, 100%);
}

.filter-search {
  min-height: 42px;
}

.table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.customer-list-layout {
  display: grid;
  gap: 14px;
}

.customer-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.customer-card {
  display: grid;
  gap: 10px;
  min-height: 176px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #1f1d19;
}

.customer-card-main {
  display: grid;
  gap: 5px;
}

.customer-name {
  max-width: 100%;
  text-align: left;
  font-size: 16px;
  line-height: 1.35;
}

.customer-card-main span,
.customer-card-meta {
  color: var(--muted);
  font-size: 13px;
}

.customer-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.compact-customer-table {
  display: none;
}

.mobile-project-cards {
  display: none;
}

.project-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #1f1d19;
}

.project-card > div:first-child {
  display: grid;
  gap: 4px;
}

.project-card > div:first-child span,
.project-card-meta {
  color: var(--muted);
  font-size: 13px;
}

.project-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.project-settings-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #171613;
}

.project-settings-panel strong,
.project-settings-panel span {
  display: block;
}

.column-toggle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px 14px;
}

.clamp-text {
  display: -webkit-box;
  max-width: 360px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

.compact-list-table {
  table-layout: fixed;
  min-width: 980px;
}

.compact-list-table th,
.compact-list-table td {
  padding: 8px 9px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-list-table th:first-child,
.project-list-table td:first-child,
.compact-list-table th:first-child,
.compact-list-table td:first-child {
  width: 220px;
}

.truncate-link {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

tr:hover td {
  background: #211f1b;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status.blue {
  background: #17232a;
  color: var(--blue);
}

.status.amber {
  background: #2d2113;
  color: var(--amber);
}

.status.red {
  background: #2b1716;
  color: var(--red);
}

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

.mini {
  color: var(--muted);
  font-size: 12px;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record {
  padding: 12px;
  border: 1px solid var(--line);
  background: #1f1d19;
}

.record strong,
.record span {
  display: block;
}

.record .meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.asset-grid.compact {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.asset {
  border: 1px solid var(--line);
  background: #1f1d19;
}

.asset img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-soft);
}

.asset-body {
  display: grid;
  gap: 6px;
  padding: 10px;
}

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

.template-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #1f1d19;
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 800;
}

.template-link span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.text-link {
  border: 0;
  background: transparent;
  color: var(--green-dark);
  padding: 0;
  text-align: left;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-link:hover {
  color: var(--blue);
}

.inline-link {
  width: fit-content;
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--green-dark);
  padding: 0;
  font-size: 13px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inline-link:hover {
  color: var(--blue);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.62);
}

.project-modal {
  width: min(1180px, 100%);
  max-width: calc(100vw - 44px);
  min-width: 0;
  max-height: min(900px, calc(100vh - 44px));
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
}

.modal-header {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 70px 18px 18px;
  border-bottom: 1px solid var(--line);
  background: #191814;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.modal-body {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-height: calc(100vh - 150px);
  overflow: auto;
  padding: 18px;
}

.project-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid #4a4337;
  background: #171613;
}

.project-hero strong,
.project-follow-summary strong {
  display: block;
  margin-top: 6px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.project-hero strong {
  font-size: 20px;
}

.project-follow-summary {
  padding: 14px;
  border: 1px solid #4a4337;
  background: #211f1b;
}

.project-follow-summary span {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.follow-timeline {
  display: grid;
  gap: 10px;
}

.follow-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #1f1d19;
}

.follow-item > div {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.follow-item strong {
  color: var(--green-dark);
}

.follow-item span {
  color: var(--muted);
  font-size: 12px;
}

.follow-item p {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.modal-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  overflow-x: auto;
}

.modal-section h3 {
  margin: 0;
}

.section-title-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
}

.form-modal-backdrop {
  z-index: 40;
}

.form-modal {
  width: min(820px, 100%);
}

.form-modal.narrow {
  width: min(680px, 100%);
}

.form-modal .panel {
  margin: 0;
  border: 0;
  background: transparent;
}

.form-modal .panel-header {
  display: flex;
  justify-content: flex-end;
  padding: 0 0 14px;
  border: 0;
  background: transparent;
}

.form-modal .panel-header h2 {
  display: none;
}

.form-modal .panel-body {
  padding: 0;
}

.drop-upload {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px dashed #6f624f;
  background: #171613;
}

.drop-upload.drag-over {
  border-color: var(--gold);
  background: #211f1b;
}

.drop-upload input[type="file"] {
  padding: 10px;
  border: 1px solid var(--line);
}

.icon-button {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  background: #211f1b;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.empty-state {
  padding: 26px;
  border: 1px dashed #5a5042;
  background: #171613;
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state span {
  margin-top: 6px;
  color: var(--muted);
}

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

.detail-item {
  padding: 10px;
  border: 1px solid var(--line);
  background: #1f1d19;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.detail-item.full {
  grid-column: 1 / -1;
}

.split-title {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  padding: 12px 14px;
  border: 1px solid #4a4337;
  background: #1b1a17;
  box-shadow: var(--shadow);
  color: var(--green-dark);
  font-weight: 700;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .column-toggle-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .grid.cols-2,
  .grid.cols-3 {
    grid-template-columns: 1fr;
  }

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

  .asset-grid.compact {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .main {
    max-width: 100vw;
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

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

  .notice {
    align-items: flex-start;
  }

  .mobile-project-cards {
    display: none;
  }

  .panel .mobile-project-cards + .filters + .table-wrap {
    display: block;
  }

  .customer-card-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .form-grid,
  .detail-grid,
  .asset-grid,
  .asset-grid.compact,
  .template-list {
    grid-template-columns: 1fr;
  }

  .project-product-row,
  .project-product-detail-row {
    grid-template-columns: 1fr;
  }

  .project-product-remove.icon-button {
    justify-self: end;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 0;
  }

  .project-modal {
    width: 100%;
    max-width: 100vw;
    max-height: 100vh;
  }

  .modal-body {
    max-height: calc(100vh - 82px);
    padding: 14px;
  }

  .project-hero {
    display: grid;
  }

  .column-toggle-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }
}

/* UI preview v2: refined matte business interface. */
:root {
  --bg: #0f0f0e;
  --surface: #191817;
  --surface-soft: #22211f;
  --surface-lift: #25231f;
  --ink: #f4f0e8;
  --muted: #a7a095;
  --line: #34312c;
  --line-soft: rgba(255, 255, 255, 0.075);
  --green: #b6924f;
  --green-dark: #d4b36e;
  --blue: #8fb0bd;
  --amber: #d19a4e;
  --red: #df776d;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  --radius: 8px;
}

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 260px),
    var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

.app-shell {
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  padding: 20px 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    #0b0b0a;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  grid-template-columns: 86px 1fr;
  gap: 12px;
  padding: 8px 8px 20px;
}

.brand-logo-card {
  width: 86px;
  border-color: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: #f5f2ed;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.3);
}

.brand strong {
  font-size: 15px;
}

.brand span {
  color: #8d867a;
  font-size: 12px;
}

.nav {
  gap: 5px;
}

.nav button {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #c7beb0;
}

.nav button:hover,
.nav button.active {
  border-color: rgba(212, 179, 110, 0.2);
  background: rgba(255, 255, 255, 0.055);
  color: #fff8ed;
  box-shadow: inset 3px 0 0 var(--green);
}

.nav .nav-icon {
  width: 24px;
  height: 24px;
  border-color: rgba(212, 179, 110, 0.18);
  border-radius: 6px;
  background: rgba(212, 179, 110, 0.06);
  color: var(--green-dark);
}

.main {
  padding: 26px;
}

.topbar {
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.eyebrow {
  margin-bottom: 7px;
  color: #8f887c;
}

h1 {
  font-size: 30px;
  font-weight: 800;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 14px;
}

.topbar-actions {
  gap: 8px;
}

.role-switch {
  min-width: 170px;
}

.sync-badge,
.notice,
.metric,
.panel,
.form-section,
.embedded-form,
.project-settings-panel,
.customer-card,
.project-card,
.record,
.asset,
.template-link,
.project-modal,
.project-hero,
.project-follow-summary,
.follow-item,
.detail-item,
.toast,
.empty-state,
.drop-upload {
  border-radius: var(--radius);
}

.sync-badge {
  min-height: 38px;
  border-color: rgba(212, 179, 110, 0.24);
  background: rgba(212, 179, 110, 0.075);
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-color: rgba(212, 179, 110, 0.22);
  background: rgba(212, 179, 110, 0.075);
  color: #d8c699;
}

.workspace {
  gap: 16px;
}

.metric {
  min-height: 98px;
  padding: 15px;
  border-color: var(--line-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0)), var(--surface);
}

.metric strong {
  margin-top: 8px;
  font-size: 26px;
}

.panel {
  border-color: var(--line-soft);
  background: rgba(25, 24, 23, 0.96);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

.panel-header {
  min-height: 58px;
  padding: 14px 16px;
  border-bottom-color: rgba(255, 255, 255, 0.065);
  background: rgba(255, 255, 255, 0.018);
}

.panel-body {
  padding: 16px;
}

label.field {
  gap: 7px;
  color: #aaa296;
  font-weight: 650;
}

input,
select,
textarea {
  min-height: 40px;
  border-color: #3b372f;
  border-radius: 7px;
  background: #121211;
  color: #f2eee7;
}

input::placeholder,
textarea::placeholder {
  color: #6f695f;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(212, 179, 110, 0.8);
  box-shadow: 0 0 0 3px rgba(212, 179, 110, 0.12);
}

.button {
  min-height: 38px;
  border-radius: 7px;
  border-color: #b6924f;
  background: #b6924f;
  color: #16120c;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.button:hover {
  background: #d4b36e;
}

.button.secondary {
  border-color: rgba(212, 179, 110, 0.22);
  background: rgba(255, 255, 255, 0.035);
  color: #d4b36e;
  box-shadow: none;
}

.button.secondary:hover {
  background: rgba(212, 179, 110, 0.12);
}

.button.ghost {
  color: #9b9388;
  box-shadow: none;
}

.button.ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #f2eee7;
}

.button.danger {
  color: #e58a82;
}

.filters {
  gap: 8px;
  margin-bottom: 14px;
}

.filters input,
.filters select {
  width: min(250px, 100%);
}

.table-wrap {
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: var(--radius);
  background: #151412;
}

table {
  min-width: 840px;
}

.compact-list-table {
  min-width: 1000px;
}

th,
td {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

th {
  background: #201e1a;
  color: #b7ad9e;
  font-size: 12px;
}

td {
  color: #eee8dd;
}

tr:hover td {
  background: rgba(212, 179, 110, 0.055);
}

.truncate-link,
.text-link,
.inline-link {
  color: #d9b66c;
}

.truncate-link:hover,
.text-link:hover,
.inline-link:hover {
  color: #95bfcd;
}

.tag,
.status {
  border-color: rgba(212, 179, 110, 0.18);
  border-radius: 999px;
  background: rgba(212, 179, 110, 0.08);
  color: #d7b672;
}

.status.blue {
  background: rgba(143, 176, 189, 0.12);
}

.status.amber {
  background: rgba(209, 154, 78, 0.12);
}

.status.red {
  background: rgba(223, 119, 109, 0.12);
}

.form-section,
.embedded-form,
.project-settings-panel,
.record,
.customer-card,
.project-card,
.asset,
.template-link,
.detail-item,
.follow-item,
.project-follow-summary {
  border-color: rgba(255, 255, 255, 0.07);
  background: #171614;
}

.customer-name,
.project-card .text-link {
  font-weight: 800;
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.project-modal {
  border-color: rgba(255, 255, 255, 0.11);
  background: #151412;
  box-shadow: 0 34px 86px rgba(0, 0, 0, 0.66);
}

.modal-header {
  padding: 18px 70px 18px 20px;
  border-bottom-color: rgba(255, 255, 255, 0.075);
  background: #10100f;
}

.modal-header h2 {
  font-size: 23px;
}

.modal-body {
  gap: 14px;
  padding: 18px;
}

.project-hero {
  border-color: rgba(212, 179, 110, 0.22);
  background: rgba(212, 179, 110, 0.055);
}

.project-hero strong {
  font-size: 21px;
}

.detail-grid {
  gap: 9px;
}

.detail-item strong {
  color: #f1ece3;
}

.follow-item strong {
  color: #d7b672;
}

.icon-button {
  border-color: rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: #22201d;
}

.icon-button:hover {
  background: #2b2823;
}

[data-project-detail-modal] {
  width: min(1080px, 100%);
}

.project-detail-header {
  padding: 22px 76px 20px 24px;
}

.project-modal-heading {
  min-width: 0;
  width: 100%;
}

.project-detail-header .eyebrow {
  margin-bottom: 8px;
}

.project-detail-header h2 {
  max-width: 860px;
  font-size: 25px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.project-header-meta {
  display: flex;
  gap: 12px 18px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.project-company {
  min-width: 0;
  color: #c8c0b4;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.project-header-meta .tag-list {
  flex: 0 0 auto;
  justify-content: flex-end;
}

[data-project-detail-modal] .modal-body {
  gap: 18px;
  padding: 20px 24px 24px;
}

.project-detail-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.project-detail-grid .detail-item {
  min-height: 76px;
  padding: 13px 14px;
  border-color: rgba(255, 255, 255, 0.075);
  background: #181715;
}

.project-detail-grid .detail-item span {
  margin-bottom: 6px;
  color: #948c81;
}

.project-detail-grid .detail-item strong {
  margin-top: 0;
  font-size: 14px;
  line-height: 1.55;
}

.project-detail-grid .project-detail-primary {
  border-color: rgba(212, 179, 110, 0.24);
  background: rgba(212, 179, 110, 0.055);
}

[data-project-detail-modal] .modal-section {
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.075);
}

[data-project-detail-modal] .section-title-row h3,
[data-project-detail-modal] .modal-section > h3 {
  font-size: 17px;
}

@media (max-width: 760px) {
  .project-detail-header {
    padding: 18px 68px 16px 16px;
  }

  .project-detail-header h2 {
    font-size: 21px;
  }

  .project-header-meta {
    display: grid;
    justify-content: stretch;
    margin-top: 12px;
  }

  .project-header-meta .tag-list {
    justify-content: flex-start;
  }

  [data-project-detail-modal] .modal-body {
    padding: 14px;
  }

  .project-detail-grid {
    grid-template-columns: 1fr;
  }
}

.drop-upload {
  border-color: rgba(212, 179, 110, 0.34);
  background: rgba(212, 179, 110, 0.045);
}

.empty-state {
  border-color: rgba(212, 179, 110, 0.24);
  background: rgba(212, 179, 110, 0.04);
}

.login-screen {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0)),
    #0e0d0c;
}

.login-box {
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #181715;
}

.login-logo {
  width: min(240px, 100%);
}

@media (max-width: 1180px) {
  .main {
    padding: 22px;
  }
}

@media (max-width: 760px) {
  .sidebar {
    padding: 14px;
  }

  .brand {
    grid-template-columns: 76px 1fr;
  }

  .brand-logo-card {
    width: 76px;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    gap: 12px;
    align-items: stretch;
  }

  .topbar-actions {
    gap: 7px;
  }

  .role-switch,
  .topbar-actions .button,
  .sync-badge {
    flex: 1 1 150px;
  }

  h1 {
    font-size: 24px;
  }

  .panel-header,
  .panel-body {
    padding: 13px;
  }

  .table-wrap {
    border-radius: 7px;
  }
}

/* V2 finance automation preview */
.automation-hero {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid rgba(208, 176, 111, 0.34);
  border-radius: 8px;
  background: #181714;
}

.automation-hero h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.automation-hero p:last-child {
  max-width: 820px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.automation-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.automation-status-card {
  display: grid;
  min-height: 124px;
  align-content: center;
  gap: 7px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171614;
}

.automation-status-card.ready {
  border-color: rgba(98, 174, 132, 0.5);
  box-shadow: inset 3px 0 0 #62ae84;
}

.automation-status-card.waiting {
  border-color: rgba(208, 176, 111, 0.28);
  box-shadow: inset 3px 0 0 rgba(208, 176, 111, 0.65);
}

.automation-status-card span,
.automation-status-card small {
  color: var(--muted);
}

.automation-status-card strong {
  font-size: 18px;
}

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

.finance-metric-grid .metric strong,
.project-finance-grid .metric strong {
  font-size: clamp(18px, 2vw, 26px);
  overflow-wrap: anywhere;
}

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

.sync-preview-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151412;
}

.sync-preview-card.pending {
  border-color: rgba(208, 176, 111, 0.42);
}

.sync-preview-card.approved {
  border-color: rgba(98, 174, 132, 0.4);
}

.sync-preview-card.rejected {
  opacity: 0.62;
}

.sync-preview-head,
.sync-preview-foot {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.sync-preview-head > div {
  display: grid;
  gap: 4px;
}

.sync-source,
.sync-preview-foot > span {
  color: var(--muted);
  font-size: 12px;
}

.sync-original {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
}

.sync-detected-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.sync-detected-grid div {
  min-width: 0;
  padding: 10px;
  border-left: 2px solid rgba(208, 176, 111, 0.42);
  background: #1d1b18;
}

.sync-detected-grid dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.sync-detected-grid dd {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-table th,
.finance-table td {
  white-space: nowrap;
}

.finance-table td:first-child,
.compact-finance-table td:nth-child(2),
.compact-finance-table td:nth-child(3) {
  white-space: normal;
}

.finance-alert {
  color: #e2b968;
  font-weight: 800;
}

.finance-income {
  color: #79c99d;
  font-weight: 800;
}

.finance-expense {
  color: #df8a82;
  font-weight: 800;
}

.finance-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.project-finance-section {
  border-color: rgba(208, 176, 111, 0.3);
  background: rgba(208, 176, 111, 0.035);
}

.project-finance-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.project-finance-grid .metric {
  min-height: 104px;
}

@media (max-width: 1180px) {
  .finance-metric-grid,
  .project-finance-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .finance-detail-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .automation-hero,
  .sync-preview-head,
  .sync-preview-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .automation-status-grid,
  .sync-preview-grid {
    grid-template-columns: 1fr;
  }

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

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

  .sync-preview-foot .actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .sync-preview-foot .button,
  .automation-hero .button {
    width: 100%;
  }
}

/* V2 final mobile layout guard: keep this after the desktop theme overrides. */
@media (max-width: 760px) {
  .app-shell {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    height: auto;
    padding: 8px;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .sidebar .brand {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .sidebar .brand-logo-card {
    width: 64px;
  }

  .mobile-brand-copy {
    display: none;
  }

  .sidebar .nav {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
    padding: 0 0 2px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .sidebar .nav button {
    flex: 0 0 auto;
    grid-template-columns: 24px auto;
    width: auto;
    min-height: 44px;
    padding: 7px 9px;
    white-space: nowrap;
  }

  .sidebar .nav .nav-icon {
    width: 22px;
    height: 22px;
  }

  .main {
    width: 100%;
    max-width: 100vw;
    padding: 12px;
  }

  .topbar {
    display: grid;
    gap: 12px;
    align-items: stretch;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
  }

  .role-switch,
  .sync-badge {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .role-switch select,
  .topbar-actions .button {
    width: 100%;
    min-width: 0;
  }

  .notice {
    display: grid;
    gap: 4px;
  }

  .automation-hero {
    padding: 16px;
  }

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

  .finance-metric-grid .metric,
  .project-finance-grid .metric {
    min-height: 94px;
    padding: 13px;
  }

  .finance-metric-grid .metric strong,
  .project-finance-grid .metric strong {
    font-size: 21px;
  }

  .sync-detected-grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .panel-body {
    padding: 12px;
  }
}
