:root {
  color-scheme: light;
  --bg: #f2f5f6;
  --surface: #ffffff;
  --surface-soft: #f7f9f9;
  --ink: #172229;
  --muted: #61727b;
  --line: #d9e1e4;
  --line-strong: #bcc9ce;
  --brand: #0f6b62;
  --brand-dark: #0a4d47;
  --blue: #185d8c;
  --amber: #b96b1f;
  --danger: #ad3838;
  --success: #287345;
  --shadow: 0 12px 35px rgba(22, 45, 52, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family:
    "Microsoft YaHei UI",
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans CJK SC",
    sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
}

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

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(300px, 440px) minmax(340px, 520px);
  align-items: stretch;
  background:
    linear-gradient(120deg, #123d43 0%, #0f5f59 58%, #eef3f3 58%, #eef3f3 100%);
}

.login-context {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 54px 48px;
  color: #fff;
}

.login-context h1 {
  max-width: 380px;
  margin: 18px 0 14px;
  font-size: 34px;
  line-height: 1.25;
}

.login-context p {
  max-width: 400px;
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 16px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

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

.login-context-foot {
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.login-panel-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-panel {
  width: min(100%, 420px);
  padding: 34px;
  border: 1px solid #dde5e7;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.login-panel h2 {
  margin: 0 0 6px;
  font-size: 25px;
}

.login-panel .subtext {
  margin: 0 0 26px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field label {
  color: #344750;
  font-size: 13px;
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 107, 98, 0.12);
}

.input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  accent-color: var(--brand);
}

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

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

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

.form-grid .span-3 {
  grid-column: span 3;
}

.check-line {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #344750;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #fff;
  background: var(--brand);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

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

.button.secondary {
  color: #20343c;
  border-color: var(--line-strong);
  background: #fff;
}

.button.secondary:hover {
  border-color: #93a6ad;
  background: #f5f8f8;
}

.button.blue {
  background: var(--blue);
}

.button.blue:hover {
  background: #124a70;
}

.button.amber {
  background: var(--amber);
}

.button.amber:hover {
  background: #915115;
}

.button.danger {
  background: var(--danger);
}

.button.danger:hover {
  background: #892a2a;
}

.button.ghost {
  min-height: 34px;
  padding: 5px 9px;
  color: #35505a;
  border-color: transparent;
  background: transparent;
}

.button.ghost:hover {
  border-color: var(--line);
  background: #f3f6f6;
}

.button.small {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

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

.login-help {
  margin-top: 18px;
  padding: 12px 13px;
  border-left: 3px solid var(--amber);
  background: #fff8ef;
  color: #765025;
  font-size: 13px;
}

.captcha-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px auto;
  align-items: center;
  gap: 8px;
}

.captcha-image {
  width: 160px;
  height: 48px;
  display: block;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #f1f6f5;
  cursor: pointer;
}

.captcha-refresh {
  min-width: 64px;
  padding-right: 9px;
  padding-left: 9px;
  white-space: nowrap;
}

.captcha-loading {
  opacity: 0.55;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  color: #fff;
  background: #123d43;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 5px 21px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

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

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

.sidebar-brand span {
  display: block;
  margin-top: 1px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 5px;
  margin-top: 21px;
}

.nav-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 0;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: #d4eeea;
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
  font-weight: 800;
}

.sidebar-user {
  margin-top: auto;
  padding: 14px 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user strong {
  display: block;
  font-size: 14px;
}

.sidebar-user span {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 12px;
}

.sidebar-user button {
  margin-top: 10px;
  padding: 0;
  border: 0;
  color: #d4eeea;
  background: transparent;
  font-size: 13px;
}

.main-area {
  min-width: 0;
  padding: 27px 30px 40px;
}

.topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topline h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.25;
}

.topline p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.mobile-nav {
  display: none;
}

.mobile-logout {
  display: none;
}

.content-stack {
  display: grid;
  gap: 18px;
}

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

.stat-card {
  min-height: 116px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 7px 20px rgba(22, 45, 52, 0.04);
}

.stat-card .label {
  color: var(--muted);
  font-size: 13px;
}

.stat-card .value {
  margin-top: 8px;
  color: #19353d;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-card .foot {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.stat-card.accent {
  border-color: #c7ddd8;
  background: #f3faf8;
}

.stat-card.warn {
  border-color: #ead5b8;
  background: #fff9f1;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(22, 45, 52, 0.04);
}

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

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 17px;
}

.panel-header .subtle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.panel-body {
  padding: 17px;
}

.panel-body.tight {
  padding: 12px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

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

.property-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.property-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15, 107, 98, 0.11);
}

.property-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.property-card h3 {
  margin: 0;
  font-size: 16px;
}

.property-card .area {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.money {
  color: #17363e;
  font-weight: 800;
  white-space: nowrap;
}

.money.large {
  font-size: 22px;
}

.bill-list {
  display: grid;
  gap: 9px;
}

.mobile-bill-list {
  display: none;
}

.mobile-bill-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.mobile-bill-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.mobile-bill-head strong {
  display: block;
  font-size: 16px;
}

.mobile-bill-lines {
  display: grid;
  gap: 8px;
  margin-top: 13px;
  padding: 11px 0;
  border-top: 1px solid #e7ecee;
  border-bottom: 1px solid #e7ecee;
}

.mobile-bill-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-bill-line span {
  color: var(--muted);
}

.mobile-bill-line strong {
  color: #263f47;
  text-align: right;
}

.mobile-bill-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-top: 12px;
}

.mobile-bill-foot > span {
  color: var(--muted);
  font-size: 13px;
}

.mobile-bill-foot > strong {
  margin-left: auto;
  color: var(--brand-dark);
  font-size: 18px;
}

.bill-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.bill-row:hover {
  border-color: #b5c8cc;
  background: #fbfcfc;
}

.bill-row .meta {
  color: var(--muted);
  font-size: 12px;
}

.bill-row strong {
  display: block;
}

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

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

.data-table th,
.data-table td {
  padding: 10px 11px;
  border-bottom: 1px solid #e7ecee;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  color: #536871;
  background: #f7f9f9;
  font-size: 12px;
  font-weight: 800;
}

.data-table td {
  font-size: 13px;
}

.data-table tbody tr:hover {
  background: #fafcfc;
}

.data-table .actions {
  display: flex;
  gap: 5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  color: #1c6039;
  background: #e7f5eb;
}

.badge.amber {
  color: #87511a;
  background: #fff0dc;
}

.badge.gray {
  color: #536871;
  background: #edf1f2;
}

.badge.red {
  color: #8d2e2e;
  background: #fae8e8;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 9px;
}

.filter-bar .field {
  min-width: 145px;
  margin: 0;
}

.filter-bar .field.wide {
  min-width: 220px;
}

.compact-field {
  display: grid;
  gap: 5px;
  margin: 0;
}

.compact-field label {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  padding: 38px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 5px;
  color: #3a5059;
}

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

.usage-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
}

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

.usage-item .value {
  margin-top: 5px;
  font-size: 20px;
  font-weight: 800;
}

.usage-item .rate {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.bill-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-top: 12px;
  padding: 15px;
  border: 1px solid #d6e5e1;
  border-radius: 6px;
  background: #f2faf7;
}

.bill-total span {
  color: #47625e;
  font-weight: 700;
}

.bill-total strong {
  color: #0a5b52;
  font-size: 28px;
}

.section-title {
  margin: 20px 0 9px;
  font-size: 15px;
}

.mini-bars {
  display: grid;
  gap: 8px;
}

.mini-bar-row {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 84px;
  align-items: center;
  gap: 9px;
  font-size: 12px;
}

.mini-bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeee;
}

.mini-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.mini-bar-fill.amber {
  background: var(--amber);
}

.app-dialog {
  width: min(960px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  box-shadow: 0 25px 80px rgba(12, 33, 39, 0.24);
}

.app-dialog.small {
  width: min(560px, calc(100vw - 28px));
}

.app-dialog::backdrop {
  background: rgba(13, 32, 38, 0.52);
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-body {
  padding: 18px;
}

.dialog-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.close-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #47616a;
  background: #fff;
  font-size: 18px;
}

.close-button:hover {
  background: #f4f7f7;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: min(390px, calc(100vw - 30px));
  padding: 12px 14px;
  border: 1px solid #cdd9dc;
  border-radius: 6px;
  color: #263c44;
  background: #fff;
  box-shadow: var(--shadow);
  animation: toast-in 0.17s ease-out;
}

.toast.error {
  border-color: #e3bcbc;
  color: #7f2a2a;
  background: #fff8f8;
}

.toast.success {
  border-color: #b8dcc5;
  color: #1f6038;
  background: #f5fff8;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.inline-note {
  padding: 10px 12px;
  border-left: 3px solid var(--blue);
  background: #f2f7fb;
  color: #385666;
  font-size: 13px;
}

.credential-box {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #d7e1e4;
  border-radius: 6px;
  background: #f7f9f9;
}

.credential-box strong {
  display: block;
  margin-bottom: 5px;
}

.credential-box code {
  display: inline-block;
  margin-top: 5px;
  padding: 5px 8px;
  border-radius: 4px;
  background: #e8eeee;
  font-size: 15px;
}

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

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

.danger-text {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

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

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

@media (max-width: 860px) {
  .login-page {
    display: block;
    background: #eef3f3;
  }

  .login-context {
    min-height: auto;
    padding: 27px 22px 74px;
    background: #123d43;
  }

  .login-context h1 {
    margin-top: 12px;
    font-size: 27px;
  }

  .login-context-foot {
    display: none;
  }

  .login-panel-wrap {
    min-height: auto;
    margin-top: -52px;
    padding: 0 18px 28px;
  }

  .login-panel {
    padding: 25px 21px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .main-area {
    padding: 18px 14px 88px;
  }

  .topline {
    display: block;
  }

  .top-actions {
    justify-content: flex-start;
    margin-top: 14px;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    overflow-x: hidden;
    padding: 6px max(7px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom))
      max(7px, env(safe-area-inset-left));
    border-top: 1px solid #d7e0e2;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
  }

  .mobile-nav .nav-button {
    min-width: 0;
    min-height: 52px;
    flex: 1 1 0;
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 5px 7px;
    color: #60747c;
    text-align: center;
    font-size: 11px;
  }

  .mobile-nav .nav-button[data-action="logout"] {
    color: var(--danger);
  }

  .mobile-nav .nav-button.active {
    color: var(--brand);
    background: #eef7f5;
  }

  .mobile-nav .nav-icon {
    width: 24px;
    height: 24px;
    color: inherit;
    background: transparent;
  }

  .mobile-logout {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .main-area {
    padding-left: 11px;
    padding-right: 11px;
  }

  .stat-grid,
  .property-grid,
  .usage-grid,
  .form-grid,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2,
  .form-grid .span-3 {
    grid-column: span 1;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .bill-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .bill-row .bill-status {
    grid-column: span 2;
  }

  .captcha-line {
    grid-template-columns: minmax(0, 1fr) 132px;
  }

  .captcha-image {
    width: 132px;
  }

  .captcha-refresh {
    grid-column: span 2;
    width: 100%;
  }

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

  .filter-bar .field,
  .filter-bar .field.wide {
    min-width: 0;
  }

  .desktop-bill-table {
    display: none;
  }

  .mobile-bill-list {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .toast-region {
    right: 10px;
    bottom: 75px;
    left: 10px;
  }

  .toast {
    max-width: none;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .mobile-nav,
  .top-actions,
  .panel-actions,
  .toast-region,
  .dialog-header,
  .dialog-footer {
    display: none !important;
  }

  .app-shell,
  .main-area {
    display: block;
    padding: 0;
  }

  .panel,
  .stat-card {
    box-shadow: none;
  }
}
