:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #697589;
  --line: #dce4ee;
  --soft: #f7f9fc;
  --accent: #126b5f;
  --accent-dark: #0e5149;
  --danger: #b64a3a;
  --nav: #111827;
  --nav-soft: #1f2937;
  --gold: #b8872f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(18, 107, 95, .08), rgba(184, 135, 47, .08)),
    var(--bg);
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(20, 32, 51, .16);
}

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

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

.login-card h1 {
  margin-top: 4px;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-card input {
  width: 100%;
}

.demo-accounts {
  display: grid;
  gap: 7px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.demo-accounts strong {
  color: var(--ink);
}

.demo-accounts span {
  padding: 6px 8px;
  border-radius: 8px;
}

.demo-accounts .current-account {
  background: #e6f4f1;
  color: var(--accent);
  font-weight: 700;
}

.login-mode .sidebar,
.login-mode main {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.sidebar {
  min-height: 100vh;
  background: var(--nav);
  color: #fff;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

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

.brand strong {
  display: block;
  font-size: 17px;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: #aeb8c7;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 7px;
}

nav a,
nav span {
  color: #cbd5e1;
  text-decoration: none;
  padding: 12px 13px;
  border-radius: 8px;
  font-size: 14px;
}

nav span {
  background: var(--nav-soft);
  color: #fff;
}

nav a.active,
nav a:hover {
  background: var(--nav-soft);
  color: #fff;
}

.identity-card {
  margin-top: auto;
  border: 1px solid #334155;
  background: #172033;
  border-radius: 8px;
  padding: 16px;
}

.identity-label {
  color: #9fb0c7;
  font-size: 12px;
}

.identity-card strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.identity-card small {
  display: block;
  margin-top: 4px;
  color: #b8c4d4;
}

.identity-card dl {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.identity-card div {
  padding-top: 10px;
  border-top: 1px solid #2f3b50;
}

.identity-card dt {
  color: #8fa1b8;
  font-size: 12px;
}

.identity-card dd {
  margin: 3px 0 0;
  color: #fff;
  font-size: 13px;
}

main {
  min-width: 0;
  padding: 24px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(420px, 620px);
  align-items: start;
  gap: 18px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf7f5;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1, h2, p { margin: 0; }
h1 {
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.2;
}
h2 {
  font-size: 18px;
  line-height: 1.3;
}
p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
}

.actions input[type="search"] {
  min-width: 240px;
}

button,
input,
select,
textarea {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  max-width: 100%;
}

textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

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

.nav-button {
  width: 100%;
  border-color: #334155;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
}

.nav-button:hover {
  background: var(--nav-soft);
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: .7;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat,
.panel,
.lock-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  min-height: 96px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.panel,
.lock-panel {
  padding: 16px;
}

.lock-panel {
  margin-bottom: 14px;
  border-left: 4px solid var(--accent);
}

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

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 300px;
}

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

.pager button,
.pager select {
  height: 34px;
}

.lock-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.lock-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.lock-form input,
.lock-form select {
  width: 100%;
}

.line-link-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.line-link-prefix {
  flex: 0 1 auto;
  padding-left: 12px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.line-link-field input {
  flex: 1 1 120px;
  min-width: 80px;
  height: 36px;
  padding-left: 4px;
  border: 0;
  outline: 0;
}

[hidden] { display: none !important; }
.lock-form label { min-width: 0; }
.line-link-field:focus-within { outline: 2px solid var(--accent); }
.profile-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.profile-fields input[type="file"] { padding: 8px; height: auto; min-height: 38px; }
.avatar { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; flex: 0 0 42px; }
.avatar.preview { width: 72px; height: 72px; }
.avatar-preview-controls { display: grid; gap: 6px; justify-items: start; }
.crop-dialog { width: 760px; }
.crop-stage { width: 100%; height: min(46dvh, 400px); min-height: 240px; background: #edf0f2; margin: 16px 0; }
.crop-stage > img { display: block; max-width: 100%; max-height: 100%; }
.crop-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.crop-controls input[type="range"] { padding: 0; }
.crop-actions { display: flex; justify-content: flex-end; gap: 10px; }
.crop-controls label { font-size: 13px; }
@media (max-width: 640px) {
  .crop-controls { grid-template-columns: minmax(0, 1fr); }
  .crop-stage { height: 32dvh; }
  .crop-actions button { flex: 1; }
}
.customer-profile { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-width: 0; }
.customer-profile span { overflow-wrap: anywhere; }
.profile-summary { margin-bottom: 12px; }
.tag.pending { background: #fff3d6; color: #73510b; }
.tag.provisional { background: #e9f1ff; color: #24529b; }
.profile-dialog {
  width: 680px;
  max-width: calc(100% - 24px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--ink);
}
.profile-dialog::backdrop { background: rgb(0 0 0 / 35%); }
.profile-dialog form, .profile-dialog label { display: grid; gap: 12px; min-width: 0; }
.profile-dialog input, .profile-dialog select, .profile-dialog textarea { width: 100%; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.profile-history { display: grid; gap: 8px; max-height: 200px; overflow: auto; }
.history-row { display: flex; align-items: center; gap: 10px; overflow-wrap: anywhere; }
.review-customers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.review-customer { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; border-bottom: 1px solid var(--line); padding-bottom: 12px; overflow-wrap: anywhere; }
.review-customer .avatar { width: 80px; height: 80px; }
@media (max-width: 640px) {
  .profile-fields, .review-customers { grid-template-columns: minmax(0, 1fr); }
  .pager { flex-wrap: wrap; }
  .profile-dialog { padding: 14px; }
}

.bulk-import {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.bulk-import h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

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

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

.user-form button {
  grid-column: span 2;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  gap: 14px;
  align-items: start;
}

.employee-role .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.employee-role .side-panel .tabs {
  display: none;
}

.employee-role .stats {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.data-panel,
.side-panel {
  min-width: 0;
}

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

table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
  font-size: 13px;
}

th:nth-child(1), td:nth-child(1) { min-width: 160px; max-width: 220px; overflow-wrap: anywhere; }
th:nth-child(2), td:nth-child(2) { min-width: 110px; }
th:nth-child(3), td:nth-child(3) { min-width: 130px; }
th:nth-child(5), td:nth-child(5) { min-width: 230px; }
th:nth-child(7), td:nth-child(7) { min-width: 110px; }

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

th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  z-index: 1;
  color: #475569;
  font-size: 12px;
}

td small {
  color: var(--muted);
}

.empty-state {
  height: 120px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.identifiers {
  display: block;
  max-width: 380px;
  line-height: 1.45;
}

.tag {
  display: inline-flex;
  min-width: 62px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #e6f4f1;
  color: var(--accent);
  font-weight: 700;
}

.tag.deleted {
  background: #faeae7;
  color: var(--danger);
}

.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.danger:hover {
  background: #943b2f;
}

.ghost {
  background: #fff;
  color: var(--accent);
}

.ghost:hover {
  background: #edf7f5;
  color: var(--accent-dark);
}

.message {
  min-height: 24px;
  margin-top: 10px;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--soft);
}

.item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

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

.item-actions {
  margin-top: 10px;
}

.item-actions button {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

@media (max-width: 1100px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 16px;
    gap: 14px;
  }

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

  nav a {
    text-align: center;
    padding: 10px 8px;
  }

  .identity-card {
    margin-top: 0;
  }

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

  .hero,
  .workspace,
  .panel-head {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .pager {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }

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

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

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

  .brand {
    min-height: 44px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

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

  .identity-card {
    padding: 12px;
  }

  .identity-card strong {
    font-size: 17px;
  }

  .identity-card dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
  }

  main {
    padding: 14px;
  }

  h1 {
    font-size: 24px;
  }

  .stats,
  .employee-role .stats,
  .lock-form,
  .user-form {
    grid-template-columns: 1fr;
  }

  .user-form button {
    grid-column: auto;
  }

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

  .actions input,
  .actions select,
  .actions button,
  .actions input[type="search"] {
    width: 100%;
    min-width: 0;
  }
}
