@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* PetroCal identity, sampled from the logo and letterhead */
  --navy: #004084;
  --navy-dk: #002f60;
  --blue: #0065b4;
  --red: #ee1e24;
  --gold: #ffb930;

  --ink: #14181c;
  --paper: #eef1f4;
  --card: #ffffff;
  --line: #d2dae1;
  --muted: #5a6772;
  --go: #0f7a3d;
  --go-bg: #e4f2e9;
  --warn: #b8650a;
  --warn-bg: #fbeedb;
  --stop: #a81f18;
  --stop-bg: #f9e4e2;

  --sans: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', 'Dubai', 'Segoe UI', Tahoma, 'Geeza Pro', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-weight: 400;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
}

a { color: var(--ink); }

.wrap { max-width: 62rem; margin: 0 auto; padding: 0 1.1rem; }
.wrap-narrow { max-width: 34rem; }

/* ---------- masthead ---------- */
.mast {
  background: #fff;
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 1px 0 rgba(0,64,132,.08);
}
.mast .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.4rem;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; padding: .5rem 0; }
.brand img { width: 2.9rem; height: auto; display: block; }
.brand-name {
  color: var(--navy);
  font-weight: 700;
  font-size: .98rem;
  line-height: 1.25;
  letter-spacing: -.01em;
}
.brand-name small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: .78rem;
  letter-spacing: 0;
}
.mast nav { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.mast nav a { color: var(--muted); text-decoration: none; padding: .35rem .55rem; }
.mast nav a:hover, .mast nav a.on { color: var(--navy); box-shadow: inset 0 -2px 0 var(--red); }
@media (max-width: 30rem) {
  .brand-name { font-size: .88rem; }
  .brand-name small { display: none; }
}

/* ---------- verdict band: the thing a phone sees first ---------- */
.verdict {
  padding: 2.2rem 0 1.9rem;
  color: #fff;
  background: var(--navy);
}
.verdict.valid { background: var(--go); }
.verdict.expired { background: var(--stop); }
.verdict.soon { background: var(--warn); }

.verdict-word {
  font-size: clamp(2.1rem, 9vw, 3.3rem);
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -.02em;
}
.verdict-en {
  margin: .3rem 0 0;
  font-size: 1.05rem;
  font-weight: 300;
  opacity: .82;
  text-align: right;
}
.verdict-sub { margin: .45rem 0 0; font-size: 1rem; opacity: .9; font-weight: 300; }
.verdict-id {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .1em;
  opacity: .78;
  margin: 0 0 .7rem;
}

/* ---------- spec sheet ---------- */
.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  margin: 1.4rem 0;
}
.sheet h2 {
  margin: 0;
  padding: .8rem 1.1rem;
  font-size: .93rem;
  font-weight: 600;
  color: var(--navy);
  border-bottom: 1px solid var(--line);
  background: #f4f7fa;
}
.specs { margin: 0; padding: .35rem 1.1rem 1rem; }
.specs > div {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: .5rem 1rem;
  padding: .62rem 0;
  border-bottom: 1px dotted var(--line);
}
.specs > div:last-child { border-bottom: 0; }
.specs dt { min-width: 0; color: var(--muted); font-size: .87rem; font-weight: 400; }
.specs dd { margin: 0; min-width: 0; font-weight: 500; overflow-wrap: anywhere; word-break: break-word; }
.specs dd.sn { font-family: var(--mono); font-weight: 500; font-size: .96rem; }
@media (max-width: 33rem) {
  .specs > div { grid-template-columns: 1fr; gap: .1rem; padding: .55rem 0; }
}

/* ---------- documents ---------- */
.docs { list-style: none; margin: 0; padding: 0; }
.docs li { border-bottom: 1px solid var(--line); }
.docs li:last-child { border-bottom: 0; }
.docs a {
  display: flex; align-items: center; gap: .8rem;
  padding: .85rem 1.1rem;
  text-decoration: none;
  min-width: 0;
}
.docs a > span { min-width: 0; }
.docs a:hover { background: #f4f7fa; }
.docs .ext {
  flex: none;
  width: 2.4rem; height: 2.9rem;
  border: 1px solid var(--navy);
  border-top-left-radius: .45rem;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: .6rem; font-weight: 600;
  color: var(--navy);
}
.docs .dname { font-weight: 500; overflow-wrap: anywhere; word-break: break-word; }
.docs .dmeta { font-size: .8rem; color: var(--muted); }
.empty { padding: 1.5rem 1.1rem; color: var(--muted); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-block;
  font: inherit; font-weight: 600; font-size: .92rem;
  padding: .62rem 1.1rem;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--navy-dk); border-color: var(--navy-dk); }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.ghost:hover { background: #dfe7ee; }
.btn.danger { background: transparent; border-color: var(--stop); color: var(--stop); }
.btn.danger:hover { background: var(--stop-bg); }
.btn.sm { padding: .38rem .7rem; font-size: .84rem; }

label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: .28rem; }
input[type=text], input[type=date], input[type=password], input[type=file], textarea, select {
  width: 100%;
  font: inherit;
  padding: .55rem .65rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 0;
}
input[type=text]:focus, input[type=date]:focus, input[type=password]:focus,
textarea:focus, select:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
input.sn { font-family: var(--mono); }
textarea { min-height: 5rem; resize: vertical; }
.field { margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 33rem) { .grid2 { grid-template-columns: 1fr; } }
.hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.req { color: var(--stop); }

/* ---------- admin table ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0 1rem;
}
.bar h1 { font-size: 1.35rem; margin: 0; min-width: 0; font-weight: 600; letter-spacing: -.01em; color: var(--navy); overflow-wrap: anywhere; }
.bar h1 .tag { vertical-align: middle; margin-right: .4rem; }
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.searchbar input { flex: 1; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); }
th, td { padding: .7rem .8rem; text-align: right; border-bottom: 1px solid var(--line); font-size: .92rem; overflow-wrap: anywhere; word-break: break-word; }
th { background: #f4f7fa; font-weight: 600; font-size: .85rem; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td.sn { font-family: var(--mono); font-size: .88rem; }
td a { font-weight: 500; color: var(--blue); }

.tag {
  display: inline-block;
  font-size: .78rem; font-weight: 600;
  padding: .12rem .5rem;
  border: 1px solid;
  white-space: nowrap;
}
.tag.valid { color: var(--go); background: var(--go-bg); border-color: #b9dcc7; }
.tag.soon { color: var(--warn); background: var(--warn-bg); border-color: #ecd0a4; }
.tag.expired { color: var(--stop); background: var(--stop-bg); border-color: #e8b8b4; }
.tag.unknown { color: var(--muted); background: #eceeec; border-color: var(--line); }

/* ---------- qr panel ---------- */
.qrbox {
  display: flex; gap: 1.4rem; align-items: flex-start; flex-wrap: wrap;
  padding: 1.1rem;
}
.qrbox img { width: 11rem; height: 11rem; border: 1px solid var(--line); background: #fff; }
.qrbox .qrmeta { flex: 1 1 13rem; min-width: 0; }
.linkline {
  font-family: var(--mono); font-size: .82rem;
  background: #f0f4f8; border: 1px solid var(--line);
  padding: .5rem .6rem; overflow-wrap: anywhere; margin: .5rem 0 .9rem;
  direction: ltr; text-align: left;
}
.actions { display: flex; gap: .55rem; flex-wrap: wrap; }

.notice {
  border-right: 4px solid var(--gold);
  background: #fff6e2;
  padding: .7rem .9rem;
  margin: 1rem 0;
  font-size: .9rem;
}
.notice.bad { border-right-color: var(--stop); background: var(--stop-bg); }

.foot {
  margin: 2.5rem 0 1.6rem;
  padding-top: 1rem;
  border-top: 2px solid var(--gold);
  font-size: .82rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.75;
}
.foot .co { color: var(--navy); font-weight: 600; font-size: .9rem; }
.foot .contact { direction: ltr; font-size: .78rem; }
.foot .contact a { color: var(--blue); text-decoration: none; }
.foot .contact a:hover { text-decoration: underline; }
.foot .ref { font-family: var(--mono); font-size: .7rem; color: #93a1ad; margin-top: .3rem; }

/* ---------- printable equipment tag ---------- */
.tagsheet { display: flex; flex-wrap: wrap; gap: .5rem; padding: 1rem 0; }
.eqtag {
  width: 8.5cm;
  border: 2px solid var(--navy);
  background: #fff;
  padding: .5cm .55cm .45cm;
  position: relative;
}
/* the zip-tie hole is real: these get punched and tied to the equipment */
.eqtag::before {
  content: '';
  position: absolute; top: .3cm; left: 50%; transform: translateX(-50%);
  width: .42cm; height: .42cm;
  border: 2px solid var(--navy); border-radius: 50%;
}
.eqtag .eqlogo { display: block; width: 2.3cm; margin: .5cm auto .12cm; }
.eqtag .eqtop { text-align: center; font-size: 8.5pt; font-weight: 600; color: var(--navy); line-height: 1.35; }
.eqtag .eqtop span { font-weight: 400; color: var(--ink); }
.eqtag .eqqr { display: block; margin: .25cm auto; width: 3.6cm; height: 3.6cm; }
.eqtag .eqid { font-family: var(--mono); text-align: center; font-size: 10pt; letter-spacing: .12em; font-weight: 600; }
.eqtag .eqrow { display: flex; justify-content: space-between; gap: .25cm; font-size: 7.5pt; margin-top: .2cm; border-top: 1px solid var(--navy); padding-top: .15cm; }
.eqtag .eqweb { text-align: center; font-size: 6.5pt; color: var(--muted); direction: ltr; margin-top: .1cm; }
.eqtag .eqexp { font-weight: 700; }

@media print {
  .mast, .noprint, .foot { display: none !important; }
  body { background: #fff; }
  .eqtag { break-inside: avoid; page-break-inside: avoid; }
  .eqtag, .eqtag * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .verdict { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

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