:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1b2733;
  --muted: #667485;
  --line: #d9e2ec;
  --brand: #17324d;
  --brand-2: #1f6f8b;
  --green: #207a55;
  --amber: #a86612;
  --red: #b42318;
  --soft-blue: #eaf2f8;
  --soft-green: #e9f6ef;
  --soft-amber: #fff3da;
  --soft-red: #fdecec;
  --radius: 8px;
  --shadow: 0 10px 26px rgba(22, 36, 50, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 50, 77, 0.92), rgba(31, 111, 139, 0.72)),
    #17324d;
}

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

.auth-panel {
  width: min(440px, 100%);
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.26);
}

.auth-brand {
  padding: 0 0 18px;
  margin-bottom: 18px;
}

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

.auth-form h2,
.auth-form p {
  margin: 0;
}

.auth-warning {
  min-height: 20px;
  color: var(--red);
}

.locked {
  display: none !important;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 22px;
  border-bottom: 1px solid var(--line);
}

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

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.eyebrow,
.muted,
.hint {
  color: var(--muted);
}

.brand p {
  margin-top: 3px;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 20px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  color: #314252;
  background: transparent;
  text-align: left;
}

.nav-item span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--brand-2);
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: var(--soft-blue);
  color: var(--brand);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.reminder-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f0c36d;
  border-radius: 8px;
  background: #fff7e6;
  color: #5f3908;
}

.reminder-banner[hidden] {
  display: none;
}

.reminder-banner span {
  flex: 1;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 12px;
}

.topbar h2 {
  font-size: 26px;
}

.top-actions,
.toolbar,
.button-row,
.modal-actions,
.backup-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-reminders {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.search-input {
  width: min(360px, 38vw);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(31, 111, 139, 0.14);
}

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

.primary-btn,
.secondary-btn,
.text-btn,
.icon-btn,
.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 13px;
  white-space: nowrap;
}

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

.primary-btn:hover {
  background: #214969;
}

.secondary-btn,
.file-label {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-btn:hover,
.file-label:hover {
  border-color: var(--brand-2);
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--brand-2);
  padding-inline: 4px;
}

.icon-btn {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--brand);
  font-size: 18px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

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

.kpi-card {
  padding: 16px;
}

.kpi-card span,
.kpi-card small {
  display: block;
  color: var(--muted);
}

.kpi-card strong {
  display: block;
  margin: 8px 0 3px;
  font-size: 30px;
}

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

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

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

.panel h3 {
  font-size: 16px;
}

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

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f5f9;
  color: #33485c;
  font-weight: 700;
}

tbody tr {
  background: #fff;
}

tbody tr:hover,
tbody tr.selected {
  background: #f5fbff;
}

.toolbar {
  margin-bottom: 14px;
}

.toolbar select {
  width: 160px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.list-panel {
  min-height: 560px;
}

.detail-panel {
  position: sticky;
  top: 18px;
  padding: 16px;
  min-height: 560px;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 400px;
  text-align: center;
  color: var(--muted);
}

.customer-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.customer-title h3 {
  margin: 0;
  font-size: 20px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

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

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

.meta-item strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 3px 8px;
  background: var(--soft-blue);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.tag.high {
  background: var(--soft-red);
  color: var(--red);
}

.tag.medium {
  background: var(--soft-amber);
  color: var(--amber);
}

.tag.low {
  background: var(--soft-green);
  color: var(--green);
}

.activity-list {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

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

.activity-item strong {
  display: block;
  margin-bottom: 4px;
}

.stage-bars {
  display: grid;
  gap: 12px;
}

.stage-row {
  display: grid;
  grid-template-columns: 80px minmax(120px, 1fr) 34px;
  align-items: center;
  gap: 10px;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--brand-2);
}

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

.paste-box {
  min-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.backup-actions {
  align-items: stretch;
  flex-direction: column;
}

.backup-actions > * {
  width: 100%;
}

.file-label input {
  display: none;
}

.warning-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft-amber);
  color: #5f3908;
}

.warning-box p {
  margin-bottom: 0;
}

dialog {
  width: min(820px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(9, 20, 31, 0.42);
}

.modal-form {
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

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

label {
  display: grid;
  gap: 6px;
  color: #3a4c5d;
  font-weight: 700;
}

label input,
label select,
label textarea {
  font-weight: 400;
}

.wide {
  grid-column: 1 / -1;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  min-height: 30px;
  padding: 5px 8px;
}

.note-text {
  color: var(--muted);
  white-space: pre-wrap;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px 14px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .nav {
    grid-template-columns: repeat(4, 1fr);
    margin-top: 12px;
  }

  .nav-item {
    justify-content: center;
  }

  .sidebar-footer {
    display: none;
  }

  .dashboard-grid,
  .split-layout,
  .import-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 16px;
  }

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

  .top-actions {
    align-items: stretch;
  }

  .search-input,
  .top-actions .primary-btn {
    width: 100%;
  }

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

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

  .nav-item {
    padding-inline: 8px;
    font-size: 13px;
  }

  .nav-item span {
    display: none;
  }
}
