.api-links, .al-modal {
    --al-navy: #102f46;
    --al-blue: #2474a5;
    --al-text: #263845;
    --al-muted: #738391;
    --al-border: #e2e9ef;
    --al-soft: #f5f8fb;
    --al-green: #1f9d70;
    --al-red: #d65454;
    --al-orange: #e07b12;
    --al-turkuaz: #0f9aa6;
    --al-salah: #6a4fc2;
    color: var(--al-text);
    font-family: 'Cairo', sans-serif;
}
.api-links [hidden], .al-modal[hidden], .al-modal [hidden] { display: none !important; }
/* .wrapper في البرنامج القديم inline-block؛ مع RTL ينزاح لليمين. نجعل الصفحة بعرض الشاشة كاملًا. */
section.wrapper.api-links {
    display: block !important;
    float: none !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 24px;
    box-sizing: border-box;
}

.al-hero {
    display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
    padding: 28px 32px; color: #fff; border-radius: 20px;
    background: radial-gradient(circle at 8% 10%, rgba(89,224,184,.22), transparent 32%), linear-gradient(135deg, #102f46, #155272 60%, #147866 120%);
    box-shadow: 0 16px 40px rgba(16,47,70,.18);
}
.al-eyebrow { display: block; color: #83efd0; font-size: 12px; font-weight: 800; margin-bottom: 4px; }
.al-hero h2 { margin: 0 0 6px; font-size: 30px; font-weight: 900; }
.al-hero p { margin: 0; color: rgba(255,255,255,.78); }

.al-btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; font-family: inherit; font-weight: 700; cursor: pointer; line-height: 1.4; }
.al-btn-primary { color: #fff; background: var(--al-green); }
.al-btn-primary:hover { background: #188760; }
.al-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.al-btn-light { color: var(--al-navy); background: #fff; }
.al-btn-light:hover { background: #eaf3f9; }
.al-btn-ghost { color: var(--al-blue); background: #fff; border-color: var(--al-border); }
.al-btn-ghost:hover { background: var(--al-soft); }
.al-btn-danger { color: var(--al-red); background: #fff; border-color: #f3caca; }
.al-btn-danger:hover { color: #fff; background: var(--al-red); }
.al-btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }

.al-alert { margin: 18px 0 0; padding: 12px 16px; border-radius: 12px; font-weight: 600; }
.al-alert-ok { color: #11694b; background: #e5f6ef; border: 1px solid #bfe7d6; }
.al-alert-err { color: #9b2c2c; background: #fdecec; border: 1px solid #f5c2c2; }

.al-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 18px 0; }
.al-stat { padding: 14px 18px; background: #fff; border: 1px solid var(--al-border); border-radius: 14px; }
.al-stat small { display: block; color: var(--al-muted); font-size: 12px; }
.al-stat strong { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; }
.al-stat .is-green { color: var(--al-green); }
.al-stat .is-blue { color: var(--al-blue); }

.al-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.al-search { position: relative; flex: 1 1 260px; }
.al-search i { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); color: var(--al-muted); }
.al-search input { width: 100%; padding: 9px 36px 9px 12px; border: 1px solid var(--al-border); border-radius: 10px; background: #fff; }
.al-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--al-soft); border: 1px solid var(--al-border); border-radius: 10px; }
.al-chip { padding: 5px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--al-muted); font-family: inherit; font-weight: 700; cursor: pointer; }
.al-chip.is-on { background: #fff; color: var(--al-navy); box-shadow: 0 1px 3px rgba(16,47,70,.12); }

.al-table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--al-border); border-radius: 16px; }
.al-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.al-table th { padding: 12px 14px; color: var(--al-muted); font-size: 12px; font-weight: 800; text-align: right; background: var(--al-soft); border-bottom: 1px solid var(--al-border); }
.al-table td { padding: 12px 14px; border-bottom: 1px solid var(--al-border); vertical-align: middle; }
.al-table tbody tr:last-child td { border-bottom: 0; }
.al-company { display: flex; align-items: center; gap: 12px; }
.al-company strong { display: block; font-size: 15px; }
.al-company small { display: block; color: var(--al-muted); font-size: 12px; }
.al-logo { flex: 0 0 44px; width: 44px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--al-border); border-radius: 10px; }
.al-logo-empty { display: inline-flex; align-items: center; justify-content: center; color: var(--al-blue); background: #eaf3f9; font-weight: 900; font-size: 18px; }
.al-url { direction: ltr; display: inline-block; color: var(--al-blue); }
.al-missing { color: var(--al-red); font-size: 12px; font-weight: 700; }

.al-type { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.al-type-orange { color: var(--al-orange); background: #fff1e2; }
.al-type-turkuaz { color: var(--al-turkuaz); background: #e2f6f7; }
.al-type-salah { color: var(--al-salah); background: #efebfb; }


.al-inline-form { display: inline; margin: 0; }
.al-link { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.al-link-meta { display: flex; align-items: center; gap: 8px; }
.al-link-meta code { padding: 0; color: var(--al-muted); background: none; font-size: 12px; direction: ltr; }
.al-link-actions { display: flex; gap: 6px; }
.al-none { display: inline-block; margin-left: 8px; color: var(--al-muted); font-size: 13px; }
.al-dir-in { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; color: #11694b; background: #e5f6ef; border-radius: 8px; font-size: 12px; font-weight: 700; }

.al-credentials { margin: 18px 0 0; padding: 16px 20px; background: #fffaf0; border: 1px solid #f1d9a6; border-radius: 14px; }
.al-credentials h3 { margin: 0 0 4px; font-size: 16px; font-weight: 900; }
.al-credentials p { margin: 0 0 10px; color: #8a5b10; font-weight: 700; }
.al-credentials dl { margin: 0 0 10px; }
.al-credentials dl div { display: flex; gap: 10px; padding: 3px 0; }
.al-credentials dt { min-width: 90px; color: var(--al-muted); font-weight: 700; }
.al-credentials dd { margin: 0; }
.al-credentials code { color: var(--al-navy); background: #fff; word-break: break-all; }
.al-empty { margin: 0; padding: 30px; color: var(--al-muted); text-align: center; }

body.al-modal-open { overflow: hidden; }
.al-modal { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; background: rgba(16,47,70,.45); }
.al-modal-card { width: 100%; max-width: 720px; background: #fff; border-radius: 18px; box-shadow: 0 24px 60px rgba(16,47,70,.3); }
.al-modal-head, .al-modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 22px; }
.al-modal-head { border-bottom: 1px solid var(--al-border); }
.al-modal-head h3 { margin: 0; font-size: 19px; font-weight: 900; }
.al-modal-foot { justify-content: flex-start; border-top: 1px solid var(--al-border); }
.al-close { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--al-muted); cursor: pointer; }
.al-modal-body { padding: 18px 22px; }
.al-modal fieldset { margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.al-modal legend { width: auto; margin: 0 0 8px; padding: 0; border: 0; font-size: 13px; font-weight: 800; color: var(--al-navy); }
.al-types { display: flex; flex-wrap: wrap; gap: 8px; }
.al-types label { margin: 0; cursor: pointer; }
.al-types input { position: absolute; opacity: 0; }
.al-types .al-type { padding: 8px 18px; font-size: 14px; border: 2px solid transparent; }
.al-types input:checked + .al-type { border-color: currentColor; }
.al-types input:focus-visible + .al-type { outline: 2px solid var(--al-blue); outline-offset: 2px; }
.al-type-fixed { margin: 0 0 16px; padding: 10px 14px; background: var(--al-soft); border-radius: 10px; font-weight: 700; }
.al-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 14px; }
.al-span { grid-column: 1 / -1; }
.al-field { display: block; margin: 0; font-weight: 400; }
.al-field > span { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 700; color: var(--al-text); }
.al-field input[type="text"], .al-field input[type="password"], .al-field select {
    width: 100%; height: 40px; padding: 6px 12px; border: 1px solid var(--al-border); border-radius: 10px; background: #fff; font-family: inherit;
}
.al-field textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--al-border); border-radius: 10px; background: #fff;
    font-family: Consolas, monospace; font-size: 12px; resize: vertical;
}
.al-field input:focus, .al-field select:focus, .al-field textarea:focus { border-color: var(--al-blue); outline: 0; box-shadow: 0 0 0 3px rgba(36,116,165,.15); }
.al-creds { padding: 14px 16px !important; background: var(--al-soft) !important; border-radius: 12px !important; }
.al-creds .al-grid { margin-bottom: 0; }
.al-hint { margin: 8px 0 0; color: var(--al-muted); font-size: 12px; }
.al-hint-box { margin: 0 0 14px; padding: 10px 14px; background: var(--al-soft); border-radius: 10px; font-size: 13px; }
.al-hint-box code { word-break: break-all; }
.al-check { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-weight: 600; cursor: pointer; }
.al-logo-pick { display: flex; align-items: center; gap: 10px; }
.al-logo-pick img { width: 48px; height: 48px; object-fit: contain; border: 1px solid var(--al-border); border-radius: 10px; }
.al-advanced summary { cursor: pointer; color: var(--al-muted); font-weight: 700; margin-bottom: 10px; }

@media (max-width: 640px) {
    .api-links { padding: 12px; }
    .al-hero { padding: 20px; }
    .al-hero h2 { font-size: 24px; }
    .al-grid { grid-template-columns: 1fr; }
    .al-modal { padding: 12px; }
}

.al-stat .is-muted { color: var(--al-muted); }
.al-btn-success { color: #fff; background: var(--al-green); }
.al-btn-success:hover { background: #188760; }
.al-stopped { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; color: #8a5b10; background: #fbf3dc; border-radius: 8px; font-size: 12px; font-weight: 800; }
.al-link.is-stopped .al-type, .al-link.is-stopped .al-url { opacity: .55; }
.al-logo-target .al-check { margin-bottom: 4px; font-size: 13px; }
.al-logo-target input[type="text"] { height: 34px; margin: 2px 0 4px; }
.al-logo-target input[type="text"]:disabled { background: var(--al-soft); }

/* قائمة الصناديق مع بحث */
.al-combo { position: relative; }
/* الـ select الأصلي يبقى في الصفحة (لا display:none) حتى يعمل required ويظهر تنبيه المتصفح بمكانه. */
.al-combo .al-combo-native { position: absolute; bottom: 0; right: 0; width: 100% !important; height: 1px !important; padding: 0 !important; border: 0 !important; opacity: 0; pointer-events: none; }
.al-combo-toggle {
    position: relative; display: block; width: 100%; height: 40px; padding: 6px 12px 6px 34px; overflow: hidden;
    color: var(--al-text); text-align: right; white-space: nowrap; text-overflow: ellipsis;
    background: #fff; border: 1px solid var(--al-border); border-radius: 10px; font-family: inherit; cursor: pointer;
}
.al-combo-toggle:after { content: '\f107'; position: absolute; top: 50%; left: 12px; transform: translateY(-50%); font-family: FontAwesome; color: var(--al-muted); }
.al-combo-toggle.is-placeholder { color: var(--al-muted); }
.al-combo-toggle.is-invalid { border-color: var(--al-red); box-shadow: 0 0 0 3px rgba(214,84,84,.15); }
.al-combo-toggle:focus, .al-combo.is-open .al-combo-toggle { border-color: var(--al-blue); outline: 0; box-shadow: 0 0 0 3px rgba(36,116,165,.15); }
.al-combo-panel {
    position: absolute; top: calc(100% + 4px); right: 0; left: 0; z-index: 20;
    padding: 8px; background: #fff; border: 1px solid var(--al-border); border-radius: 12px; box-shadow: 0 12px 30px rgba(16,47,70,.18);
}
.al-combo-search { width: 100%; height: 36px; margin-bottom: 6px; padding: 6px 10px; border: 1px solid var(--al-border); border-radius: 8px; font-family: inherit; }
.al-combo-search:focus { border-color: var(--al-blue); outline: 0; }
.al-combo-list { max-height: 260px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.al-combo-list li { padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.al-combo-list li.is-active { background: #eaf3f9; }
.al-combo-list li.is-selected { color: var(--al-blue); font-weight: 800; }
.al-combo-list li.al-combo-empty { color: var(--al-muted); cursor: default; text-align: center; }
