:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #e5e7eb;
  --text: #17191c;
  --muted: #73777f;
  --green: #1f6feb;
  --green-2: #175cc5;
  --red: #d64545;
  --shadow: 0 10px 30px rgba(17, 24, 39, .06);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.25rem, 3vw, 1.75rem); }
h2 { margin-bottom: 0; font-size: 1.1rem; }

.eyebrow { margin-bottom: .35rem; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .08em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.login-page { display: grid; place-items: center; padding: 1.25rem; }
.login-shell { width: min(100%, 430px); }
.login-card, .panel, .stat-card, dialog {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-card { padding: clamp(1.5rem, 5vw, 2.5rem); border-radius: 14px; }
.login-card h1 { font-size: 1.65rem; }
.brand-mark {
  display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 1.25rem;
  overflow: hidden; border: 1px solid var(--border); border-radius: 50%; background: #fff;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-mark-small { width: 42px; height: 42px; margin: 0; }

.stack-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
label { display: grid; gap: .45rem; color: #4b5058; font-size: .84rem; font-weight: 650; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 0 .85rem; border: 1px solid #d8dbe0; border-radius: 8px;
  color: var(--text); background: #fff; outline: none; transition: border-color .2s, box-shadow .2s;
}
textarea { padding-top: .7rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31, 111, 235, .10); }

.btn { min-height: 40px; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 8px; color: var(--text); font-weight: 700; }
.btn-primary { color: #fff; background: var(--text); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-secondary { border-color: var(--border); background: #fff; }
.btn-danger { border-color: #f0caca; color: var(--red); background: #fffafa; }
.btn-block { width: 100%; }

.alert { margin: 1rem 0; padding: .8rem 1rem; border-radius: 9px; font-size: .88rem; }
.alert-error { border: 1px solid #f0caca; color: #a82f36; background: #fff6f6; }
.alert-success { border: 1px solid #bfe2cb; color: #267342; background: #f4fbf6; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: 1rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
}
.brand-row { display: flex; align-items: center; gap: .9rem; }
.brand-row .eyebrow { margin-bottom: .2rem; }
.page-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 3rem; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat-card { padding: 1rem 1.15rem; border-radius: 14px; }
.stat-card span { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .78rem; }
.stat-card strong { font-size: 1.35rem; }
.status-online { color: #267342; }
.panel { padding: 1.2rem; margin-bottom: 1rem; border-radius: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: 1.25fr 1.25fr .85fr .8fr auto auto; align-items: end; gap: .8rem; }
.check-field { display: flex; align-items: center; gap: .5rem; min-height: 44px; white-space: nowrap; }
.check-field input { width: 18px; min-height: 18px; accent-color: var(--green); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th, td { padding: .85rem .7rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .84rem; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .04em; }
td { color: #363a40; }
.loading { padding: 2rem; text-align: center; color: var(--muted); }
.badge { display: inline-flex; padding: .25rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.badge-green { color: #267342; background: #edf8f1; }
.badge-gray { color: #666b73; background: #f1f2f4; }
.actions { display: flex; gap: .45rem; }
.actions .btn { min-height: 34px; padding: .4rem .65rem; font-size: .76rem; }

dialog { width: min(92vw, 430px); padding: 0; border-radius: 16px; color: var(--text); }
dialog::backdrop { background: rgba(17, 24, 39, .36); backdrop-filter: blur(2px); }
.dialog-card { display: grid; gap: 1rem; padding: 1.25rem; }
.dialog-card .panel-head { margin-bottom: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .5rem; }
.icon-btn { border: 0; color: var(--muted); background: transparent; font-size: 1.6rem; }
.account-dialog { width: min(94vw, 620px); max-height: 88vh; overflow: auto; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 0; }
.detail-grid div { padding: .75rem; border-radius: 9px; background: var(--surface-2); }
.detail-grid dt { color: var(--muted); font-size: .72rem; }
.detail-grid dd { margin: .25rem 0 0; font-size: .86rem; font-weight: 700; }
.settings-list { display: grid; gap: .7rem; padding-top: .2rem; }
.setting-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: .7rem; }
.setting-row .btn { min-width: 104px; }
.dialog-actions-split { justify-content: space-between; }

@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .btn { width: 100%; }
}
@media (max-width: 640px) {
  .topbar { align-items: flex-start; }
  .brand-row .eyebrow { display: none; }
  .topbar h1 { font-size: 1.05rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .panel { padding: 1rem; }
  .page-shell { width: min(100% - 1rem, 1180px); }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .setting-row { grid-template-columns: 1fr; }
  .setting-row .btn { width: 100%; }
}
