:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-strong: #f0f7f5;
  --ink: #202124;
  --muted: #6f7479;
  --line: #dfe3e6;
  --brand: #146c63;
  --brand-dark: #0f514b;
  --accent: #b7791f;
  --danger: #b42318;
  --info: #285980;
  --ok: #1f7a4d;
  --shadow: 0 12px 30px rgba(23, 38, 35, 0.08);
  --radius: 8px;
  --font: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: var(--brand);
  text-decoration: none;
}

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

button {
  border: 0;
}

[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.brand-mark.large {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  font-size: 20px;
}

.brand-title {
  display: block;
  font-weight: 800;
}

.brand-subtitle {
  display: block;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.nav-actions,
.inline-actions,
.form-actions,
.payment-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.page {
  width: min(1180px, calc(100% - 40px));
  margin: 28px auto 56px;
}

.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 22px;
  width: min(1320px, calc(100% - 36px));
  margin: 24px auto 56px;
}

.sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tab-button,
.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab-button {
  width: 100%;
  justify-content: flex-start;
}

.tab-button:hover,
.nav-button:hover {
  background: #edf3f1;
  color: var(--ink);
}

.tab-button.active,
.nav-button.active {
  background: var(--brand);
  color: #fff;
}

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

.section {
  margin-bottom: 22px;
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.section-desc {
  margin: 6px 0 0;
  color: var(--muted);
}

.section-body {
  padding: 22px;
}

.panel {
  padding: 18px;
}

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

.workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 22px;
}

.order-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
}

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

.three-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

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

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

.form-field label {
  color: #303436;
  font-weight: 700;
}

.form-field small {
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd6d9;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 108, 99, 0.14);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 7px;
  background: #e9eeec;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: #dfe7e4;
}

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

.btn.primary:hover {
  background: var(--brand-dark);
}

.btn.warn {
  background: #f4eadb;
  color: #7a4a10;
}

.btn.danger {
  background: #f7dfdc;
  color: var(--danger);
}

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

.btn.icon {
  width: 38px;
  padding: 0;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 780px;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f3f6f5;
  color: #3c4244;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf0f2;
  color: #495057;
  font-size: 12px;
  font-weight: 800;
}

.status.paid,
.status.approved,
.status.delivered,
.status.completed {
  background: #ddf4e8;
  color: var(--ok);
}

.status.deposit_paid {
  background: #e5edff;
  color: #315ca8;
}

.status.pending_payment,
.status.pending,
.status.pending_review,
.status.revision_requested {
  background: #fff0d4;
  color: #8a5700;
}

.status.cancelled,
.status.rejected,
.status.refunded {
  background: #f9dedb;
  color: var(--danger);
}

.status.assigned,
.status.in_progress {
  background: #dcecf7;
  color: var(--info);
}

.summary-box {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--surface-strong);
  border: 1px solid #cfe4df;
  border-radius: var(--radius);
}

.summary-price {
  margin: 0;
  color: var(--brand);
  font-size: 30px;
  font-weight: 900;
}

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

.strong {
  font-weight: 800;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #cbd3d6;
  border-radius: var(--radius);
  background: #fafafa;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #1f2927;
  color: #fff;
  box-shadow: var(--shadow);
}

dialog {
  width: min(780px, calc(100% - 28px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(21, 26, 28, 0.36);
}

.dialog-card {
  max-height: min(84vh, 820px);
  overflow: auto;
}

.message-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

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

.conversation-item {
  width: 100%;
  padding: 12px;
  border-radius: 7px;
  background: #f3f6f5;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.conversation-item.active {
  background: var(--brand);
  color: #fff;
}

.message-thread {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 300px;
  max-height: 460px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafafa;
}

.message {
  width: min(78%, 560px);
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #e8eeec;
}

.message.mine {
  justify-self: end;
  background: #dceee9;
}

.message-meta {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.compact-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.compact-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.compact-list li:last-child {
  border-bottom: 0;
}

.role-badge {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eee7db;
  color: #6a4a16;
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .app-shell,
  .workbench-grid,
  .order-detail-grid,
  .message-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-grid,
  .three-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
    gap: 12px;
  }

  .page,
  .app-shell {
    width: min(100% - 24px, 1180px);
    margin-top: 18px;
  }

  .section-head,
  .section-body {
    padding: 16px;
  }

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

  .message {
    width: 92%;
  }
}

body.auth-modal-open,
body.ledger-fullscreen-active {
  overflow: hidden;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 28px;
  overflow: auto;
  background: rgba(21, 26, 28, 0.66);
}

.auth-modal[hidden] {
  display: none;
}

.auth-modal .auth-panel {
  position: relative;
  align-self: center;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
}

.auth-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}

.status.balance-pending {
  background: #fff0d4;
  color: #8a5700;
}

.status.balance-recovered {
  background: #ddf4e8;
  color: var(--ok);
}

.status.balance-not_required {
  background: #edf0f2;
  color: #596166;
}

.project-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.project-list-item,
.project-admin-item {
  display: flex;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #eef2f1;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.project-list-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 11px;
}

.project-list-item span,
.project-list-item small,
.project-admin-item small {
  color: var(--muted);
}

.project-list-item.active,
.project-admin-item.active {
  border-color: var(--brand);
  background: #e5f1ed;
}

.chat-main {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.project-overview {
  max-height: 330px;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.project-summary-line {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.project-summary-line span {
  display: grid;
  gap: 3px;
}

.project-summary-line small {
  color: var(--muted);
}

.project-resource-grid,
.project-admin-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
}

.project-resource-grid h3,
.project-admin-columns h3,
.project-admin-columns h4 {
  margin: 0 0 10px;
}

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

.project-revision-list div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-left: 3px solid var(--accent);
  background: #f7f6f2;
}

.project-revision-list small {
  color: var(--muted);
}

.project-revision-form,
.project-upload-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.project-management-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.32fr) minmax(0, 1fr);
  gap: 16px;
}

.project-admin-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.project-admin-item {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.project-admin-item > span {
  display: grid;
  gap: 4px;
}

.project-admin-item > span:last-child {
  justify-items: end;
}

.project-admin-workspace {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.project-workspace-head,
.project-chat-panel {
  padding: 18px;
  background: #fff;
}

.project-workspace-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.project-workspace-head h2,
.project-workspace-head p {
  margin: 5px 0 0;
}

.project-workspace-head p {
  color: var(--muted);
}

.project-chat-panel {
  border-top: 1px solid var(--line);
}

.project-admin-thread {
  min-height: 240px;
  max-height: 420px;
  margin-top: 12px;
}

.erp-shell.ledger-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  background: #f4f6f7;
}

.erp-shell.ledger-fullscreen .erp-sidebar {
  display: none;
}

.erp-shell.ledger-fullscreen > div,
.erp-shell.ledger-fullscreen #ordersTab {
  width: 100%;
  height: 100%;
}

.erp-shell.ledger-fullscreen #ordersTab {
  margin: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.erp-shell.ledger-fullscreen #ordersTab .section-body {
  padding: 14px 18px 24px;
}

@media (max-width: 980px) {
  .project-management-layout,
  .project-admin-columns {
    grid-template-columns: 1fr;
  }

  .project-admin-list {
    max-height: 300px;
  }
}

@media (max-width: 720px) {
  .auth-modal {
    display: block;
    width: 100%;
    padding: 12px;
  }

  .auth-modal[hidden] {
    display: none;
  }

  .auth-modal .auth-visual {
    display: none;
  }

  .auth-modal .auth-panel {
    width: 100%;
    min-height: calc(100dvh - 24px);
    padding: 14px;
  }

  #purchaseDialog {
    width: 100%;
    height: 100dvh;
    max-height: none;
    margin: 0;
  }

  #purchaseDialog .dialog-card {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  #purchaseDialog .workbench-grid,
  #purchaseDialog .field-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #purchaseDialog .section-head {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #fff;
  }

  #purchaseDialog input,
  #purchaseDialog select,
  #purchaseDialog textarea,
  .auth-modal input,
  .auth-modal select,
  .auth-modal textarea {
    min-height: 48px;
    font-size: 16px;
  }

  input[type="file"] {
    min-height: 52px;
    padding: 10px;
    background: #f8faf9;
  }

  .project-summary-line,
  .project-resource-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-overview {
    max-height: 400px;
  }

  .chat-main {
    min-height: 680px;
  }

  .project-file-picker {
    width: 48px;
    min-height: 48px;
  }
}

.site-body {
  background: #f3f1ec;
}

.site-topbar {
  min-height: 72px;
}

.auth-landing {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 24px;
  width: min(1320px, calc(100% - 40px));
  margin: 28px auto 56px;
}

.auth-visual,
.site-hero {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(10, 38, 35, 0.88), rgba(10, 38, 35, 0.58), rgba(10, 38, 35, 0.18)),
    url("/assets/hero-consulting.png") center / cover;
  box-shadow: var(--shadow);
}

.auth-visual {
  display: flex;
  align-items: flex-end;
  padding: 48px;
}

.auth-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.auth-mode-panel {
  min-height: 360px;
}

.hero-copy,
.site-hero-overlay {
  max-width: 720px;
  color: #fff;
}

.hero-copy h1,
.site-hero-overlay h1 {
  margin: 10px 0 14px;
  font-size: clamp(38px, 5vw, 64px);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-copy p,
.site-hero-overlay p {
  max-width: 600px;
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 17px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.hero-metrics span {
  min-width: 132px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
}

.hero-metrics strong {
  display: block;
  color: #fff;
  font-size: 20px;
}

.elevated {
  border-color: rgba(20, 108, 99, 0.28);
}

.site-hero {
  display: flex;
  align-items: center;
  min-height: 600px;
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(5, 33, 29, 0.95), rgba(5, 33, 29, 0.68), rgba(5, 33, 29, 0.12)),
    url("/assets/hero-consulting.png") center / cover;
}

.site-hero-overlay {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.home-trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 40px;
}

.home-trust-row div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 10px;
  min-width: 180px;
  padding: 13px 15px;
  border-left: 3px solid rgba(183, 121, 31, 0.96);
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
}

.home-trust-row i {
  grid-row: span 2;
  width: 22px;
  height: 22px;
  color: #e3bd75;
}

.home-trust-row strong {
  color: #fff;
  font-weight: 900;
}

.home-trust-row span {
  font-size: 13px;
}

.translucent {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.translucent:hover {
  background: rgba(255, 255, 255, 0.24);
}

.site-band {
  width: min(1180px, calc(100% - 40px));
  margin: 34px auto;
}

.site-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.site-section-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.site-section-head h2,
.split-band h2 {
  margin: 4px 0 0;
  font-size: 32px;
  line-height: 1.18;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.service-card {
  display: grid;
  align-content: start;
  min-height: 230px;
  padding: 18px;
  border: 1px solid #dfe3de;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(30, 42, 38, 0.07);
}

.service-card h3 {
  margin: 10px 0 8px;
  font-size: 18px;
}

.service-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.service-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #e6f1ef;
  color: var(--brand);
}

.service-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.service-footer strong {
  color: var(--brand);
  font-size: 20px;
}

.service-footer small {
  display: block;
  margin-top: 3px;
  color: #8a5700;
  font-size: 11px;
}

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

.payment-plan-card {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 108px;
  padding: 15px;
  border: 1px solid #d8dee2;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.payment-plan-card.active,
.payment-plan-card:has(input:checked) {
  border-color: var(--brand);
  background: #f0f7f5;
  box-shadow: 0 0 0 3px rgba(20, 108, 99, 0.1);
}

.payment-plan-card input {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 18px;
  min-height: 18px;
}

.payment-plan-card span {
  color: var(--brand);
  font-size: 24px;
  font-weight: 900;
}

.payment-plan-card small {
  color: var(--muted);
}

.split-band {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 22px;
  align-items: center;
  padding: 30px;
  border: 1px solid #dfe3de;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.split-band p {
  margin: 10px 0 0;
  color: var(--muted);
}

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

.process-steps span {
  display: grid;
  place-items: center;
  min-height: 68px;
  padding: 10px;
  border-radius: 8px;
  background: #f0f7f5;
  color: var(--brand-dark);
  font-weight: 800;
  text-align: center;
}

.purchase-card {
  width: 100%;
}

#purchaseDialog {
  width: min(1080px, calc(100% - 28px));
}

#purchaseDialog .workbench-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.65fr);
}

.chat-workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chat-side {
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #f7f8f7;
}

.chat-user {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.chat-user p,
.chat-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.quick-replies {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.chat-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 620px;
}

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

.chat-thread {
  max-height: none;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: #fbfaf7;
}

.chat-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.chat-input textarea {
  min-height: 46px;
  max-height: 120px;
}

.metric-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.metric-card span {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  color: var(--brand);
  font-size: 28px;
}

.progress-line {
  width: 140px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ecea;
}

.progress-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.erp-body {
  background: #f4f6f7;
}

.erp-topbar {
  min-height: 62px;
  border-bottom-color: #d8dee2;
  background: rgba(255, 255, 255, 0.96);
}

.erp-shell {
  grid-template-columns: 230px minmax(0, 1fr);
  width: min(1360px, calc(100% - 32px));
  gap: 18px;
  margin-top: 18px;
}

.erp-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
  width: min(1560px, calc(100% - 24px));
}

.erp-shell.sidebar-collapsed .erp-sidebar {
  display: none;
  visibility: hidden;
  overflow: hidden;
  padding: 0;
  border: 0;
}

.erp-sidebar {
  top: 80px;
  padding: 10px;
  border-color: #d8dee2;
  box-shadow: 0 10px 28px rgba(29, 39, 43, 0.06);
}

.erp-menu-title {
  padding: 8px 10px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.erp-body .tab-button {
  min-height: 42px;
  margin-bottom: 4px;
  border-radius: 6px;
  font-weight: 700;
}

.erp-body .section {
  border-color: #d8dee2;
  box-shadow: 0 10px 28px rgba(29, 39, 43, 0.06);
}

.erp-module-head {
  align-items: center;
  min-height: 88px;
  background: linear-gradient(180deg, #fff, #fbfcfc);
}

.erp-filterbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid #d8dee2;
  border-radius: 8px;
  background: #f8faf9;
}

.erp-filterbar .filter-keyword {
  grid-column: span 2;
}

.ledger-layout.detail-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.ledger-layout.detail-hidden #adminOrderDetail {
  display: none;
}

.erp-filterbar .form-field {
  gap: 4px;
}

.erp-filterbar label {
  color: #596166;
  font-size: 12px;
}

.erp-filter-actions {
  display: flex;
  align-items: end;
}

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

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

.erp-kpi {
  min-height: 92px;
  padding: 14px;
  border: 1px solid #d8dee2;
  border-radius: 8px;
  background: #fff;
}

.erp-kpi-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
  border-radius: 7px;
  background: #e6f1ef;
  color: var(--brand);
}

.erp-kpi span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.erp-kpi strong {
  display: block;
  margin-top: 4px;
  color: #17211f;
  font-size: 24px;
  line-height: 1.2;
}

.erp-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.erp-panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.erp-panel-title h2 {
  margin: 0;
  font-size: 18px;
}

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

.erp-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid #dce2e5;
  border-radius: 7px;
  background: #fbfcfc;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.erp-list-row:hover {
  background: #f0f7f5;
}

.erp-list-row small,
.erp-target-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

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

.erp-target-row:last-child {
  border-bottom: 0;
}

.wide-dialog {
  width: min(1120px, calc(100% - 28px));
}

.writer-table-wrap {
  background: #fff;
}

.writer-table {
  min-width: 1280px;
}

.writer-table th,
.writer-table td {
  vertical-align: middle;
  white-space: nowrap;
}

.writer-table th:nth-child(9),
.writer-table td:nth-child(9) {
  min-width: 300px;
  white-space: normal;
}

.writer-table th:nth-child(10),
.writer-table td:nth-child(10) {
  min-width: 190px;
}

.writer-table th:last-child,
.writer-table td:last-child {
  position: sticky;
  right: 0;
  box-shadow: -10px 0 16px rgba(29, 39, 43, 0.06);
}

.writer-table th:last-child {
  z-index: 2;
  background: #eef2f1;
}

.writer-table td:last-child {
  z-index: 1;
  background: #fff;
}

.metric-cell {
  color: var(--brand);
  font-size: 20px;
  font-weight: 900;
  white-space: nowrap;
}

.table-subtext {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.writer-stage-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.writer-stage-strip.compact {
  gap: 6px;
}

.writer-stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid #dce2e5;
  border-radius: 999px;
  background: #fbfcfc;
  color: var(--muted);
  font-size: 12px;
}

.writer-stage-pill b {
  color: var(--ink);
}

.writer-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
}

.writer-detail-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.writer-detail-summary div {
  padding: 14px;
  border: 1px solid #dce2e5;
  border-radius: 8px;
  background: #f5f8f7;
}

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

.writer-detail-summary strong {
  display: block;
  margin-top: 5px;
  color: var(--brand);
  font-size: 24px;
}

.writer-detail-stage {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border: 1px solid #dce2e5;
  border-radius: 8px;
  background: #fbfcfc;
}

.writer-detail-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.writer-detail-title h3 {
  margin: 0;
  font-size: 16px;
}

.writer-order-table table {
  min-width: 980px;
}

.erp-body .table-wrap {
  border-color: #d8dee2;
  border-radius: 6px;
}

.erp-body table {
  min-width: 920px;
}

.erp-body .writer-table {
  min-width: 1280px;
}

.erp-body th {
  background: #eef2f1;
  color: #30383b;
  font-weight: 900;
}

.erp-body th,
.erp-body td {
  padding: 10px 12px;
}

.erp-body .order-detail-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.erp-body .panel {
  box-shadow: none;
}

.admin-login-page {
  width: min(1180px, calc(100% - 40px));
  margin: 42px auto 64px;
}

.admin-login-cover {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.75fr);
  min-height: 620px;
  overflow: hidden;
  border: 1px solid #d8dee2;
  border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(8, 38, 35, 0.96), rgba(20, 108, 99, 0.82)),
    url("/assets/hero-consulting.png") center / cover;
  box-shadow: 0 18px 50px rgba(29, 39, 43, 0.12);
}

.admin-login-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
  color: #fff;
}

.admin-login-brand h1 {
  max-width: 620px;
  margin: 14px 0 14px;
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.06;
  letter-spacing: 0;
}

.admin-login-brand p {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 17px;
}

.admin-login-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.admin-login-points span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.admin-login-card {
  display: flex;
  align-items: center;
  padding: 38px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.admin-login-card .panel {
  width: 100%;
  box-shadow: none;
}

@media (max-width: 980px) {
  .auth-landing,
  .split-band,
  .chat-workspace {
    grid-template-columns: 1fr;
  }

  .erp-shell,
  .erp-dashboard-grid {
    grid-template-columns: 1fr;
  }

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

  .erp-sidebar {
    position: static;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
  }

  .erp-menu-title {
    display: none;
  }

  .erp-body .tab-button {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
  }

  .erp-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
    width: min(1360px, calc(100% - 24px));
  }

  .admin-login-cover {
    grid-template-columns: 1fr;
  }

  .admin-login-card {
    align-items: stretch;
  }

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

  .writer-actions {
    width: 100%;
  }

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

  .auth-visual,
  .site-hero {
    min-height: 460px;
  }

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

  .chat-side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    min-height: auto;
    padding: 10px 12px;
  }

  .site-topbar .brand-subtitle,
  .erp-topbar .brand-subtitle {
    display: none;
  }

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

  .site-topbar .nav-button,
  .site-topbar .btn {
    min-width: 0;
    min-height: 42px;
    padding: 6px 4px;
    font-size: 12px;
    white-space: normal;
  }

  .site-topbar .nav-button svg,
  .site-topbar .btn svg {
    width: 17px;
    height: 17px;
  }

  .erp-topbar .nav-actions {
    gap: 5px;
  }

  .erp-topbar .role-badge {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .auth-landing,
  .site-band,
  .site-hero-overlay {
    width: min(100% - 24px, 1180px);
  }

  .auth-visual {
    padding: 26px;
  }

  .hero-copy h1,
  .site-hero-overlay h1 {
    font-size: 32px;
  }

  .site-hero {
    min-height: 560px;
    background-position: 62% center;
  }

  .site-hero-overlay {
    padding: 42px 0;
  }

  .home-trust-row {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    margin-top: 28px;
  }

  .home-trust-row div {
    width: 100%;
  }

  .service-grid,
  .process-steps,
  .chat-input {
    grid-template-columns: 1fr;
  }

  .field-grid,
  .workbench-grid,
  .order-detail-grid,
  .payment-plan-options,
  .erp-filterbar {
    grid-template-columns: 1fr;
  }

  .erp-filterbar .filter-keyword {
    grid-column: auto;
  }

  .section-head,
  .site-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .section-body,
  .section-head,
  .panel {
    padding: 14px;
  }

  dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
  }

  .dialog-card {
    max-height: 92vh;
    border-radius: 8px 8px 0 0;
  }

  .user-order-table {
    overflow: visible;
    border: 0;
  }

  .user-order-table table,
  .user-order-table tbody,
  .user-order-table tr,
  .user-order-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .user-order-table thead {
    display: none;
  }

  .user-order-table tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .user-order-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 0;
    border: 0;
    text-align: right;
  }

  .user-order-table td::before {
    content: attr(data-label);
    flex: 0 0 82px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-align: left;
  }

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

  .file-item > .inline-actions,
  .file-item > .btn {
    width: 100%;
  }

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

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

  .admin-login-page {
    width: min(100% - 24px, 1180px);
    margin-top: 22px;
  }

  .admin-login-brand,
  .admin-login-card {
    padding: 28px;
  }
}

/* Final layout overrides for the public login overlay and ledger workspace. */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 28px;
  overflow: auto;
  background: rgba(21, 26, 28, 0.66);
}

.auth-modal[hidden] {
  display: none;
}

.chat-main {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.erp-shell.ledger-fullscreen,
.erp-shell.ledger-fullscreen.sidebar-collapsed {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
}

.managed-file {
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
}

.file-main {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.file-title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.file-title-line .strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-time {
  flex: 0 0 auto;
  color: #6a7276;
  font-size: 12px;
  font-weight: 800;
}

.file-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.file-meta-row span:not(.status) {
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f4f3;
  color: #596166;
  font-size: 12px;
  font-weight: 700;
}

@media (min-width: 1180px) {
  .erp-shell {
    grid-template-columns: 204px minmax(0, 1fr);
    width: min(1720px, calc(100% - 20px));
    gap: 12px;
  }

  .erp-shell.sidebar-collapsed {
    width: min(1760px, calc(100% - 16px));
  }

  .erp-body .section-head {
    padding: 16px 18px;
  }

  .erp-body .section-body {
    padding: 16px 18px;
  }

  .erp-filterbar {
    grid-template-columns: minmax(220px, 1.35fr) repeat(7, minmax(120px, 1fr)) auto;
    gap: 8px;
    padding: 10px;
  }

  .erp-filterbar .filter-keyword {
    grid-column: span 2;
  }

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

  .erp-kpi {
    min-height: 72px;
    padding: 10px 12px;
  }

  .erp-body th,
  .erp-body td {
    padding: 8px 9px;
    font-size: 13px;
  }

  .erp-body table {
    min-width: 1040px;
  }

  .project-management-layout {
    grid-template-columns: minmax(260px, 0.24fr) minmax(0, 1fr);
  }

  .project-admin-columns {
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
    padding: 12px;
  }

  .erp-body .ledger-layout.detail-hidden {
    grid-template-columns: minmax(0, 1fr);
  }

  .erp-body .ledger-layout:not(.detail-hidden) {
    grid-template-columns: minmax(920px, 1fr) minmax(300px, 0.28fr);
  }
}

@media (max-width: 720px) {
  .site-topbar .nav-actions {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  }

  .auth-modal {
    display: block;
    width: 100%;
    margin: 0;
    padding: 12px;
  }

  .auth-modal[hidden] {
    display: none;
  }

  .auth-modal .auth-visual {
    display: none;
  }

  .auth-modal .auth-panel {
    width: 100%;
    min-height: calc(100dvh - 24px);
    padding: 14px;
  }

  #purchaseDialog {
    width: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
  }

  #purchaseDialog .dialog-card {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  #purchaseDialog .section-head {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #fff;
  }

  #purchaseDialog .workbench-grid,
  #purchaseDialog .field-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #purchaseDialog input,
  #purchaseDialog select,
  #purchaseDialog textarea,
  .auth-modal input,
  .auth-modal select,
  .auth-modal textarea {
    min-height: 48px;
    font-size: 16px;
  }

  input[type="file"] {
    min-height: 52px;
    padding: 10px;
    background: #f8faf9;
  }

  .project-summary-line,
  .project-resource-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-overview {
    max-height: 400px;
  }

  .chat-main {
    min-height: 680px;
  }
}
