* { box-sizing: border-box; margin: 0; }
:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --line: #e5e9f0;
    --ink: #1b2432;
    --dim: #66748a;
    --brand: #0f5e4a;
    --brand-deep: #0a4636;
    --accent: #c89b3c;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 28, 45, .05), 0 6px 18px -8px rgba(16, 28, 45, .12);
    --sidebar-w: 240px;
    font-size: 15.5px;
}
body {
    font-family: "Segoe UI", "IBM Plex Sans Arabic", Tahoma, system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.7;
}
a { color: var(--brand); text-decoration: none; }
h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 14px; }
p { margin-bottom: 10px; }
ul, ol { padding-inline-start: 22px; margin-bottom: 10px; }
code { background: #eef2f7; border: 1px solid var(--line); padding: 1px 7px; border-radius: 7px; font-size: .85em; direction: ltr; display: inline-block; }
pre { background: #101c2d; color: #d7e3f4; padding: 16px 18px; border-radius: var(--radius); overflow-x: auto; direction: ltr; text-align: left; font-size: .86rem; line-height: 1.6; }
input, select, textarea {
    width: 100%; padding: 10px 13px; border: 1px solid #d3dae4; border-radius: 10px;
    font-family: inherit; font-size: .95rem; background: #fbfcfe; color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 94, 74, .12); background: #fff; }
textarea { min-height: 130px; resize: vertical; }
button, .btn {
    background: var(--brand); color: #fff; border: 0; padding: 10px 22px; border-radius: 10px;
    cursor: pointer; font-family: inherit; font-size: .95rem; font-weight: 600;
    transition: background .15s, transform .1s;
}
button:hover, .btn:hover { background: var(--brand-deep); }
.btn-ghost {
    display: inline-block; background: #fff; color: var(--brand); border: 1.5px solid var(--brand);
    padding: 9px 20px; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: .95rem;
}
.btn-ghost:hover { background: #eef6f3; }
.btn-danger { background: #fff; color: #b42318; border: 1.5px solid #f0b8b2; }
.btn-danger:hover { background: #fdf2f1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; font-weight: 600; color: #3d4a5e; }

/* ============ التخطيط والقائمة الجانبية ============ */
.layout { display: flex; min-height: 100vh; }
.top {
    width: var(--sidebar-w); flex-shrink: 0;
    background: linear-gradient(180deg, #0d3f31 0%, #0a3125 100%);
    color: #dfeae6; padding: 0 14px 22px; position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
}
.brand {
    font-weight: 800; font-size: 1.06rem; color: #fff; padding: 22px 10px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .12); margin-bottom: 14px; letter-spacing: .2px;
    display: flex; align-items: center; gap: 9px;
}
.brand::before {
    content: ""; width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #e8c97e);
    box-shadow: inset 0 0 0 6px rgba(10, 49, 37, .35);
}
.top nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.top nav a {
    color: rgba(223, 234, 230, .78); padding: 10px 14px; border-radius: 10px;
    font-size: .94rem; font-weight: 600; transition: background .15s, color .15s;
}
.top nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.top nav a.on { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.top nav a.out { margin-top: auto; color: rgba(223, 234, 230, .55); font-weight: 500; border-top: 1px solid rgba(255,255,255,.12); border-radius: 0; padding-top: 14px; }
.top nav a.out:hover { color: #fff; background: transparent; }
main { flex: 1; padding: 30px 34px 60px; max-width: 1100px; }

/* ============ المكونات ============ */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; margin-bottom: 20px; }
.grid .panel { margin: 0; padding: 18px; }
.grid .panel b { display: block; font-size: 1.7rem; color: var(--brand); line-height: 1.3; }
.grid .panel span { font-size: .84rem; color: var(--dim); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: right; color: var(--dim); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; padding: 8px 10px; border-bottom: 2px solid var(--line); }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f7faf9; }
tr.new td { background: #fdf8ec; }
tr.new td:first-child { border-inline-start: 3px solid var(--accent); }
.tl { display: flex; flex-direction: column; gap: 0; }
.tl > div { padding: 10px 0 10px 18px; border-inline-start: 2px solid var(--line); position: relative; margin-inline-start: 8px; }
.tl > div::before { content: ""; position: absolute; inset-inline-start: -6px; top: 17px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.tl-time { font-size: .78rem; color: var(--dim); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; align-items: end; margin-bottom: 6px; }
.inline-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline-form input { max-width: 240px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px 26px; }
.fields div { border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.fields dt { font-size: .78rem; color: var(--dim); font-weight: 600; }
.fields dd { font-size: .94rem; }
.dim { color: var(--dim); font-size: .9rem; }
.notice { background: #e8f5ef; border: 1px solid #bfe3d4; color: #14532d; padding: 11px 16px; border-radius: 10px; margin-bottom: 18px; font-size: .92rem; font-weight: 600; }

/* ============ تسجيل الدخول ============ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; max-width: none; }
.login { width: 100%; max-width: 410px; padding: 34px 32px; }
.login h2 { margin-bottom: 6px; }
.login .dim { margin-bottom: 20px; }
.login form { display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .top { width: 100%; height: auto; position: static; padding: 0 16px 6px; }
    .brand { padding: 16px 4px 12px; }
    .top nav { flex-direction: row; overflow-x: auto; gap: 2px; }
    .top nav a { white-space: nowrap; padding: 8px 12px; }
    .top nav a.on { box-shadow: inset 0 -3px 0 var(--accent); }
    .top nav a.out { margin: 0; border: 0; padding-top: 8px; }
    main { padding: 20px 16px 50px; }
}

/* ============ لوحة القمع ============ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.65rem; color: var(--brand); line-height: 1.3; }
.stat span { color: var(--dim); font-size: .84rem; }

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 14px; align-items: start; }
.col { background: #e9edf3; border-radius: var(--radius); padding: 12px; }
.col h3 { margin: 2px 6px 12px; font-size: .95rem; display: flex; justify-content: space-between; align-items: center; }
.count { color: var(--dim); font-weight: 500; font-size: .85rem; background: #fff; border-radius: 999px; padding: 0 10px; }
.empty { color: #9aa5b5; text-align: center; padding: 14px 0; font-size: .82rem; }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, transform .1s; }
.card:hover { border-color: var(--brand); transform: translateY(-1px); }
.card-name { font-weight: 700; }
.card-line { font-size: .88rem; }
.card-line.dim, .dim { color: var(--dim); font-size: .85rem; }
.card-next { margin-top: 7px; font-size: .82rem; color: var(--brand); font-weight: 600; }

.split { display: grid; grid-template-columns: 1fr 1.4fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }
.wide { grid-column: 1 / -1; }

.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 11px; border-radius: 999px; background: #eef1f6; color: var(--dim); vertical-align: middle; }
.badge.s1 { background: #e2f0ea; color: var(--brand); }
.badge.s2, .badge.s3 { background: #e6ecf7; color: #3d5a99; }
.badge.s4 { background: #fbf0dd; color: #96690f; }
.badge.s5 { background: #ececec; color: var(--dim); }
.flag { font-size: .72rem; font-weight: 600; background: #fdeaea; color: #b42318; border-radius: 999px; padding: 1px 9px; }

.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.timeline li { border-bottom: 1px solid var(--line); padding: 10px 0; }
.timeline time { display: block; color: var(--dim); font-size: .76rem; }
.kind { display: inline-block; font-size: .74rem; font-weight: 600; background: #eef1f6; border-radius: 7px; padding: 1px 9px; margin-left: 7px; color: var(--dim); }

button.pill, .pill { display: inline-block; background: #eef1f6; color: var(--dim); border: 0; padding: 3px 13px; font-size: .78rem; font-weight: 600; border-radius: 999px; cursor: pointer; }
button.pill.ok, .pill.ok { background: #e2f0ea; color: var(--brand); }

.webhook { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; background: #f0f4f8; border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin: 12px 0; align-items: center; }
.webhook span { color: var(--dim); font-size: .82rem; font-weight: 600; }

.foot { text-align: center; color: var(--dim); font-size: .8rem; padding: 26px; }
