/* ==========================================================================
   رصيفي الذكي | SMART BERTH — مكونات الواجهة
   Buttons, cards, forms, tables, dialogs, charts, page patterns.
   ========================================================================== */

/* ------------------------------ Buttons --------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 40px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform var(--speed) var(--ease), background var(--speed) var(--ease), box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

.btn svg { width: 16px; height: 16px; }
.btn:hover { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text-soft);
}

.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--line-strong); }

.btn-outline {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-outline:hover { background: var(--accent-soft); color: var(--accent); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); color: #fff; }

.btn-sm { height: 32px; padding: 0 var(--sp-3); font-size: 12.5px; border-radius: var(--r-xs); }
.btn-lg { height: 48px; padding: 0 var(--sp-5); font-size: 15px; }
.btn-block { width: 100%; }

/* ------------------------------- Badges --------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 700;
  background: var(--idle-soft);
  color: var(--idle);
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brass { background: var(--brass-soft); color: var(--brass); }
.badge.plain::before { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-soft);
}

/* -------------------------------- Cards --------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.card-pad { padding: var(--sp-5); }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.card-head h2, .card-head h3 { margin: 2px 0 0; }
.card-head p { font-size: 12.5px; color: var(--text-mute); margin-top: 3px; }
.card-body { padding: var(--sp-5); }
.card-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ----------------------------- Page header ------------------------------ */
.page-head {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-5);
  flex-wrap: wrap;
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-5);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 70%, var(--surface)) 0%, var(--surface) 62%);
  box-shadow: var(--shadow-1);
}

.page-head::after {
  content: "SB";
  position: absolute;
  inset-inline-end: -8px;
  bottom: -30px;
  font-size: 120px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  opacity: .04;
  letter-spacing: -.05em;
  pointer-events: none;
}

.page-head-copy { position: relative; z-index: 1; max-width: 70ch; }
.page-head-copy h1 { margin: 6px 0 8px; }
.page-head-copy p { font-size: 13.5px; color: var(--text-soft); }
.page-head-actions { position: relative; z-index: 1; display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* --------------------------- Breadcrumb / tabs -------------------------- */
.crumbs {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12.5px;
  color: var(--text-mute);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}

.crumbs a { color: var(--text-soft); font-weight: 600; }
.crumbs svg { width: 13px; height: 13px; opacity: .6; }
html[dir="ltr"] .crumbs .crumb-sep { transform: rotate(180deg); }

.tabs {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-1);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow-x: auto;
  margin-bottom: var(--sp-5);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px var(--sp-4);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  border: 1px solid transparent;
  white-space: nowrap;
  background: transparent;
  transition: all var(--speed) var(--ease);
}

.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); background: var(--surface-3); }
.tab[aria-current="page"], .tab.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
  box-shadow: var(--shadow-1);
}

/* ------------------------------- Metrics -------------------------------- */
.metric {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}

.metric-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
}

.metric-icon svg { width: 21px; height: 21px; }
.metric-icon.brass { background: var(--brass-soft); color: var(--brass); }
.metric-icon.info { background: var(--info-soft); color: var(--info); }
.metric-icon.ok { background: var(--ok-soft); color: var(--ok); }
.metric-icon.warn { background: var(--warn-soft); color: var(--warn); }
.metric-icon.danger { background: var(--danger-soft); color: var(--danger); }

.metric-copy { display: grid; min-width: 0; }
.metric-copy small { font-size: 11.5px; color: var(--text-mute); }
.metric-copy strong { font-size: 26px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.metric-copy span { font-size: 11px; color: var(--text-mute); }

.metric.feature { background: linear-gradient(140deg, var(--olive-600), var(--olive-700)); border-color: transparent; color: #fff; }

:root[data-theme="dark"] .metric.feature {
  background: linear-gradient(140deg, #2c352a, #1c2320);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .metric.feature {
    background: linear-gradient(140deg, #2c352a, #1c2320);
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  }
}
.metric.feature .metric-copy small,
.metric.feature .metric-copy span { color: rgba(255, 255, 255, .78); }
.metric.feature .metric-copy strong { color: #fff; }
.metric.feature .metric-icon { background: rgba(255, 255, 255, .16); color: #fff; }

/* ------------------------------- Forms ---------------------------------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: 12.5px; font-weight: 700; color: var(--text-soft); }
.field small { font-size: 11px; color: var(--text-mute); font-weight: 500; }
.field.full { grid-column: 1 / -1; }

.input, input[type="text"], input[type="search"], input[type="tel"], input[type="email"],
input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"],
input[type="time"], select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px var(--sp-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

textarea { min-height: 96px; resize: vertical; line-height: 1.7; }

input:hover, select:hover, textarea:hover { border-color: var(--stone-400); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input[disabled], select[disabled], textarea[disabled] { opacity: .6; cursor: not-allowed; background: var(--surface-2); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%), linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: left 16px top 50%, left 11px top 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-start: var(--sp-3);
  padding-inline-end: 34px;
}

html[dir="ltr"] select { background-position: right 11px top 50%, right 16px top 50%; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--sp-4); }

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field svg {
  position: absolute;
  inset-inline-start: 12px;
  width: 17px; height: 17px;
  color: var(--text-mute);
  pointer-events: none;
}

.search-field input { padding-inline-start: 38px; }

.radio-cards { display: flex; gap: var(--sp-3); flex-wrap: wrap; border: 0; padding: 0; margin: 0; }
.radio-cards legend { font-size: 12.5px; font-weight: 700; color: var(--text-soft); margin-bottom: 6px; }

.radio-card {
  flex: 1 1 130px;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  transition: all var(--speed) var(--ease);
}

.radio-card svg { width: 22px; height: 22px; opacity: .8; }
.radio-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.radio-card:hover { border-color: var(--accent); }
.radio-card:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: 10px var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.form-hint {
  font-size: 12px;
  color: var(--text-mute);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  padding: 8px var(--sp-3);
}

/* ------------------------------- Tables --------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 620px;
}

table.data thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: start;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--text-mute);
  padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data tbody td {
  padding: 11px var(--sp-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background var(--speed) var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data td strong { font-weight: 700; }
table.data td small { display: block; font-size: 11.5px; color: var(--text-mute); }
table.data td.actions { white-space: nowrap; }

/* Definition lists */
dl.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-3) var(--sp-5); margin: 0; }
dl.facts > div { display: grid; gap: 2px; padding-bottom: var(--sp-2); border-bottom: 1px dashed var(--line); }
dl.facts dt { font-size: 11.5px; color: var(--text-mute); }
dl.facts dd { margin: 0; font-size: 13.5px; font-weight: 600; word-break: break-word; }

/* ----------------------------- Empty states ----------------------------- */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-5);
  text-align: center;
  color: var(--text-mute);
}

.empty-mark {
  width: 58px; height: 58px;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-mute);
}

.empty-mark svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); }
.empty p { max-width: 46ch; font-size: 13px; }

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
  height: 14px;
}

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ------------------------------ Dialogs --------------------------------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: rgba(14, 16, 12, .55);
  backdrop-filter: blur(3px);
  animation: fade 160ms var(--ease);
  overflow-y: auto;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(880px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: pop 220ms var(--ease);
  overflow: hidden;
  margin: auto;
}

.modal.narrow { width: min(520px, 100%); }

@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.modal-head .copy { display: grid; min-width: 0; }
.modal-head small { font-size: 11px; color: var(--text-mute); letter-spacing: .04em; }
.modal-head h2 { font-size: 18px; }
.modal-head .close { margin-inline-start: auto; }

.modal-body { padding: var(--sp-5); overflow-y: auto; display: grid; gap: var(--sp-4); }
.modal-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.modal-foot .spacer { flex: 1 1 auto; }

/* Stepper */
.steps { display: flex; gap: var(--sp-1); padding: var(--sp-3) var(--sp-5) 0; overflow-x: auto; }

.step {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-mute);
  white-space: nowrap;
}

.step b {
  width: 20px; height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  font-size: 10.5px;
}

.step.active { background: var(--accent-soft); color: var(--text); }
.step.active b { background: var(--accent); color: var(--accent-ink); }
.step.done b { background: var(--ok); color: #fff; }

.progress-rail { height: 3px; background: var(--surface-3); }
.progress-rail > i { display: block; height: 100%; background: var(--accent); transition: width 260ms var(--ease); }

/* ------------------------------- Toasts --------------------------------- */
.toast-stack {
  position: fixed;
  inset-block-end: var(--sp-5);
  inset-inline-end: var(--sp-5);
  z-index: 120;
  display: grid;
  gap: var(--sp-2);
  width: min(360px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--ok);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  animation: slide 220ms var(--ease);
}

.toast.error { border-inline-start-color: var(--danger); }
.toast.warn { border-inline-start-color: var(--warn); }
.toast.info { border-inline-start-color: var(--info); }
.toast svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--ok); }
.toast.error svg { color: var(--danger); }
.toast.warn svg { color: var(--warn); }
.toast.info svg { color: var(--info); }
.toast button { margin-inline-start: auto; background: none; border: 0; color: var(--text-mute); }

@keyframes slide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------ QR blocks ------------------------------- */
.qr-frame {
  display: grid;
  justify-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.qr-frame svg { display: block; width: 100%; height: auto; max-width: 220px; }
.qr-frame small { font-size: 10.5px; color: #5b5f55; text-align: center; }

.qr-card {
  display: grid;
  justify-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}

.qr-card code { font-size: 11px; color: var(--text-mute); }
.qr-card strong { font-size: 13.5px; }
.qr-card small { font-size: 11.5px; color: var(--text-mute); }

/* --------------------------- Identity banner ---------------------------- */
.identity {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--sp-6);
  align-items: center;
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow-1);
}

.identity-copy { display: grid; gap: 6px; min-width: 0; }
.identity-copy code { font-size: 12.5px; color: var(--brass); font-weight: 700; }
.identity-copy p { font-size: 13px; color: var(--text-soft); }

.identity-seal {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px dashed var(--brass);
  background: var(--brass-soft);
  color: var(--brass);
  text-align: center;
  min-width: 110px;
}

.identity-seal span { font-size: 26px; font-weight: 800; letter-spacing: .04em; }
.identity-seal strong { font-size: 12px; }
.identity-seal small { font-size: 10.5px; opacity: .85; }

@media (max-width: 860px) {
  .identity { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .identity-copy { justify-items: center; }
}

.proof-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-2); }
.proof-row > div { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--surface-3); }
.proof-row small { display: block; font-size: 10.5px; color: var(--text-mute); }
.proof-row strong { font-size: 14px; }

/* -------------------------------- Hero ---------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  min-height: 300px;
  display: flex;
  align-items: flex-end;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-1);
  isolation: isolate;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: -2;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top, rgba(16, 20, 14, .92) 0%, rgba(16, 20, 14, .62) 45%, rgba(16, 20, 14, .25) 100%);
}

html[dir="rtl"] .hero::after { background: linear-gradient(to top left, rgba(16, 20, 14, .94) 10%, rgba(16, 20, 14, .55) 55%, rgba(16, 20, 14, .2) 100%); }

.hero-copy { padding: var(--sp-6); color: #fff; display: grid; gap: var(--sp-3); max-width: 62ch; }
.hero-copy h1 { color: #fff; font-size: clamp(24px, 3vw, 34px); }
.hero-copy p { color: rgba(255, 255, 255, .85); font-size: 14px; }
.hero-copy .eyebrow { color: var(--brass-400); }
.hero-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-2); }
.hero-actions .btn-ghost { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .3); color: #fff; }
.hero-actions .btn-ghost:hover { background: rgba(255, 255, 255, .22); color: #fff; }

.hero-stats {
  position: absolute;
  inset-block-start: var(--sp-4);
  inset-inline-end: var(--sp-4);
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  z-index: 1;
}

.hero-stat {
  min-width: 92px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: rgba(20, 24, 18, .62);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
  text-align: center;
}

.hero-stat b { display: block; font-size: 20px; font-weight: 800; }
.hero-stat span { font-size: 10.5px; color: rgba(255, 255, 255, .75); }

@media (max-width: 700px) {
  .hero { min-height: 260px; }
  .hero-copy { padding: var(--sp-5) var(--sp-4); }
  .hero-stats { position: static; padding: 0 var(--sp-4) var(--sp-4); }
}

/* ------------------------------ Port cards ------------------------------ */
.port-card {
  display: grid;
  grid-template-rows: 170px auto;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

.port-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); color: inherit; }

.port-photo { position: relative; overflow: hidden; }
.port-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform 420ms var(--ease); }
.port-card:hover .port-photo img { transform: scale(1.045); }

.port-photo .code {
  position: absolute;
  inset-block-start: var(--sp-3);
  inset-inline-start: var(--sp-3);
  padding: 3px 10px;
  border-radius: var(--r-xs);
  background: rgba(20, 24, 18, .7);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

.port-photo .badge { position: absolute; inset-block-start: var(--sp-3); inset-inline-end: var(--sp-3); background: rgba(20, 24, 18, .7); color: #fff; backdrop-filter: blur(4px); border-color: rgba(255, 255, 255, .2); }

.port-body { padding: var(--sp-4) var(--sp-5) var(--sp-5); display: grid; gap: var(--sp-2); }
.port-body .en { font-size: 10.5px; letter-spacing: .12em; color: var(--text-mute); font-weight: 700; }
.port-body p { font-size: 13px; color: var(--text-soft); }
.port-body .go { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--accent); margin-top: var(--sp-1); }
.port-body .go svg { width: 15px; height: 15px; }
html[dir="ltr"] .port-body .go svg { transform: rotate(180deg); }

/* ------------------------------ Tool links ------------------------------ */
.tool-link {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: all var(--speed) var(--ease);
}

.tool-link:hover { border-color: var(--accent); background: var(--surface-2); color: inherit; transform: translateY(-2px); }
.tool-link .metric-icon { width: 40px; height: 40px; }
.tool-link .copy { display: grid; min-width: 0; }
.tool-link h3 { font-size: 14px; }
.tool-link p { font-size: 12px; color: var(--text-mute); }
.tool-link > svg:last-child { margin-inline-start: auto; width: 16px; height: 16px; color: var(--text-mute); }
html[dir="ltr"] .tool-link > svg:last-child { transform: rotate(180deg); }

/* ------------------------------ Selectors ------------------------------- */
.selector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sp-3); }

.selector {
  display: grid;
  gap: 6px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: start;
  transition: all var(--speed) var(--ease);
}

.selector:hover { border-color: var(--accent); background: var(--surface-2); }
.selector[aria-selected="true"], .selector.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-1);
}

.selector small { font-size: 11px; color: var(--text-mute); }
.selector strong { font-size: 14px; }
.selector code { font-size: 10.5px; color: var(--brass); }

.berth-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: start;
  transition: all var(--speed) var(--ease);
}

.berth-tile:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-1); }
.berth-tile.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--shadow-1); }
.berth-tile .mini-qr { width: 62px; height: 62px; background: #fff; border-radius: var(--r-xs); padding: 4px; border: 1px solid var(--line); }
.berth-tile .mini-qr svg { width: 100%; height: 100%; display: block; }
.berth-tile .copy { display: grid; gap: 1px; min-width: 0; }
.berth-tile .copy small { font-size: 10.5px; color: var(--text-mute); }
.berth-tile .copy strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.berth-tile .copy code { font-size: 10px; color: var(--brass); }
.berth-tile .copy span { font-size: 11px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------- Charts --------------------------------- */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid-line { stroke: var(--line); stroke-width: 1; }
.chart-axis-text { fill: var(--text-mute); font-size: 10.5px; font-family: var(--font); }
.chart-bar { fill: var(--accent); transition: fill var(--speed) var(--ease); }
.chart-bar:hover { fill: var(--brass); }
.chart-bar.alt { fill: var(--brass); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--accent); opacity: .12; }
.chart-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart-value { fill: var(--text); font-size: 11px; font-weight: 700; font-family: var(--font); }

.legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: 12px; color: var(--text-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }

.bar-list { display: grid; gap: var(--sp-3); }
.bar-row { display: grid; gap: 5px; }
.bar-row .bar-label { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: 12.5px; }
.bar-row .bar-label small { color: var(--text-mute); font-size: 11px; }
.bar-row .bar-label strong { font-variant-numeric: tabular-nums; }
.bar-track { height: 9px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-full); background: linear-gradient(90deg, var(--accent), var(--brass)); transition: width 500ms var(--ease); }

.ring {
  --p: 0;
  width: 150px; height: 150px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0);
  margin: 0 auto;
}

.ring::before {
  content: "";
  position: absolute;
  width: 112px; height: 112px;
  border-radius: 50%;
  background: var(--surface);
}

.ring > div { position: relative; text-align: center; }
.ring strong { font-size: 26px; font-weight: 800; }
.ring span { display: block; font-size: 11px; color: var(--text-mute); }

/* ------------------------------ Timeline -------------------------------- */
.timeline { display: grid; gap: var(--sp-4); position: relative; padding-inline-start: var(--sp-5); }

.timeline::before {
  content: "";
  position: absolute;
  inset-block: 6px;
  inset-inline-start: 5px;
  width: 2px;
  background: var(--line);
}

.timeline-item { position: relative; display: grid; gap: 4px; }

.timeline-item::before {
  content: "";
  position: absolute;
  inset-inline-start: calc(var(--sp-5) * -1 + 1px);
  top: 7px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
}

.timeline-item.current::before { background: var(--brass); }
.timeline-item time { font-size: 11.5px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.timeline-item p { font-size: 13px; color: var(--text-soft); }

/* ---------------------------- Record cards ------------------------------ */
.record {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

.record:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.record.current { border-inline-start: 3px solid var(--accent); }
.record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.record-head small { font-size: 11px; color: var(--text-mute); }
.record-head h3 { font-size: 16px; }
.record-head p { font-size: 12.5px; color: var(--text-mute); }
.record-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding-top: var(--sp-3); border-top: 1px dashed var(--line); }
.record-foot small { font-size: 11px; color: var(--text-mute); }
.record-actions { display: flex; gap: var(--sp-2); }

/* ------------------------------- Uploads -------------------------------- */
.upload {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: var(--sp-5);
  border-radius: var(--r-md);
  border: 1.5px dashed var(--line-strong);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
}

.upload:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload svg { width: 26px; height: 26px; color: var(--accent); }
.upload strong { font-size: 13.5px; }
.upload span { font-size: 11.5px; color: var(--text-mute); }
.upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.file-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12.5px;
}

.file-row .thumb { width: 38px; height: 38px; border-radius: var(--r-xs); object-fit: cover; border: 1px solid var(--line); }
.file-row .copy { display: grid; min-width: 0; }
.file-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row small { font-size: 10.5px; color: var(--text-mute); }
.file-row button { margin-inline-start: auto; }

/* -------------------------------- Login --------------------------------- */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--bg);
}

.login-visual {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  isolation: isolate;
}

.login-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }

.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(200deg, rgba(20, 26, 18, .55), rgba(14, 18, 12, .94));
}

.login-visual-copy { padding: var(--sp-8) var(--sp-7); color: #fff; display: grid; gap: var(--sp-4); max-width: 60ch; }
.login-visual-copy h1 { color: #fff; font-size: clamp(26px, 3.4vw, 40px); }
.login-visual-copy p { color: rgba(255, 255, 255, .8); font-size: 14.5px; }

.login-slogan {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 16px;
  border-radius: var(--r-full);
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .1);
  font-size: 12.5px;
  font-weight: 700;
  width: fit-content;
}

.login-panel {
  display: grid;
  align-content: center;
  justify-items: stretch;
  padding: var(--sp-7) var(--sp-6);
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
}

.login-box { width: min(420px, 100%); margin: 0 auto; display: grid; gap: var(--sp-4); }
.login-box .brand { border: 0; padding: 0; height: auto; margin-bottom: var(--sp-2); }

.account-hint {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-soft);
}

.account-hint code { color: var(--brass); font-weight: 700; }

.account-pick {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 8px var(--sp-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  text-align: start;
  transition: all var(--speed) var(--ease);
}

.account-pick:hover { border-color: var(--accent); background: var(--surface-2); }
.account-pick .avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 700; flex: 0 0 auto; }
.account-pick .copy { display: grid; min-width: 0; line-height: 1.3; }
.account-pick strong { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-pick small { font-size: 10.5px; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .login-page { grid-template-columns: minmax(0, 1fr); }
  .login-visual { min-height: 220px; }
  .login-visual-copy { padding: var(--sp-6) var(--sp-5); }
  .login-panel { border: 0; padding: var(--sp-6) var(--sp-4) var(--sp-7); }
}

/* ------------------------------- Splash --------------------------------- */
.splash {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: var(--sp-4);
  text-align: center;
  padding: var(--sp-5);
}

.splash .spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------- Scanner -------------------------------- */
.scanner {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-md);
  overflow: hidden;
  background: #0d0f0c;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
}

.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .reticle {
  position: relative;
  width: 62%;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, .5);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}

.scanner .laser {
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 2px;
  background: var(--brass-400);
  box-shadow: 0 0 12px var(--brass-400);
  animation: sweep 2.4s ease-in-out infinite;
}

@keyframes sweep { 0%, 100% { top: 2%; } 50% { top: 96%; } }

/* --------------------------- Service / guide ---------------------------- */
.guide-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--sp-4);
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
}

.guide-row > b {
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
}

.guide-row .copy { display: grid; gap: 2px; min-width: 0; }
.guide-row strong { font-size: 14px; }
.guide-row p { font-size: 12.5px; color: var(--text-soft); }
.guide-row code { font-size: 11px; color: var(--brass); }

.pill-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.pill-list span {
  padding: 7px 14px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-soft);
}

.step-list { display: grid; gap: var(--sp-3); counter-reset: s; list-style: none; padding: 0; margin: 0; }
.step-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-3); align-items: center; font-size: 13.5px; }
.step-list li::before {
  counter-increment: s;
  content: counter(s, decimal-leading-zero);
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--brass-soft);
  color: var(--brass);
  font-weight: 800;
  font-size: 12.5px;
}

/* ------------------------------- Notice --------------------------------- */
.notice {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  background: var(--warn-soft);
  color: var(--text);
  font-size: 13px;
}

.notice svg { width: 20px; height: 20px; color: var(--warn); flex: 0 0 auto; }
.notice.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.notice.info svg { color: var(--info); }
.notice strong { display: block; margin-bottom: 2px; }
.notice p { color: var(--text-soft); }

/* --------------------------- Command header ----------------------------- */
.command-head {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--sp-5);
  align-items: center;
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-5);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  border-top: 3px solid var(--brass);
  background: linear-gradient(120deg, var(--surface-2) 0%, var(--surface) 55%);
  box-shadow: var(--shadow-1);
}

.command-crest {
  width: 62px; height: 62px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: linear-gradient(150deg, var(--olive-600), var(--olive-700));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}

.command-copy { display: grid; gap: 4px; min-width: 0; }
.command-copy h1 { font-size: clamp(21px, 2.3vw, 28px); }
.command-copy p { font-size: 13.5px; color: var(--text-soft); max-width: 62ch; }

.command-meta {
  display: grid;
  gap: var(--sp-2);
  padding-inline-start: var(--sp-5);
  border-inline-start: 1px solid var(--line);
  min-width: 190px;
}

.command-meta span { display: grid; gap: 1px; }
.command-meta small { font-size: 10.5px; color: var(--text-mute); letter-spacing: .04em; }
.command-meta strong { font-size: 12.5px; }

@media (max-width: 900px) {
  .command-head { grid-template-columns: auto minmax(0, 1fr); padding: var(--sp-4); }
  .command-meta {
    grid-column: 1 / -1;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    padding-inline-start: 0;
    padding-top: var(--sp-3);
    border-inline-start: 0;
    border-top: 1px solid var(--line);
  }
}

/* التاريخ في الشريط العلوي */
.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
}

.date-chip svg { width: 14px; height: 14px; color: var(--brass); }

@media (max-width: 1180px) { .date-chip { display: none; } }

/* صفوف المؤشرات في بطاقة النظرة السريعة */
.stat-rows { display: grid; gap: var(--sp-2); }

.stat-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.stat-row small { font-size: 12.5px; color: var(--text-soft); font-weight: 600; }
.stat-row strong { font-size: 17px; font-variant-numeric: tabular-nums; }

/* تنبيه أمني في صفحة الدخول */
.login-note {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.7;
}

.login-note svg { width: 18px; height: 18px; color: var(--brass); flex: 0 0 auto; margin-top: 2px; }
