:root {
  --header: #0b3d73;
  --accent: #2f6bff;
  --bg: #f4f7fb;
  --title: #102a43;
  --table: #0b3d73;
  --th-text: #ffffff;
  --td-bg: #ffffff;
  --td-alt: #f4f8fc;
  --td-text: #102a43;
  --panel: #ffffff;
  --line: #e4ecf4;
  --text: #16324f;
  --muted: #6b7c90;
  --danger: #d64545;
  --ok: #1f9d64;
  --shadow: 0 12px 32px rgba(11, 61, 115, 0.12);
  --radius: 26px;
  --font: "Plus Jakarta Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --tabbar-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
html[dir="rtl"] body { font-family: "IBM Plex Sans Arabic", "Plus Jakarta Sans", sans-serif; }
body {
  padding-bottom: calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
input, textarea, select { -webkit-user-select: text; user-select: text; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; }
.topbar .title { font-size: 1rem; line-height: 1.25; }

.app-hero {
  background: var(--header);
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 20px 28px;
}
.hero-top, .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.hello { opacity: .75; font-size: .82rem; }
.app-hero h1, .brand-name, .title {
  font-size: 1.45rem;
  font-weight: 800;
  color: inherit;
}
.app-hero p { opacity: .8; margin-top: 8px; font-size: .95rem; }
.app-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: cover;
  background: #fff;
}

.sheet, .page {
  background: var(--bg);
  min-height: 60vh;
  border-radius: 28px 28px 0 0;
  margin-top: -8px;
  padding: 18px 16px 24px;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.page { min-height: calc(100dvh - 88px); }

.topbar {
  background: var(--header);
  color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 16px 14px;
  border-radius: 0;
  box-shadow: none;
  border: 0;
  margin: 0;
}
.topbar .title, .topbar small { color: #fff; }
.topbar small { opacity: .75; display: block; }
.mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.mark img { width: 100%; height: 100%; object-fit: cover; display: block; }

.chip-row, .lang-switch { display: flex; gap: 8px; align-items: center; }
.chip, .lang-btn {
  border: 0;
  background: rgba(255,255,255,.14);
  color: #fff;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: .75rem;
  font-weight: 700;
}
.lang-btn.active, .chip.live { background: #fff; color: var(--header); }

.section-title {
  color: var(--title);
  font-size: 1.15rem;
  font-weight: 800;
  margin: 8px 4px 12px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.tile {
  background: #fff;
  border-radius: 18px;
  padding: 12px 6px;
  text-align: center;
  box-shadow: var(--shadow);
}
.tile b { display: block; font-size: .68rem; color: var(--title); margin-top: 6px; }
.tile-ico, .ico {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.tile-ico svg, .ico svg { width: 22px; height: 22px; display: block; }
.t1 { background: #e8f1ff; color: #2f6bff; }
.t2 { background: #ffe8d6; color: #e67a2e; }
.t3 { background: #e6f7f4; color: #1aa38a; }
.t4 { background: #f3e8ff; color: #7a4ad6; }
a.tile { display: block; }

.list { display: grid; gap: 10px; }
.service-row, .card, .glass, .item {
  background: var(--panel);
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 0;
}
.service-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
}
.service-row h3 { color: var(--title); font-size: 1rem; }
.service-row p { color: var(--muted); font-size: .8rem; }
.service-row .grow { flex: 1; }
.chev { color: #9aa8b8; font-size: 1.2rem; }
.ico {
  width: 48px;
  height: 48px;
  margin: 0;
  border-radius: 16px;
  flex: 0 0 auto;
}

.auth-box { display: grid; gap: 8px; padding: 0 14px 14px; }
.field {
  width: 100%;
  border: 1px solid var(--line);
  background: #f7fbfe;
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
.field:focus { border-color: var(--accent); background: #fff; }
.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
}
.btn.full { width: 100%; }
.btn.ghost { background: #eaf1ff; color: var(--header); }
.btn.danger { background: #fdecec; color: var(--danger); }
.btn:disabled { opacity: .55; }

.msg { display: none; font-size: .85rem; padding: 10px 12px; border-radius: 12px; }
.msg.show { display: block; }
.msg.error { background: #fdecec; color: #9b2c2c; }
.msg.ok { background: #e8f8f0; color: #146c43; }

.hero { display: none; }
.kicker { color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0; }
.stat { padding: 16px; text-align: center; background: #fff; border-radius: 20px; box-shadow: var(--shadow); }
.stat b { display: block; color: var(--title); font-size: 1.5rem; }
.muted, .empty { color: var(--muted); text-align: center; padding: 16px; }

.add-row, .vessel-row {
  display: grid;
  grid-template-columns: 1.5fr .8fr auto;
  gap: 8px;
  align-items: center;
  background: #fff;
  border-radius: 16px;
  padding: 10px;
}
.item { padding: 16px; display: grid; gap: 10px; margin-bottom: 12px; }

.badge { border-radius: 999px; padding: 7px 11px; font-size: .72rem; font-weight: 800; }
.badge.view { background: #e8f8f0; color: var(--ok); }
.badge.edit { background: #eaf1ff; color: var(--accent); }

.ops { display: none; margin: 10px 16px; padding: 12px; border-radius: 16px; background: #fff3f3; color: #9b2c2c; text-align: center; }
.ops.show { display: block; }

.overlay {
  position: fixed; inset: 0; background: rgba(11,61,115,.35);
  display: none; place-items: center; z-index: 40; padding: 18px;
}
.overlay.show { display: grid; }
.modal { width: min(520px, 100%); padding: 22px; display: grid; gap: 12px; background: #fff; border-radius: 24px; }

.toast {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%;
  transform: translate(-50%, -120%); z-index: 80;
  background: #fff; color: var(--text); padding: 12px 16px; border-radius: 14px;
  box-shadow: var(--shadow); max-width: 90%;
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { color: #9b2c2c; }
#downloadModal .modal { gap: 10px; }
#downloadModal .btn { width: 100%; justify-content: center; text-decoration: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 8px 10px env(safe-area-inset-bottom);
  background: #fff;
  box-shadow: 0 -8px 24px rgba(11,61,115,.08);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
}
.tab {
  display: grid; place-items: center; gap: 2px;
  color: #8a97a8; font-size: .68rem; font-weight: 700;
  background: none; border: 0;
}
.tab.active { color: var(--accent); }
.tab svg { width: 22px; height: 22px; }

.hidden { display: none !important; }
.footer { display: none; }
.admin-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

.data-table, .a4-table, .section-table { width: 100%; border-collapse: collapse; }
.data-table th, .daily-table th {
  background: var(--table);
  color: var(--th-text);
}
.data-table td, .daily-table td {
  background: var(--td-bg);
  color: var(--td-text);
}
.data-table tbody tr:nth-child(even) td,
.daily-table tbody tr:nth-child(even) td {
  background: var(--td-alt);
}

.print-sheet {
  position: fixed; left: -9999px; top: 0; width: 210mm; min-height: 297mm;
  background: #fff; color: #111; padding: 12mm; font-family: Arial, sans-serif;
}
.a4-title { text-align: center; font-size: 18pt; font-weight: 800; margin-bottom: 8px; color: var(--title); }
.a4-date { text-align: center; margin-bottom: 16px; }
.a4-table th, .a4-table td, .section-table th, .section-table td {
  border: 1px solid #bdc3c7; padding: 8px; text-align: center;
}
.stamp { float: right; border: 3px solid #ff1e1e; color: #ff1e1e; padding: 6px 10px; transform: rotate(4deg); font-weight: 800; }

.excel-preview { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 8px; }
.excel-preview th, .excel-preview td { border: 1px solid #c5d0dc; padding: 8px; text-align: center; }
.excel-preview th { background: var(--table); color: var(--th-text); }
.excel-preview td { background: var(--td-bg); color: var(--td-text); }
.excel-preview tbody tr:nth-child(even) td { background: var(--td-alt); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.daily-card { overflow-x: auto; margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
.daily-table { width: 100%; border-collapse: collapse; font-size: .88rem; direction: rtl; }
.daily-table th, .daily-table td {
  border: 1px solid #d7e2ee;
  padding: 6px;
  vertical-align: top;
  text-align: right;
}
.daily-table th { text-align: center; font-weight: 700; }
.daily-table .num { width: 42px; text-align: center; font-weight: 800; }
.daily-table textarea {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
  resize: vertical;
  text-align: right;
}
.daily-table textarea.empty-fill,
.daily-table tr.empty-fill td,
.daily-table tr.empty-fill td.num,
.daily-table tr.empty-fill textarea {
  background: #c4c4c4 !important;
}
.daily-table .btn.tiny { padding: 8px 10px; font-size: .75rem; }
.sign-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 22px;
  text-align: center;
}
.sign-box { flex: 1; }
.sign-box strong { display: block; margin-bottom: 10px; color: #222; }
.sign-box input {
  width: 100%;
  max-width: 260px;
  border: 0;
  border-bottom: 1px solid #9aa8b8;
  border-radius: 0;
  text-align: center;
  background: transparent;
  padding: 8px 4px;
}

.print-sheet {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  color: #102a43;
  padding: 0;
  font-family: "IBM Plex Sans Arabic", "Plus Jakarta Sans", Arial, sans-serif;
}
.print-doc { padding: 14mm 14mm 16mm; direction: rtl; }
.print-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 4px solid #0b3d73;
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.print-brand { font-size: 22px; font-weight: 800; color: #0b3d73; }
.print-meta { text-align: left; font-size: 12px; color: #5b6b7c; }
.print-doc h1 {
  font-size: 20px;
  margin: 0 0 18px;
  color: #102a43;
  text-align: center;
}
.print-doc h2 {
  font-size: 14px;
  margin: 0 0 8px;
  color: #0b3d73;
}
.print-section { margin-bottom: 18px; }
.print-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.print-table th {
  padding: 8px 10px;
  font-weight: 700;
}
.print-table td {
  border: 1px solid #d5dee8;
  padding: 8px 10px;
  vertical-align: top;
}
.print-table .center { text-align: center; }
.print-total {
  margin-top: 8px;
  text-align: right;
  font-weight: 800;
  color: #0b3d73;
}
.print-signs {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 28px;
  text-align: center;
}
.print-sign { flex: 1; }
.print-sign .lbl { font-weight: 800; margin-bottom: 28px; color: #102a43; }
.print-sign .name { min-height: 22px; font-weight: 700; }
.print-sign .line { width: 70%; margin: 8px auto 0; border-bottom: 1px solid #102a43; height: 28px; }

.a4-title { text-align: center; font-size: 18pt; font-weight: 800; margin-bottom: 8px; color: var(--title); }
.a4-date { text-align: center; margin-bottom: 16px; }

@media (min-width: 900px) {
  .app-hero, .topbar { padding-left: 32px; padding-right: 32px; }
  .sheet, .page { border-radius: 24px; margin-top: 12px; padding: 28px 32px 40px; }
  .list { grid-template-columns: 1fr; }
  .sheet > .list { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .tabbar { left: 0; right: 0; width: 100%; max-width: none; transform: none; }
}
@media (max-width: 700px) {
  .add-row, .vessel-row, .grid-2, .sign-row { grid-template-columns: 1fr; }
  .sign-row { flex-direction: column; }
  .list { grid-template-columns: 1fr; }
}

@font-face {
  font-family: "ReportFont";
  src: url("../fonts/IBMPlexSansArabic-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}
@font-face {
  font-family: "ReportFont";
  src: url("../fonts/IBMPlexSansArabic-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: block;
}
.rpt {
  width: 210mm;
  min-height: 297mm;
  max-width: 794px;
  margin: 0 auto;
  background: #fff;
  color: #16331c;
  padding: 14mm 16mm 16mm;
  font-family: "ReportFont", "Segoe UI", Tahoma, Arial, sans-serif !important;
  font-size: 16px;
  line-height: 1.4;
  position: relative;
  box-sizing: border-box;
  direction: rtl;
  unicode-bidi: embed;
  letter-spacing: 0;
  word-spacing: 0;
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
}
.rpt-head {
  display: flex;
  direction: ltr;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
  min-height: 24mm;
}
.rpt-meta {
  direction: rtl;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 18px;
  padding-top: 2px;
}
.rpt-logo {
  width: 18mm;
  height: 18mm;
  object-fit: contain;
  flex: 0 0 auto;
  background: #fff;
}
.rpt, .rpt * {
  font-family: "ReportFont", "Segoe UI", Tahoma, Arial, sans-serif !important;
  letter-spacing: 0 !important;
  word-spacing: 0 !important;
  unicode-bidi: embed;
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
}
.rpt-to {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: #16331c;
  direction: rtl;
  white-space: nowrap;
}
.rpt-title {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: #026f01;
  margin: 2px 0 4px;
  direction: rtl;
  line-height: 1.3;
}
.rpt-sub {
  text-align: center;
  color: #3d4a40;
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 10px;
  direction: rtl;
}
.rpt-bar {
  background: #028a01 !important;
  color: #f4ff4a !important;
  text-align: center;
  padding: 5px 6px;
  font-weight: 700;
  font-size: 17px;
  direction: rtl;
}
.rpt-stamp {
  border: 2px solid #d10f16;
  color: #d10f16;
  padding: 5px 12px;
  margin-top: 10px;
  transform: rotate(-6deg);
  transform-origin: center;
  font-weight: 700;
  text-align: center;
  font-size: 12px;
  line-height: 1.3;
  background: #fff;
}
.rpt-block { margin-bottom: 8px; }
.rpt-table { width: 100%; border-collapse: collapse; direction: ltr; table-layout: fixed; }
.rpt-table-ar { direction: rtl; }
.rpt-table col.col-n { width: 34px; }
.rpt-table col.col-qty { width: 88px; }
.rpt-table col.col-main { width: auto; }
.rpt-table th,
.print-table th,
.a4-table th,
.section-table th {
  background: #028a01 !important;
  color: #f4ff4a !important;
  padding: 5px 4px;
  font-size: 15px;
  font-weight: 700;
  border: 1px solid #026f01;
  text-align: center !important;
  direction: rtl;
}
.rpt-table td,
.print-table td,
.a4-table td,
.section-table td {
  border: 1px solid #b7d7b2;
  padding: 5px 6px;
  text-align: right !important;
  font-size: 15px;
  background: #fff !important;
  color: #222 !important;
  direction: rtl;
  vertical-align: middle;
}
.rpt-table tr.empty-fill td {
  background: #c4c4c4 !important;
  color: transparent !important;
}
.rpt-table td.center,
.rpt-table td.num,
.rpt-table th.center {
  text-align: center !important;
  direction: ltr;
  unicode-bidi: embed;
  width: 34px;
  max-width: 34px;
  padding-left: 2px;
  padding-right: 2px;
  white-space: nowrap;
}
.rpt-table td.qty,
.rpt-table th.qty {
  width: 88px;
  max-width: 88px;
  text-align: center !important;
  direction: ltr;
  white-space: nowrap;
}
.rpt-signs {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  text-align: center;
  direction: ltr;
}
.rpt-sign { width: 42%; }
.rpt-sign .lbl { font-size: 15px; font-weight: 700; margin-bottom: 8px; color: #222 !important; direction: rtl; }
.rpt-sign .nm { min-height: 16px; font-size: 15px; font-weight: 700; color: #222 !important; direction: rtl; }
.rpt-note { font-size: 12px; color: #555; }
@page { size: A4; margin: 12mm; }
@media print {
  body.print-mode > *:not(.print-sheet) { display: none !important; }
  body.print-mode .print-sheet {
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
  body.print-mode .rpt {
    width: auto !important;
    min-height: auto !important;
    max-width: none !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  body.print-mode .rpt,
  body.print-mode .rpt * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
