:root {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #1d2d45;
  background: #f3f7fc;
  font-size: 15px;
  line-height: 1.6;
  --blue: #1869c6;
  --muted: #607087;
  --line: #e2eaf4;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  border: 0;
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 18px;
  background: #eaf3ff;
  color: #175da9;
  cursor: pointer;
  font-weight: 600;
}
button:hover {
  filter: brightness(0.96);
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #79b7f0;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.primary {
  background: var(--blue);
  color: white;
}
button.danger {
  background: #fff0ef;
  color: #a62d26;
}
button.green {
  background: #108653;
  color: white;
}
button.quiet {
  background: transparent;
  color: var(--muted);
}
input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid #c8d6e7;
  border-radius: 10px;
  background: #f8fbff;
  color: #1d2d45;
}
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid #79b7f0;
  border-color: #1869c6;
}
textarea {
  min-height: 120px;
  resize: vertical;
}
label {
  display: block;
  margin: 0 0 8px;
  font-weight: 600;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 28px;
  letter-spacing: -0.5px;
}
h2 {
  font-size: 20px;
}
h3 {
  font-size: 17px;
}
.muted {
  color: var(--muted);
  font-size: 13px;
}
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 10px 32px;
}
.brand img {
  width: 40px;
  height: 40px;
  background: #eaf3ff;
  border-radius: 12px;
  padding: 7px;
}
.brand b {
  font-size: 22px;
}
.nav-label {
  font-size: 11px;
  color: #728198;
  margin: 18px 12px 8px;
  letter-spacing: 1.5px;
}
.nav button {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  margin: 3px 0;
  background: transparent;
  color: #54667e;
  font-weight: 500;
  min-height: 46px;
}
.nav button.active {
  color: #175da9;
  background: #eaf3ff;
  font-weight: 700;
}
.nav img {
  width: 21px;
  height: 21px;
}
.content {
  padding: 36px 44px 60px;
  max-width: 1500px;
  width: 100%;
  margin: auto;
}
.topbar,
.row,
.toolbar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}
.topbar {
  margin-bottom: 28px;
}
.topbar .muted {
  margin-top: 5px;
}
.user {
  display: flex;
  gap: 12px;
  align-items: center;
}
.card {
  background: #fff;
  border: 1px solid #e6edf6;
  border-radius: 18px;
  padding: 26px;
  margin-bottom: 22px;
  box-shadow: 0 3px 18px #15385703;
}
.hero {
  padding: 30px 32px;
  background: linear-gradient(115deg, #2c80d1, #67b0f4);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  border: 34px solid #ffffff18;
  border-radius: 50%;
  right: 50px;
  top: -50px;
}
.hero p {
  color: #f2f7ff;
  margin: 8px 0 22px;
}
.hero button {
  background: white;
  color: #185ca5;
  position: relative;
  z-index: 1;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}
.metric {
  padding: 22px;
}
.metric strong {
  display: block;
  font-size: 32px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  color: #1869c6;
  margin-top: 12px;
  overflow-wrap: anywhere;
}
.metric small {
  font-weight: 400;
  font-size: 13px;
  margin-left: 6px;
}
.split {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 22px;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 22px;
}
.feature-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 13px;
  gap: 12px;
  padding: 16px 4px;
  background: transparent;
  color: #33465e;
}
.feature-grid img {
  width: 48px;
  height: 48px;
  padding: 10px;
  background: #eaf4ff;
  border-radius: 14px;
}
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid #edf1f6;
}
.list-row:last-child {
  border: 0;
}
.list-row .muted {
  margin-top: 4px;
}
.badge {
  display: inline-block;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: 7px;
  background: #eaf3ff;
  color: #185ca5;
  font-size: 12px;
}
.badge.paid {
  color: #0b7047;
  background: #e5f6ee;
}
.badge.unpaid {
  color: #915d12;
  background: #fff3df;
}
.badge.void {
  color: #697688;
  background: #edf0f4;
}
.empty {
  text-align: center;
  padding: 55px 25px;
  color: #607087;
}
.empty img {
  width: 55px;
  height: 55px;
  margin-bottom: 16px;
}
.toolbar {
  margin-bottom: 20px;
}
.toolbar input {
  max-width: 350px;
}
.table-wrap {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
th {
  text-align: left;
  color: #607087;
  font-size: 12px;
  letter-spacing: 0.5px;
  background: #f8fbff;
  padding: 14px;
}
td {
  padding: 17px 14px;
  border-bottom: 1px solid #edf1f6;
  max-width: 300px;
  overflow-wrap: anywhere;
}
tr:last-child td {
  border: 0;
}
td button {
  font-size: 13px;
  padding: 8px 12px;
  min-height: 42px;
}
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.notice {
  background: #fff7e6;
  color: #856016;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  margin-bottom: 20px;
}
.error {
  background: #fff0ef;
  color: #a62d26;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.tabs button {
  background: #e9eef5;
  color: #607087;
}
.tabs .active {
  background: #1869c6;
  color: white;
}
.money {
  font-size: 22px;
  font-weight: 700;
  color: #1869c6;
  font-variant-numeric: tabular-nums;
}
.login {
  max-width: 430px;
  margin: 9vh auto;
  padding: 20px;
}
.login .brand {
  padding: 0 0 36px;
}
.login h1 {
  margin: 0 0 10px;
}
.field {
  margin: 0 0 22px;
}
.login .card {
  padding: 32px;
}
.login button {
  width: 100%;
}
.login .muted {
  margin: 12px 0 28px;
}
.login label {
  font-size: 14px;
}
dialog {
  border: 0;
  padding: 0;
  border-radius: 22px;
  width: min(650px, calc(100vw - 30px));
  max-height: 90vh;
  color: #1d2d45;
  background: #fff;
  box-shadow: 0 20px 100px #12243a45;
}
dialog::backdrop {
  background: #14283d70;
}
.modal-head {
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.modal-body {
  padding: 28px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}
.field.wide {
  grid-column: 1 / -1;
}
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
#toast {
  display: none;
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  background: #18324f;
  color: white;
  border-radius: 12px;
  padding: 13px 23px;
  max-width: 90vw;
}
#toast.visible {
  display: block;
}
.bill-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bill-head strong {
  font-size: 40px;
}
.bill-line {
  background: #f6f9fd;
  padding: 16px 20px;
  border-radius: 12px;
  margin: 12px 0;
}
.bill-line .muted {
  margin-top: 6px;
}
.total {
  padding: 22px 0;
  justify-content: flex-end;
}
.chart {
  display: flex;
  gap: 20px;
  height: 220px;
  align-items: flex-end;
  padding-top: 22px;
}
.chart-col {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: #607087;
}
.chart-track {
  height: 160px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px solid #dde6ef;
}
.bar {
  width: 40px;
  max-width: 80%;
  background: linear-gradient(#6bb8ff, #2c80d1);
  border-radius: 7px 7px 0 0;
}
.chart-label {
  display: block;
  margin-top: 10px;
}
.public-bill {
  max-width: 620px;
  margin: 40px auto;
  padding: 0 20px;
}
.print-only {
  display: none;
}
.contract-terms {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.9;
}
.footer-note {
  margin-top: 20px;
  color: #728198;
  font-size: 12px;
}
@media (max-width: 1100px) {
  .content {
    padding: 24px;
  }
  .layout {
    grid-template-columns: 190px 1fr;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 650px) {
  .layout {
    display: block;
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    border: 0;
  }
  .sidebar .brand {
    padding: 0 0 12px;
  }
  .nav {
    display: flex;
    overflow-x: auto;
    gap: 4px;
  }
  .nav button {
    width: auto;
    white-space: nowrap;
  }
  .nav-label {
    display: none;
  }
  .content {
    padding: 20px 16px;
  }
  .topbar {
    align-items: flex-start;
  }
  .topbar h1 {
    font-size: 22px;
  }
  .user {
    flex-direction: column;
    gap: 0;
  }
  .metrics {
    gap: 12px;
  }
  .metric {
    padding: 18px;
  }
  .metric strong {
    font-size: 26px;
  }
  .form-grid {
    display: block;
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .card {
    padding: 20px;
  }
  .modal-body {
    padding: 22px;
  }
  .feature-grid {
    gap: 4px;
  }
  .feature-grid button {
    font-size: 12px;
  }
  .login {
    margin: 4vh auto;
  }
}
@media print {
  body > * {
    display: none !important;
  }
  dialog[open] {
    display: block !important;
    position: static;
    width: 100%;
    max-height: none;
    box-shadow: none;
    border-radius: 0;
  }
  dialog .modal-body {
    padding: 10px;
  }
  dialog button,
  dialog .modal-head,
  dialog .modal-foot,
  .no-print {
    display: none !important;
  }
  .print-only {
    display: block;
  }
  dialog::backdrop {
    background: white;
  }
  .bill-line {
    break-inside: avoid;
  }
  dialog {
    overflow: visible;
  }
}
:root {
  --attachment-line: #dce6f2;
}
.contract-attachments {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--attachment-line);
}
.attachment-label {
  display: block;
  margin: 16px 0 8px;
  font-weight: 600;
}
#contract-files {
  width: 100%;
  padding: 12px;
}
#attachment-progress {
  width: 100%;
  accent-color: #1869c6;
}
#attachment-error {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.attachment-row {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 18px 0;
  border-bottom: 1px solid var(--attachment-line);
}
.attachment-row > div:first-child {
  min-width: 0;
  flex: 1 1 230px;
  overflow-wrap: anywhere;
}
.attachment-row button {
  min-height: 44px;
}
.attachment-preview {
  width: min(960px, 94vw);
  max-height: 94vh;
}
.attachment-preview-body {
  padding: 16px;
}
.attachment-preview-body img {
  width: 100%;
  height: auto;
  object-fit: contain;
}
.attachment-preview-body iframe {
  width: 100%;
  height: 72vh;
  border: 0;
}
.attachment-download {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  background: #eaf3ff;
  color: #175da9;
  text-decoration: none;
}
