:root {
    --ink: #0e2233;
    --ink-2: #17344b;
    --teal: #0fa38b;
    --teal-dark: #0b7f6c;
    --teal-soft: #e3f6f2;
    --bg: #f2f5f4;
    --surface: #ffffff;
    --line: #dce4e2;
    --text: #12222d;
    --muted: #5d6f78;
    --wait: #9a6200;  --wait-bg: #fff3d1;
    --info: #1b55c0;  --info-bg: #e5edff;
    --move: #0b7f6c;  --move-bg: #dcf5ef;
    --done: #12784f;  --done-bg: #dcf3e6;
    --back: #bb2d2d;  --back-bg: #fde6e6;
    --jt: #d6001c;
    --radius: 14px;
    --side: 236px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: 'IBM Plex Sans Arabic', 'Cairo', Tahoma, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid rgba(15, 163, 139, 0.45); outline-offset: 2px; }

.side { position: fixed; top: 0; right: 0; bottom: 0; width: var(--side); background: var(--ink); color: #c8d6df; display: flex; flex-direction: column; z-index: 40; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px; }
.side-brand img { width: 44px; height: 44px; border-radius: 12px; background: #fff; object-fit: contain; padding: 2px; }
.side-brand b { display: block; color: #fff; font-size: 15px; font-weight: 700; letter-spacing: 0.3px; line-height: 1.2; direction: ltr; text-align: right; }
.side-brand span { font-size: 12px; color: #8fa6b4; }
.side-nav { flex: 1; padding: 6px 10px; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; font-weight: 500; margin-bottom: 2px; transition: background 0.12s, color 0.12s; }
.side-nav a i { width: 20px; text-align: center; font-size: 15px; color: #7f97a6; }
.side-nav a:hover { background: var(--ink-2); color: #fff; }
.side-nav a.on { background: var(--teal); color: #fff; font-weight: 600; }
.side-nav a.on i { color: #fff; }
.side-nav .gap { height: 1px; background: #1f3e56; margin: 10px 6px; }
.side-foot { padding: 10px; border-top: 1px solid #1f3e56; }
.side-foot a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.side-foot a:hover { background: var(--ink-2); color: #fff; }
.side-foot a.out { color: #ff9c9c; }

.main { margin-right: var(--side); min-height: 100vh; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 28px 6px; flex-wrap: wrap; }
.top h1 { font-size: 24px; font-weight: 700; line-height: 1.3; }
.top p { color: var(--muted); font-size: 14px; }
.top .spacer { flex: 1; }
.top-logo { display: none; }
.wrap { padding: 14px 28px 60px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1.5px solid transparent; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background 0.12s, border-color 0.12s; min-height: 42px; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: #b9c7c4; background: #f8faf9; }
.btn-danger { background: var(--back-bg); color: var(--back); }
.btn-danger:hover { background: #fbd5d5; }
.btn-jt { background: var(--jt); color: #fff; }
.btn-jt:hover { background: #b30017; }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: 0.6; cursor: wait; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px; }
.card h2 { font-size: 17px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.card h2 i { color: var(--teal); font-size: 15px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.note { padding: 12px 14px; border-radius: 10px; font-weight: 500; font-size: 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.note i { margin-top: 4px; }
.note-ok { background: var(--done-bg); color: var(--done); }
.note-bad { background: var(--back-bg); color: var(--back); }
.note-warn { background: var(--wait-bg); color: var(--wait); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line); font-weight: 600; font-size: 14px; white-space: nowrap; flex-shrink: 0; }
.tab b { font-weight: 700; background: var(--bg); border-radius: 999px; padding: 0 8px; font-size: 13px; min-width: 26px; text-align: center; }
.tab:hover { border-color: #b9c7c4; }
.tab.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab.on b { background: rgba(255, 255, 255, 0.18); color: #fff; }
.tab .dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.wait { background: #e0a100; } .dot.info { background: #3b76e8; } .dot.move { background: var(--teal); } .dot.done { background: #17a065; } .dot.back { background: #dd4646; }

.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { flex: 1; min-width: 220px; position: relative; }
.search i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding: 10px 40px 10px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; min-height: 44px; }
.search input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 163, 139, 0.15); }

.bulk { display: none; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; position: sticky; top: 8px; z-index: 20; }
.bulk.show { display: flex; }
.bulk b { font-weight: 700; margin-inline-end: auto; }
.bulk .btn { min-height: 36px; padding: 6px 12px; font-size: 13px; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 34px 150px minmax(0, 1.9fr) minmax(0, 0.7fr) 118px 176px 212px; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row:hover { background: #fafcfb; }
.row.head { background: #f7f9f8; color: var(--muted); font-size: 13px; font-weight: 600; padding: 10px 16px; }
.row.head:hover { background: #f7f9f8; }
.row input[type="checkbox"], .head input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--teal); cursor: pointer; }
.code { display: block; font-weight: 700; direction: ltr; text-align: right; font-size: 14px; letter-spacing: 0.2px; }
a.code:hover { color: var(--teal-dark); text-decoration: underline; }
.code-jt { display: inline-flex; align-items: center; gap: 5px; direction: ltr; font-size: 12px; font-weight: 600; color: var(--jt); background: #ffeef0; padding: 1px 7px; border-radius: 6px; margin-top: 3px; }
.when { font-size: 12px; color: var(--muted); direction: ltr; text-align: right; }
.route { min-width: 0; }
.route .leg { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.route .leg + .leg { margin-top: 4px; }
.route .leg i { font-size: 11px; width: 14px; text-align: center; flex-shrink: 0; }
.route .from i { color: var(--muted); }
.route .to i { color: var(--teal); }
.route .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route .from .nm { font-weight: 500; color: var(--muted); }
.route .pl { font-size: 13px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.route .ph { font-size: 13px; direction: ltr; color: var(--muted); flex-shrink: 0; }
.what { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.what small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.amt b { font-size: 16px; font-weight: 700; display: block; line-height: 1.3; }
.amt small { font-size: 12px; color: var(--muted); display: block; }
.amt .nocod { font-size: 11px; font-weight: 600; color: var(--info); background: var(--info-bg); padding: 0 6px; border-radius: 5px; display: inline-block; }

.st { appearance: none; -webkit-appearance: none; width: 100%; border: none; border-radius: 999px; padding: 7px 14px 7px 30px; font-weight: 600; font-size: 13px; cursor: pointer; background-repeat: no-repeat; background-position: left 12px center; background-size: 10px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23000' stroke-opacity='.55' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E"); }
.st.wait { background-color: var(--wait-bg); color: var(--wait); }
.st.info { background-color: var(--info-bg); color: var(--info); }
.st.move { background-color: var(--move-bg); color: var(--move); }
.st.done { background-color: var(--done-bg); color: var(--done); }
.st.back { background-color: var(--back-bg); color: var(--back); }
.scan { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 5px; align-items: baseline; overflow: hidden; }
.scan span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan i { font-size: 10px; color: var(--jt); }

.acts { display: flex; gap: 6px; justify-content: flex-end; }
.ic { width: 36px; height: 36px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: var(--bg); color: var(--muted); border: none; cursor: pointer; font-size: 14px; transition: background 0.12s, color 0.12s; flex-shrink: 0; }
.ic:hover { background: var(--teal-soft); color: var(--teal-dark); }
.ic.jt { background: #ffeef0; color: var(--jt); }
.ic.jt:hover { background: var(--jt); color: #fff; }
.ic.ok { background: var(--done-bg); color: var(--done); }
.ic.ok:hover { background: var(--done); color: #fff; }
.ic.wa:hover { background: #dcf8e6; color: #128c4a; }
.ic.del:hover { background: var(--back-bg); color: var(--back); }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty i { font-size: 30px; color: #b5c4c1; display: block; margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 16px; }
.pager span { color: var(--muted); font-size: 14px; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.f { min-width: 0; }
.f.wide { grid-column: 1 / -1; }
.f label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.f input, .f select, .f textarea { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; min-height: 44px; }
.f textarea { min-height: 70px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 163, 139, 0.15); }
.f input[readonly] { background: var(--bg); font-weight: 700; }
.f .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.f input[type="tel"], .f input[type="number"], .f input.ltr-in { direction: ltr; text-align: right; }
.savebar { position: sticky; bottom: 0; background: rgba(242, 245, 244, 0.94); backdrop-filter: blur(6px); padding: 12px 0; margin-top: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; z-index: 15; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 600; overflow-wrap: anywhere; }

.trail { list-style: none; margin-top: 6px; }
.trail li { position: relative; padding: 0 38px 16px 0; }
.trail li:last-child { padding-bottom: 0; }
.trail li::before { content: ''; position: absolute; right: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.trail li:last-child::before { display: none; }
.trail .pin { position: absolute; right: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--bg); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.trail li.latest .pin { background: var(--teal); color: #fff; }
.trail b { display: block; font-weight: 600; font-size: 14px; }
.trail small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.switch-row { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-of-type { border-bottom: none; }
.switch-row b { display: block; font-weight: 600; }
.switch-row span { display: block; color: var(--muted); font-size: 13px; }
.toggle { position: relative; width: 46px; height: 26px; flex-shrink: 0; margin-top: 2px; }
.toggle input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; margin: 0; }
.toggle i { position: absolute; inset: 0; background: #c3cfcc; border-radius: 999px; transition: background 0.15s; }
.toggle i::after { content: ''; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.toggle input:checked + i { background: var(--teal); }
.toggle input:checked + i::after { transform: translateX(-20px); }
.toggle input:focus-visible + i { outline: 3px solid rgba(15, 163, 139, 0.45); outline-offset: 2px; }

.copy { display: flex; gap: 8px; }
.copy input { flex: 1; min-width: 0; direction: ltr; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 13px; }

.gov-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.gov { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 8px 8px; }
.gov b { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gov input { width: 84px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; direction: ltr; text-align: center; font-weight: 700; outline: none; }
.gov input:focus { border-color: var(--teal); }
.gov small { color: var(--muted); }

.rev { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.rev .card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.rev .stars { color: #e0a100; font-size: 13px; letter-spacing: 2px; }
.rev p { font-size: 14px; flex: 1; }
.rev .foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill.wait { background: var(--wait-bg); color: var(--wait); } .pill.done { background: var(--done-bg); color: var(--done); }
.pill.info { background: var(--info-bg); color: var(--info); } .pill.move { background: var(--move-bg); color: var(--move); } .pill.back { background: var(--back-bg); color: var(--back); }

.toast { position: fixed; bottom: 24px; left: 24px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; display: none; align-items: center; gap: 12px; z-index: 60; max-width: calc(100vw - 48px); }
.toast.show { display: flex; }
.toast a { color: #7fe6d3; font-weight: 700; text-decoration: underline; }

.tabbar { display: none; }

.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-art { background: var(--ink); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 60px; }
.login-art img { width: 120px; height: 120px; background: #fff; border-radius: 28px; padding: 6px; object-fit: contain; margin-bottom: 28px; }
.login-art h1 { font-size: 34px; font-weight: 700; line-height: 1.35; max-width: 12em; }
.login-art p { color: #9fb4c1; margin-top: 12px; max-width: 30em; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 30px 20px; }
.login-box { width: 100%; max-width: 380px; }
.login-box h2 { font-size: 24px; font-weight: 700; }
.login-box > p { color: var(--muted); margin-bottom: 20px; }
.login-box .f { margin-bottom: 14px; }
.login-box .btn { width: 100%; min-height: 48px; font-size: 16px; }
.login-box .alt { display: block; text-align: center; margin-top: 14px; color: var(--teal-dark); font-weight: 600; font-size: 14px; }

@media (max-width: 1280px) {
    .row { grid-template-columns: 34px 138px minmax(0, 1.4fr) 112px 164px 212px; }
    .row .what { display: none; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
    .side { display: none; }
    .main { margin-right: 0; padding-bottom: 76px; }
    .top { padding: 14px 16px 4px; gap: 10px; }
    .top-logo { display: block; width: 38px; height: 38px; border-radius: 10px; background: #fff; border: 1px solid var(--line); object-fit: contain; }
    .top h1 { font-size: 20px; }
    .top p { display: none; }
    .wrap { padding: 10px 16px 30px; }

    .tabbar { display: flex; position: fixed; bottom: 0; right: 0; left: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 50; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
    .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: 11px; font-weight: 600; color: var(--muted); border-radius: 10px; }
    .tabbar a i { font-size: 18px; }
    .tabbar a.on { color: var(--teal-dark); }
    .tabbar a.new i { background: var(--teal); color: #fff; width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; margin-top: -20px; box-shadow: 0 6px 14px rgba(15, 163, 139, 0.35); }
    .tabbar a.new { color: var(--teal-dark); }

    .list { background: transparent; border: none; border-radius: 0; overflow: visible; }
    .row.head { display: none; }
    .row { grid-template-columns: 28px minmax(0, 1fr) auto; grid-template-areas: "chk code amt" "route route route" "st st st" "acts acts acts"; gap: 10px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 14px; }
    .row:last-child { border-bottom: 1px solid var(--line); }
    .row > .c-chk { grid-area: chk; align-self: start; padding-top: 2px; }
    .row > .c-code { grid-area: code; }
    .row > .c-amt { grid-area: amt; text-align: left; }
    .row > .c-route { grid-area: route; background: var(--bg); border-radius: 10px; padding: 10px 12px; }
    .row > .c-st { grid-area: st; }
    .row > .c-acts { grid-area: acts; }
    .route .leg { flex-wrap: wrap; row-gap: 0; }
    .acts { justify-content: flex-start; }
    .ic { width: 42px; height: 42px; font-size: 16px; flex: 1; max-width: 64px; }
    .bulk { top: 6px; }
    .toast { bottom: 88px; left: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .savebar { bottom: 70px; }
    .login { grid-template-columns: 1fr; }
    .login-art { padding: 30px 24px; flex-direction: row; align-items: center; gap: 16px; justify-content: flex-start; }
    .login-art img { width: 64px; height: 64px; border-radius: 16px; margin: 0; }
    .login-art h1 { font-size: 20px; }
    .login-art p { display: none; }
    .login-form { align-items: flex-start; padding-top: 34px; }
}

@media (max-width: 440px) {
    .fields { grid-template-columns: 1fr; }
    .top .btn span { display: none; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.row.res { grid-template-columns: 170px minmax(0, 1fr) auto; grid-template-areas: none; }
@media (max-width: 980px) { .row.res { grid-template-columns: 1fr; grid-template-areas: none; } }
.trail small.ltr { display: block; text-align: right; }

.ic.ok.still { cursor: default; }
.ic.ok.still:hover { background: var(--done-bg); color: var(--done); }

@media (max-width: 980px) { .acts .ic { max-width: none; } }
