/* HASAD admin panel */
@font-face {
  font-family: 'Flags';
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E007F;
  src: url('https://cdn.jsdelivr.net/npm/country-flag-emoji-polyfill@0.1.8/dist/TwemojiCountryFlags.woff2') format('woff2');
  font-display: swap;
}
:root {
  --g9: #1e2f15; --g8: #2c4320; --g7: #395528; --g6: #4e6d37; --g5: #6e8e53; --g1: #e9efe0;
  --c0: #fff; --c1: #f9f8f3; --c2: #f2f0e7; --c3: #eae7db; --c4: #dcd8c9;
  --ink: #1b2514; --ink2: #3c4535; --muted: #767c6d; --line: #e6e3d8;
  --red: #c24f2a; --amber: #b7801b; --blue: #2f6690; --teal: #217a72;
  --r: 16px;
  --font: 'Flags', 'IBM Plex Sans Arabic', 'Readex Pro', system-ui, sans-serif;
  --font-h: 'Flags', 'Readex Pro', 'IBM Plex Sans Arabic', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--c2); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-h); font-weight: 500; margin: 0; }
svg.i { width: 1em; height: 1em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
[dir='rtl'] .flip { transform: scaleX(-1); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding-inline: 18px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .2s, border-color .2s; }
.btn .i { font-size: 16px; }
.btn-primary { background: var(--g8); color: #f4f1e6; }
.btn-primary:hover { background: var(--g7); }
.btn-ghost { border: 1px solid var(--c4); background: var(--c0); }
.btn-ghost:hover { border-color: var(--g6); color: var(--g8); }
.btn-danger { border: 1px solid #efc9bb; color: var(--red); background: var(--c0); }
.btn-danger:hover { background: #fdf0eb; }
.btn-sm { height: 34px; padding-inline: 14px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--muted); font-size: 16px; }
.icon-btn:hover { background: var(--c2); color: var(--g8); }
.icon-btn.danger:hover { color: var(--red); background: #fdf0eb; }
.input, .select, .textarea { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--c0); padding-inline: 12px; font-size: 13.5px; outline: none; transition: border-color .2s, box-shadow .2s; }
.textarea { height: auto; min-height: 80px; padding-block: 10px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--g6); box-shadow: 0 0 0 3px rgba(78, 109, 55, .14); }
.input.sm, .select.sm { height: 32px; font-size: 12.5px; padding-inline: 8px; border-radius: 8px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #dfe7d2, transparent 50%), var(--c2); }
.login-card { width: min(400px, 100%); background: var(--c0); border-radius: 24px; padding: 34px; box-shadow: 0 30px 60px -30px rgba(30, 47, 21, .35); display: grid; gap: 14px; }
.login-card h1 { font-size: 22px; margin-top: 8px; }
.login-card label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--ink2); }
.login-logo, .side-logo { display: flex; align-items: center; gap: 10px; color: var(--g8); }
.login-logo svg, .side-logo svg { width: 38px; height: 38px; }
.login-logo b, .side-logo b { display: block; font-family: var(--font-h); font-size: 18px; font-weight: 600; line-height: 1.1; }
.login-logo small, .side-logo small { font-size: 11px; color: var(--muted); }
.form-err { color: var(--red); font-size: 12.5px; margin: 0; min-height: 1em; }
.back-link { font-size: 12px; color: var(--muted); text-align: center; }

/* Layout */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--g9); color: #d7d3c3; padding: 22px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-logo { color: #f4f1e6; padding: 4px 10px 22px; }
.side-logo small { color: #a3a893; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; transition: background .2s; }
.side-nav a .i { font-size: 18px; opacity: .8; }
.side-nav a:hover { background: rgba(255, 255, 255, .06); }
.side-nav a.active { background: rgba(255, 255, 255, .12); color: #fff; }
.side-nav .nb { margin-inline-start: auto; background: #d9734d; color: #fff; font-size: 10.5px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 99px; display: grid; place-items: center; padding-inline: 6px; }
.side-nav .sep { font-size: 10.5px; letter-spacing: .14em; color: #8f957f; padding: 16px 12px 6px; }
.side-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 2px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-size: 13px; color: #c9c5b4; text-align: start; }
.side-link:hover { background: rgba(255, 255, 255, .06); }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 16px 28px; background: rgba(242, 240, 231, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 20px; }
.topbar-end { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.content { padding: 24px 28px 60px; }
.mobile-only { display: none; }

/* Cards / KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--c0); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: flex; gap: 12px; align-items: flex-start; }
.kpi-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--g1); color: var(--g7); font-size: 19px; flex: none; }
.kpi small { display: block; color: var(--muted); font-size: 12px; }
.kpi b { display: block; font-family: var(--font-h); font-size: 22px; font-weight: 600; margin-top: 2px; }
.kpi em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.panel { background: var(--c0); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-h h3 { font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-top: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.stack { display: grid; gap: 14px; }

/* Charts */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 38px; background: linear-gradient(to top, var(--g7), var(--g5)); border-radius: 8px 8px 3px 3px; min-height: 3px; position: relative; }
.bars .bar span { position: absolute; top: -18px; inset-inline: 0; text-align: center; font-size: 11px; font-weight: 600; color: var(--ink2); }
.bars small { font-size: 10.5px; color: var(--muted); }
.hbars { display: grid; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 110px 1fr 46px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar { height: 8px; background: var(--c2); border-radius: 99px; overflow: hidden; }
.hbar i { display: block; height: 100%; border-radius: inherit; background: var(--g6); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--c0); border: 1px solid var(--line); border-radius: var(--r); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: start; font-weight: 600; font-size: 11.5px; color: var(--muted); padding: 12px 14px; background: var(--c1); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--c2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--c1); }
table.t tr.unread td { background: #fbfaf1; font-weight: 500; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--c3); }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 11.5px; color: var(--muted); }
.actions { display: flex; gap: 2px; justify-content: flex-end; }
.inline-num { width: 90px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--c2); color: var(--ink2); white-space: nowrap; }
.pill.new, .pill.loading { background: #e2edf6; color: var(--blue); }
.pill.confirmed, .pill.available, .pill.delivered { background: var(--g1); color: var(--g7); }
.pill.preparing, .pill.customs, .pill.maintenance { background: #f8ecd2; color: var(--amber); }
.pill.shipped, .pill.in_transit, .pill.on_trip { background: #ddf0ee; color: var(--teal); }
.pill.cancelled, .pill.delayed { background: #fbe4dc; color: var(--red); }
.pill.partner { background: #efe6f6; color: #6b3d8f; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 200px; }
.tabs { display: flex; gap: 4px; background: var(--c0); border: 1px solid var(--line); padding: 4px; border-radius: 999px; overflow-x: auto; }
.tabs button { height: 32px; padding-inline: 14px; border-radius: 99px; font-size: 12.5px; white-space: nowrap; color: var(--muted); }
.tabs button.active { background: var(--g8); color: #fff; }
.tabs button small { opacity: .7; margin-inline-start: 4px; }
.switch { position: relative; width: 38px; height: 22px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--c4); transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; inset-inline-start: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--g6); }
.switch input:checked + span::before { transform: translateX(calc(16px * var(--dx, 1))); }
[dir='rtl'] .switch { --dx: -1; }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.list { display: grid; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--c1); font-size: 13px; }
.list-item .grow { flex: 1; min-width: 0; }

/* Forms */
.form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
.f label, .f > span { display: block; font-size: 12px; font-weight: 500; color: var(--ink2); margin-bottom: 6px; }
.f label em { color: var(--red); font-style: normal; }
.f .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; cursor: pointer; margin: 0; user-select: none; }
.checks input { accent-color: var(--g7); margin: 0; }
.checks label:has(input:checked) { background: var(--g1); border-color: var(--g5); color: var(--g8); }
.img-field { display: flex; gap: 10px; align-items: center; }
.img-field img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--c3); flex: none; }
.img-field .grow { flex: 1; display: grid; gap: 6px; }
.form-section { grid-column: 1 / -1; font-family: var(--font-h); font-size: 14px; font-weight: 500; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line); color: var(--g8); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 30, 14, .45); display: grid; place-items: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal.show { opacity: 1; pointer-events: auto; }
.modal-box { width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--c1); border-radius: 22px; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .45); }
.modal-box.wide { width: min(980px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--c1); z-index: 2; }
.modal-h h2 { font-size: 18px; }
.modal-b { padding: 20px 22px; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--c1); }
.modal-f .left { margin-inline-end: auto; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.kv div { background: var(--c0); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.kv small { display: block; font-size: 11px; color: var(--muted); }
.kv b { font-weight: 600; font-size: 13.5px; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding-inline-start: 22px; padding-bottom: 14px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; inset-inline-start: 4px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--g6); }
.timeline li::after { content: ''; position: absolute; inset-inline-start: 8px; top: 17px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline small { color: var(--muted); display: block; font-size: 11.5px; }
.progress { height: 8px; border-radius: 99px; background: var(--c3); overflow: hidden; min-width: 80px; }
.progress i { display: block; height: 100%; background: var(--g6); border-radius: inherit; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: var(--g9); color: #f4f1e6; padding: 11px 20px; border-radius: 99px; font-size: 13px; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }

@media (max-width: 1100px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; width: 260px; transform: translateX(-110%); transition: transform .3s; }
  [dir='rtl'] .side { transform: translateX(110%); }
  [dir='rtl'] .side.open, .side.open { transform: none; }
  .mobile-only { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .form, .settings-grid { grid-template-columns: 1fr; }
  .toolbar .input, .toolbar .select { min-width: 0; flex: 1; }
}
