:root {
    color-scheme: light;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #1f2937;
    background: #f4f6f8;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f4f6f8; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 28px;
    color: #fff;
    background: #111827;
}

.brand { font-size: 20px; font-weight: 700; white-space: nowrap; }
.topbar nav { display: flex; flex: 1; flex-wrap: wrap; gap: 16px; }
.topbar nav a { color: #d1d5db; font-size: 14px; }
.topbar nav a:hover { color: #fff; }
.link-button { border: 0; color: #d1d5db; background: transparent; }

.container { width: min(1180px, calc(100% - 40px)); margin: 32px auto; }
.container.narrow { max-width: 620px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.page-heading h1 { margin: 0; }
.page-heading p { margin: 6px 0 0; color: #6b7280; }
.panel, .metric-card, .login-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 20px rgba(15, 23, 42, .05);
}
.panel { padding: 24px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; }
.metric-card { display: flex; flex-direction: column; padding: 24px; }
.metric-card strong { color: #2563eb; font-size: 34px; }
.metric-card span { margin-top: 8px; color: #6b7280; }

.stack-form { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
label { display: grid; gap: 7px; color: #374151; font-weight: 600; }
input, select, textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    color: #111827;
    background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: #2563eb; outline: 2px solid #bfdbfe; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.form-actions { grid-column: 1 / -1; }
button[type="submit"]:not(.secondary-button), .primary-button {
    border: 0;
    border-radius: 8px;
    padding: 11px 18px;
    color: #fff;
    background: #2563eb;
}
.secondary-button {
    border: 1px solid #d1d5db;
    border-radius: 7px;
    padding: 7px 12px;
    color: #374151;
    background: #fff;
}
.inline-form, .toolbar { display: flex; align-items: end; gap: 14px; margin-bottom: 20px; }
.inline-form label { flex: 1; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.table-panel { overflow-x: auto; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-heading h2 { margin: 0; font-size: 20px; }
.panel-heading p { margin: 6px 0 0; color: #6b7280; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid #e5e7eb; padding: 12px 10px; text-align: left; white-space: nowrap; }
th { color: #4b5563; background: #f9fafb; }
.status { display: inline-block; border-radius: 999px; padding: 3px 9px; font-size: 12px; }
.status.active { color: #166534; background: #dcfce7; }
.status.disabled { color: #6b7280; background: #e5e7eb; }
code { border-radius: 4px; padding: 2px 5px; background: #f3f4f6; }
.detail-list { display: grid; grid-template-columns: 130px 1fr; gap: 12px; }
.detail-list dt { color: #6b7280; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.qr-image { display: block; width: 320px; max-width: 100%; margin: 12px auto; }
.button-row { display: flex; gap: 12px; margin-top: 20px; }
.form-help { grid-column: 1 / -1; color: #6b7280; }
.ranking-vendor-list { display: grid; gap: 0; border: 0; margin: 0; padding: 0; }
.ranking-vendor-list legend { margin-bottom: 8px; color: #374151; font-weight: 700; }
.ranking-vendor-option { min-height: 48px; border-bottom: 1px solid #e5e7eb; padding: 10px 0; }
.ranking-vendor-option:last-child { border-bottom: 0; }
.ranking-vendor-option code { margin-left: auto; color: #6b7280; font-weight: 400; }
.message-preview { border: 1px solid #dbeafe; border-radius: 8px; padding: 12px 14px; background: #eff6ff; }
.message-preview strong { display: block; margin-bottom: 8px; color: #1d4ed8; }
.message-preview pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; color: #1f2937; }
.placeholder-guide { overflow-x: auto; }
.placeholder-guide h2 { margin-top: 0; }
.placeholder-guide td { white-space: normal; vertical-align: top; }
.action-cell { display: flex; gap: 8px; }
.wrap-cell { min-width: 280px; white-space: normal; overflow-wrap: anywhere; }
.alert { margin-bottom: 16px; border-radius: 8px; padding: 12px 14px; }
.alert.success { color: #166534; background: #dcfce7; }
.alert.error, .field-error { color: #b91c1c; }
.alert.error { background: #fee2e2; }
.field-error { font-size: 13px; }
.input-hint { color: #6b7280; font-size: 12px; font-weight: 400; }

.modal-dialog {
    width: min(520px, calc(100% - 32px));
    max-height: calc(100vh - 48px);
    border: 0;
    border-radius: 14px;
    padding: 0;
    color: #1f2937;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}
.modal-dialog::backdrop { background: rgba(15, 23, 42, .48); backdrop-filter: blur(2px); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid #e5e7eb; padding: 20px 22px; }
.modal-header h2 { margin: 0; font-size: 20px; }
.modal-header p { margin: 5px 0 0; color: #6b7280; font-size: 14px; }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 8px; padding: 0; color: #6b7280; background: #f3f4f6; font-size: 24px; line-height: 1; }
.dialog-close:hover { color: #111827; background: #e5e7eb; }
.modal-form { display: grid; gap: 16px; padding: 22px; }
.modal-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.modal-form .alert { margin-bottom: 0; }
.modal-form .form-help { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #e5e7eb; margin: 2px -22px -22px; padding: 16px 22px; background: #f9fafb; }
input[readonly] { color: #6b7280; background: #f9fafb; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 32px; }
.login-card h1 { margin-bottom: 4px; }
.login-card p { margin-top: 0; color: #6b7280; }

@media (max-width: 820px) {
    .topbar { align-items: flex-start; flex-direction: column; padding: 18px; }
    .topbar nav { gap: 10px 14px; }
    .form-grid { grid-template-columns: 1fr; }
    .inline-form, .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar input, .toolbar select { width: 100%; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .page-heading > .primary-button { width: 100%; }
    .modal-field-grid { grid-template-columns: 1fr; }
}
