* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f4f6f8;
    color: #1f2933;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 26px;
    line-height: 1.25;
}

.topbar p {
    margin-top: 8px;
    color: #5f6b7a;
}

.panel {
    background: #fff;
    border: 1px solid #dce3ea;
    border-radius: 8px;
    margin-top: 18px;
    padding: 18px;
}

.login-panel {
    width: min(460px, 100%);
    margin: 40px auto 0;
}

.login-form {
    display: grid;
    gap: 14px;
}

.login-form input[type="password"] {
    width: 100%;
    min-height: 42px;
    border: 1px solid #c9d3dd;
    border-radius: 6px;
    padding: 10px 12px;
    background: #fff;
    color: #1f2933;
}

.login-form input[type="password"]:focus {
    outline: 2px solid #9ec5fe;
    border-color: #5294e2;
}

.section-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.section-title h2 {
    font-size: 17px;
}

.section-title span {
    color: #657180;
    font-size: 13px;
}

#liveStatus[data-state="ok"] {
    color: #087443;
}

#liveStatus[data-state="error"] {
    color: #b42318;
}

.alert-form {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) auto auto;
    gap: 14px;
    align-items: end;
}

label {
    display: grid;
    gap: 6px;
    color: #52606d;
    font-size: 13px;
}

input,
select,
button {
    font: inherit;
}

input[type="number"],
select {
    width: 100%;
    min-height: 38px;
    border: 1px solid #c9d3dd;
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
    color: #1f2933;
}

input[type="number"]:focus,
select:focus {
    outline: 2px solid #9ec5fe;
    border-color: #5294e2;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
}

.button {
    min-height: 38px;
    border: 1px solid #1b6ac9;
    border-radius: 6px;
    padding: 8px 14px;
    background: #1f73d4;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover {
    background: #195fb0;
}

.button-secondary {
    background: #fff;
    color: #1f73d4;
}

.button-secondary:hover {
    background: #edf5ff;
}

.notice {
    border-radius: 6px;
    margin: 14px 0;
    padding: 11px 13px;
}

.notice-success {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    color: #067647;
}

.notice-error {
    background: #fef3f2;
    border: 1px solid #fecdca;
    color: #b42318;
}

.hidden {
    display: none !important;
}

.table-wrap {
    overflow-x: auto;
}

.mobile-alerts {
    display: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
}

th,
td {
    border-bottom: 1px solid #edf1f5;
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f8fafc;
    color: #52606d;
    font-weight: 600;
    white-space: nowrap;
}

.status {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 8px;
    margin: 0 4px 4px 0;
    font-size: 12px;
    line-height: 18px;
}

.status-on {
    background: #e7f8ee;
    color: #087443;
}

.status-off {
    background: #eef2f6;
    color: #52606d;
}

.status-hit {
    background: #fff4e5;
    color: #b54708;
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    white-space: nowrap;
}

.link-button {
    border: 0;
    background: transparent;
    color: #1f73d4;
    cursor: pointer;
    padding: 0;
}

.link-button.danger {
    color: #c03221;
}

.empty {
    color: #657180;
    padding: 20px 0;
    text-align: center;
}

.live-price {
    display: inline-block;
    min-width: 54px;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease, transform 0.2s ease;
}

.live-price.price-up {
    color: #087443;
    transform: translateY(-1px);
}

.live-price.price-down {
    color: #c03221;
    transform: translateY(1px);
}

.edit-row.hidden {
    display: none;
}

.edit-row td {
    background: #f8fbff;
    padding: 16px 10px;
}

.inline-edit-form {
    display: grid;
    grid-template-columns: minmax(180px, 1.5fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) auto auto;
    gap: 14px;
    align-items: end;
}

.edit-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.compact-button {
    min-height: 36px;
    padding: 8px 12px;
}

.danger-button {
    background: #c03221;
    border-color: #b42318;
}

.danger-button:hover {
    background: #a61e12;
}

.alert-card {
    border: 1px solid #dce3ea;
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.alert-card + .alert-card {
    margin-top: 12px;
}

.alert-card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.alert-card-header h3 {
    margin: 0;
    font-size: 18px;
    line-height: 1.3;
}

.alert-card-header p {
    margin-top: 4px;
    color: #657180;
}

.alert-card-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.alert-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
    margin-top: 14px;
}

.meta-item {
    display: grid;
    gap: 4px;
}

.meta-label {
    color: #657180;
    font-size: 12px;
}

.meta-value {
    color: #1f2933;
    font-size: 15px;
    line-height: 1.35;
    word-break: break-word;
}

.mobile-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.mobile-actions form,
.mobile-actions button {
    width: 100%;
}

.mobile-edit-panel {
    margin-top: 14px;
    border-top: 1px solid #edf1f5;
    padding-top: 14px;
}

.mobile-inline-edit-form {
    grid-template-columns: 1fr;
}

.card-error {
    margin-top: 12px;
    border-radius: 6px;
    background: #fff8f7;
    color: #b42318;
    padding: 10px 12px;
    font-size: 13px;
}

.error-row td {
    background: #fff8f7;
    color: #b42318;
    font-size: 13px;
}

@media (max-width: 900px) {
    .topbar,
    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .alert-form {
        grid-template-columns: 1fr 1fr;
    }

    .inline-edit-form {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 620px) {
    .page {
        width: min(100% - 20px, 1180px);
        padding-top: 18px;
    }

    .panel {
        padding: 14px;
    }

    .desktop-alerts {
        display: none;
    }

    .mobile-alerts {
        display: block;
    }

    .alert-form {
        grid-template-columns: 1fr;
    }

    .inline-edit-form {
        grid-template-columns: 1fr;
    }

    .button,
    .button-secondary {
        width: 100%;
    }

    .topbar {
        gap: 14px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .topbar-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .section-title {
        gap: 8px;
    }

    .section-title span {
        line-height: 1.5;
    }

    .edit-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .alert-card-header,
    .alert-card-status {
        flex-direction: column;
        align-items: flex-start;
    }

    .alert-meta-grid {
        grid-template-columns: 1fr;
    }

    .mobile-actions {
        grid-template-columns: 1fr;
    }
}
