:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --line: #e5e9ef;
    --text: #17202a;
    --muted: #687482;
    --blue: #3d8bfd;
    --blue-dark: #276fd1;
    --blue-soft: #eaf3ff;
    --green: #23875b;
    --green-soft: #e9f7f0;
    --red: #c94141;
    --red-soft: #fff0f0;
    --amber: #9a6715;
    --amber-soft: #fff7df;
    --shadow: 0 8px 30px rgba(33, 48, 67, 0.07);
    font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    color: var(--text);
    letter-spacing: 0;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue-dark); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 24px; line-height: 1.25; margin-bottom: 4px; }
h2 { font-size: 17px; line-height: 1.35; margin-bottom: 3px; }
code { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
svg { width: 18px; height: 18px; flex: 0 0 auto; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.block { display: block; color: var(--muted); margin-top: 2px; }

.button, .icon-button, .action-button {
    border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 38px; border-radius: 7px; transition: background-color .16s ease, color .16s ease, border-color .16s ease, opacity .16s ease;
}
.button { padding: 8px 14px; font-weight: 650; white-space: nowrap; }
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { background: #fff; color: #2f3b48; border: 1px solid var(--line); }
.button.secondary:hover { background: #f7f9fc; border-color: #cfd7e1; }
.button.ghost { background: transparent; color: var(--muted); }
.button.danger { background: var(--red-soft); color: var(--red); border: 1px solid #ffd2d2; }
.button.wide { width: 100%; }
.button.disabled, .button:disabled, .icon-button:disabled, .action-button:disabled { opacity: .45; pointer-events: none; }
.icon-button { width: 36px; height: 36px; min-height: 36px; padding: 0; color: #556170; background: #fff; border: 1px solid var(--line); }
.icon-button:hover { color: var(--blue-dark); background: var(--blue-soft); border-color: #c7dcfa; }
.icon-button.danger:hover { color: var(--red); background: var(--red-soft); border-color: #ffd2d2; }
.icon-button.copied { color: var(--green); background: var(--green-soft); }

label { display: grid; gap: 6px; color: #34414f; font-weight: 600; }
label small { color: var(--muted); font-weight: 400; }
input, select, textarea {
    width: 100%; border: 1px solid #d9e0e8; border-radius: 7px; background: #fff; color: var(--text); min-height: 40px; padding: 8px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #87b8f8; box-shadow: 0 0 0 3px rgba(61, 139, 253, .11); }
input::placeholder, textarea::placeholder { color: #a0a9b4; }
textarea { resize: vertical; }

.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 750; font-size: 16px; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 7px; background: var(--blue); color: #fff; font-weight: 800; }
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; z-index: 30; }
.sidebar .brand { padding: 0 9px 22px; }
.nav-list { display: grid; gap: 4px; }
.nav-item { min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 7px; color: #4a5664; font-weight: 600; }
.nav-item:hover { background: #f5f8fc; color: var(--text); }
.nav-item.active { background: var(--blue-soft); color: var(--blue-dark); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.admin-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.admin-main { min-width: 0; }
.topbar { min-height: 82px; padding: 17px 28px; display: flex; align-items: center; gap: 14px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 21px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.mobile-menu { display: none; }
.content-wrap { padding: 24px 28px 40px; max-width: 1600px; margin: 0 auto; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.narrow-panel { max-width: 800px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading p { color: var(--muted); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { min-height: 126px; position: relative; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: var(--shadow); overflow: hidden; }
.stat-card span { color: var(--muted); font-weight: 600; }
.stat-card strong { display: block; margin-top: 11px; font-size: 28px; line-height: 1; }
.stat-card > svg { position: absolute; right: 16px; top: 16px; width: 23px; height: 23px; color: #76a9ee; }
.warning-card > svg { color: var(--amber); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(310px, .8fr); gap: 20px; }
.dashboard-grid .panel { margin: 0; }
.project-bars { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: minmax(130px, 190px) minmax(90px, 1fr) 35px; gap: 12px; align-items: center; }
.bar-row div:first-child { min-width: 0; }
.bar-row strong, .bar-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row span { color: var(--muted); font-size: 11px; }
.bar-track { width: 100%; height: 8px; border: 0; border-radius: 4px; overflow: hidden; background: #eef2f7; appearance: none; }
.bar-track::-webkit-progress-bar { background: #eef2f7; border-radius: 4px; }
.bar-track::-webkit-progress-value { background: var(--blue); border-radius: 4px; }
.bar-track::-moz-progress-bar { background: var(--blue); border-radius: 4px; }
.bar-row b { text-align: right; }
.activity-list { display: grid; gap: 4px; }
.activity-item { display: flex; gap: 11px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #edf0f4; }
.activity-item:last-child { border-bottom: 0; }
.activity-item strong, .activity-item small { display: block; }
.activity-item strong { font-size: 13px; }
.activity-item small { color: var(--muted); margin-top: 3px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: #9aa5b1; }
.status-dot.success { background: var(--green); }.status-dot.failure { background: var(--red); }.status-dot.info { background: var(--blue); }

.inline-form, .filter-bar { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.inline-form label, .filter-bar label { min-width: 145px; }
.inline-form .grow { flex: 1 1 240px; }
.generate-form label:first-of-type { min-width: 220px; }
.form-stack { display: grid; gap: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.input-suffix { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.input-suffix input { border-radius: 7px 0 0 7px; }
.input-suffix span { height: 40px; min-width: 46px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #d9e0e8; border-left: 0; border-radius: 0 7px 7px 0; background: #f7f9fb; color: var(--muted); }
.config-meta { align-self: end; min-height: 40px; display: flex; flex-direction: column; justify-content: center; gap: 2px; color: var(--muted); font-size: 12px; }
.generated-output { min-height: 150px; font-family: Consolas, monospace; font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 650; background: #fafbfd; white-space: nowrap; }
tbody tr:hover { background: #fbfcfe; }
.actions-cell { text-align: right; white-space: nowrap; }
.inline-action { display: inline-flex; vertical-align: middle; }
.row-menu { display: inline-block; position: relative; vertical-align: middle; }
.row-menu summary { list-style: none; }
.row-menu summary::-webkit-details-marker { display: none; }
.popover-form { position: absolute; z-index: 10; right: 0; top: 42px; width: 280px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 14px 38px rgba(25, 38, 55, .16); padding: 15px; display: grid; gap: 12px; text-align: left; }
.link-cell { display: flex; align-items: center; gap: 7px; max-width: 340px; }
.link-cell code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.success { color: var(--green); background: var(--green-soft); }.badge.failure, .badge.error { color: var(--red); background: var(--red-soft); }.badge.info { color: var(--blue-dark); background: var(--blue-soft); }.badge.muted { color: #6c7681; background: #eef1f4; }
.empty-state { text-align: center; padding: 28px 12px; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 18px; color: var(--muted); }
.alert { border-radius: 7px; padding: 11px 13px; margin-bottom: 15px; border: 1px solid var(--line); }
.alert.success { background: var(--green-soft); color: #176f4a; border-color: #ccecdc; }.alert.error { background: var(--red-soft); color: #a92f2f; border-color: #ffd6d6; }.alert.info { background: var(--blue-soft); color: var(--blue-dark); border-color: #d2e5ff; }

.auth-body { display: grid; place-items: center; padding: 24px; background: #f4f7fb; }
.auth-panel { width: min(100%, 420px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 28px; }
.auth-brand { margin-bottom: 24px; }
.auth-panel h1 { font-size: 22px; margin-bottom: 20px; }

.install-body { background: #f4f7fb; }
.install-shell { width: min(100% - 28px, 920px); margin: 0 auto; padding: 28px 0 56px; }
.install-header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.install-form { display: grid; gap: 0; }
.install-requirements { box-shadow: none; }
.requirement-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.requirement-grid > div { min-height: 82px; position: relative; padding: 13px; border: 1px solid var(--line); border-radius: 7px; background: #fafbfd; overflow: hidden; }
.requirement-grid span, .requirement-grid strong { display: block; }
.requirement-grid span { color: var(--muted); font-size: 12px; }
.requirement-grid strong { margin-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.requirement-grid svg { position: absolute; right: 10px; top: 10px; }
.requirement-grid svg.requirement-good { color: var(--green); }
.requirement-grid svg.requirement-bad { color: var(--red); }
.install-submit { width: 100%; min-height: 48px; font-size: 15px; }

.public-body { background: #f7f9fc; }
.public-shell { width: min(100% - 28px, 720px); margin: 0 auto; padding: 24px 0 44px; }
.public-header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.public-brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 750; }
.public-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 26px; }
.landing-state { padding-top: 80px; }
.landing-state .public-brand { justify-content: center; margin-bottom: 20px; }
.center-state { min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.center-state > svg { width: 40px; height: 40px; color: #8ca2ba; margin-bottom: 18px; }
.center-state h1 { font-size: 21px; }
.center-state p { margin: 6px 0 0; color: var(--muted); }
.task-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.task-heading h1 { font-size: 23px; margin: 4px 0 0; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 650; }
.project-id { font-family: Consolas, monospace; color: var(--muted); font-size: 12px; background: #f4f6f9; padding: 5px 8px; border-radius: 6px; }
.phone-display { padding: 30px 0 20px; text-align: center; }
.phone-display > span { color: var(--muted); font-weight: 600; }
.phone-display > div { min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px; }
.phone-display strong { font-family: Consolas, monospace; font-size: 34px; line-height: 1.2; }
.poll-status { height: 42px; padding: 0 12px; border-radius: 7px; background: #f5f8fc; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; color: #4e5c6b; }
.poll-status b { font-family: Consolas, monospace; color: var(--blue-dark); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px rgba(61,139,253,.12); }
.public-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.action-button { min-height: 72px; flex-direction: column; background: #fff; color: #394654; border: 1px solid var(--line); font-weight: 650; }
.action-button:hover { border-color: #b8d4f8; background: var(--blue-soft); color: var(--blue-dark); }
.action-button.danger-soft:hover { border-color: #ffd0d0; background: var(--red-soft); color: var(--red); }
.result-band { margin-top: 20px; padding: 20px; border: 1px solid #cbe9da; border-radius: 8px; background: var(--green-soft); text-align: center; }
.result-band > span { color: var(--green); font-weight: 650; }
.code-line { min-height: 55px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.code-line strong { font-family: Consolas, monospace; font-size: 32px; }
.result-band p { margin: 8px 0 0; color: #385448; overflow-wrap: anywhere; }
.receive-panel > .button.wide { margin-top: 15px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); padding: 10px 15px; border-radius: 7px; box-shadow: 0 8px 25px rgba(22,33,47,.16); background: #24303d; color: #fff; }
.toast.success { background: #176f4a; }.toast.error { background: #a92f2f; }
.modal { width: min(92vw, 440px); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 50px rgba(26, 38, 54, .22); padding: 20px; }
.modal::backdrop { background: rgba(32, 42, 54, .4); }
.modal-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-heading h2 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.sidebar-backdrop { display: none; }

@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
    .admin-shell { display: block; }
    .sidebar { position: fixed; left: 0; top: 0; width: 238px; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 8px 0 30px rgba(24,36,52,.12); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(24,34,46,.35); }
    .sidebar-backdrop.show { display: block; }
    .mobile-menu { display: inline-flex; }
    .topbar { min-height: 72px; padding: 14px 18px; }
    .content-wrap { padding: 18px 16px 34px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .requirement-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 580px) {
    body { font-size: 13px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-card { min-height: 108px; padding: 15px; }
    .stat-card strong { font-size: 24px; }
    .panel { padding: 15px; }
    .inline-form, .filter-bar { align-items: stretch; }
    .inline-form label, .filter-bar label, .inline-form .grow { width: 100%; min-width: 0; flex-basis: 100%; }
    .inline-form > .button, .filter-bar > .button { flex: 1; }
    .section-heading { align-items: flex-start; }
    .bar-row { grid-template-columns: 105px 1fr 28px; gap: 8px; }
    .auth-panel { padding: 22px 18px; }
    .install-shell { width: min(100% - 20px, 920px); padding-top: 14px; }
    .requirement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .public-shell { width: min(100% - 20px, 720px); padding-top: 12px; }
    .public-panel { padding: 19px 15px; }
    .phone-display strong { font-size: 27px; overflow-wrap: anywhere; }
    .public-actions { gap: 7px; }
    .action-button { min-height: 68px; padding: 6px; }
    .task-heading h1 { font-size: 20px; }
    .code-line strong { font-size: 28px; }
    .pagination { justify-content: space-between; }
    .pagination .button { padding: 8px 10px; }
}
