/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f4f6f9;
    color: #2c3e50;
    font-size: 14px;
}

/* ===== Login ===== */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-container {
    background: #fff; padding: 40px; border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3); width: 380px;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-header h1 { font-size: 30px; }
.login-header p { color: #888; margin-top: 6px; }
.error-message { color: #e74c3c; margin-top: 12px; text-align: center; display: none; }

/* Optional field hint */
.optional {
    color: #aaa;
    font-size: 12px;
    font-weight: normal;
}

/* ===== Layout ===== */
.app-container { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px; background: #1f2a44; color: #fff;
    display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-header {
    padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-header h2 { font-size: 20px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav .nav-item {
    padding: 13px 22px; cursor: pointer; list-style: none;
    transition: background .2s; border-left: 3px solid transparent;
}
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,.08); }
.sidebar-nav .nav-item.active {
    background: rgba(102,126,234,.25); border-left-color: #667eea;
}
.sidebar-footer { padding: 18px; border-top: 1px solid rgba(255,255,255,.1); }

.main-content { flex: 1; padding: 28px 32px; overflow-y: auto; }
.page { display: none; }
.page.active { display: block; }
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 22px;
}
.page-header h1 { font-size: 24px; }

/* ===== Buttons ===== */
.btn {
    padding: 9px 18px; border: none; border-radius: 6px; cursor: pointer;
    font-size: 14px; transition: all .2s; background: #e9ecef; color: #333;
}
.btn:hover { transform: translateY(-1px); opacity: .92; }
.btn-primary { background: linear-gradient(135deg,#667eea,#764ba2); color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-outline { background: #fff; border: 1px solid #ccd; color: #555; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 7px; font-weight: 500; color: #444; }
.form-control {
    width: 100%; padding: 10px 13px; border: 1px solid #d5dae0;
    border-radius: 6px; font-size: 14px; transition: border-color .2s;
}
.form-control:focus { outline: none; border-color: #667eea; }
.form-help { display: block; margin-top: 5px; color: #999; font-size: 12px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ===== Filter bar ===== */
.filter-bar { display: flex; gap: 12px; margin-bottom: 18px; }
.filter-bar .form-control { max-width: 320px; }
.filter-bar select { max-width: 150px; }

/* ===== Table ===== */
.data-table {
    width: 100%; background: #fff; border-radius: 8px; overflow: hidden;
    border-collapse: collapse; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.data-table th, .data-table td {
    padding: 13px 16px; text-align: left; border-bottom: 1px solid #eef1f4;
}
.data-table th { background: #f8f9fb; font-weight: 600; color: #555; }
.data-table tr:hover td { background: #fafbfc; }
.empty-state { text-align: center; color: #999; padding: 50px; }

/* ===== Badges & status ===== */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    background: #e9ecef; font-size: 12px; color: #555;
}
.status-badge {
    padding: 3px 10px; border-radius: 12px; font-size: 12px;
}
.status-badge.online { background: #27ae60; color: #fff; }
.status-badge.offline { background: #95a5a6; color: #fff; }
.tag-published { color: #27ae60; font-weight: 600; }
.tag-draft { color: #e67e22; font-weight: 600; }

/* ===== Config card ===== */
.config-card {
    background: #fff; padding: 26px; border-radius: 8px; max-width: 640px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 20px;
}
.status-info { margin-top: 16px; padding: 12px; border-radius: 6px;
    background: #f8f9fb; font-size: 13px; display: none; }
.status-info.show { display: block; }
.status-info.ok { background: #e8f8f0; color: #1e7e4f; }
.status-info.err { background: #fdecea; color: #c0392b; }
.hint-box {
    background: #fff8e6; border: 1px solid #ffe3a3; border-radius: 8px;
    padding: 18px 22px; max-width: 640px;
}
.hint-box h4 { margin-bottom: 10px; }
.hint-box p { margin: 5px 0; color: #6b5a2e; }
.hint-box code {
    background: #fff; padding: 2px 6px; border-radius: 4px; color: #c0392b;
}

/* ===== Modal ===== */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; }
.modal.show { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-content {
    position: relative; background: #fff; width: 900px; max-width: 94%;
    margin: 4vh auto; border-radius: 10px; max-height: 90vh;
    display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-header {
    padding: 18px 24px; border-bottom: 1px solid #eee;
    display: flex; align-items: center; justify-content: space-between;
}
.modal-close { background: none; border: none; font-size: 26px; cursor: pointer; color: #999; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid #eee;
    display: flex; justify-content: flex-end; gap: 12px;
}
.modal-grid { display: grid; grid-template-columns: 1fr 300px; gap: 26px; }

/* ===== Buttons section (dynamic rows) ===== */
.buttons-section { margin: 18px 0; padding: 16px; background: #f8f9fb; border-radius: 8px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.button-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.button-row .form-control { margin: 0; }
.btn-text-input { flex: 0 0 140px; }
.btn-url-input { flex: 1; }
.btn-remove {
    flex: 0 0 34px; height: 38px; background: #fdecea; color: #e74c3c;
    border: none; border-radius: 6px; cursor: pointer; font-size: 18px;
}
.btn-remove:hover { background: #f9d5d0; }

/* ===== Toggle ===== */
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* ===== Telegram preview ===== */
.modal-preview h4 { margin-bottom: 12px; color: #555; }
.tg-card {
    background: #eef2f5; border-radius: 12px; padding: 14px;
    min-height: 80px;
}
.tg-bubble {
    background: #fff; border-radius: 10px; padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,.1); margin-bottom: 8px;
}
.tg-bubble .tg-title { font-weight: 700; margin-bottom: 6px; color: #1f2a44; }
.tg-bubble .tg-desc { color: #4a5568; white-space: pre-wrap; font-size: 13px; }
.tg-btn {
    display: block; background: #fff; color: #2481cc; text-align: center;
    padding: 9px; border-radius: 8px; margin-top: 6px; font-size: 13px;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* ===== Toast ===== */
.toast {
    position: fixed; top: 24px; right: 24px; background: #333; color: #fff;
    padding: 13px 20px; border-radius: 8px; opacity: 0; transform: translateY(-12px);
    transition: all .3s; z-index: 2000; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: #27ae60; }
.toast.err { background: #e74c3c; }

/* ===== Action links in table ===== */
.action-link { color: #667eea; cursor: pointer; margin-right: 12px; }
.action-link:hover { text-decoration: underline; }
.action-link.danger { color: #e74c3c; }
