:root {
  color-scheme: light;
  --bg: #f2f4f0;
  --panel: #ffffff;
  --panel-2: #f8faf7;
  --panel-3: #edf1ec;
  --line: #d8ded9;
  --line-bright: #b8c2bb;
  --text: #121814;
  --muted: #68746d;
  --accent: #79a900;
  --accent-soft: #eef7d9;
  --danger: #b83e39;
  --danger-soft: #fff0ee;
  --repair: #925716;
  --repair-soft: #fff4e6;
  --ready: #487700;
  --ready-soft: #edf7dc;
  --loading: #176c87;
  --loading-soft: #e7f6fb;
  --delivered: #53655c;
  --delivered-soft: #edf1ef;
  --profile-alwaleed: #006b4f;
  --profile-ali: #12345b;
  --profile-ghanim: #4b1f6f;
  --display: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --body: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--body);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; overflow-x: hidden; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; overflow-x: hidden; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
body::before { position: fixed; inset: 0; z-index: -1; background-image: linear-gradient(rgba(18,24,20,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(18,24,20,.035) 1px, transparent 1px); background-size: 40px 40px; content: ""; pointer-events: none; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: square; stroke-linejoin: miter; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

body.profile-locked { overflow: hidden; }
.profile-gate { position: fixed; inset: 0; z-index: 2000; display: grid; padding: 28px; place-items: center; overflow: auto; background: #f7f9f5; }
.profile-gate::before { position: fixed; inset: 0; background-image: linear-gradient(rgba(18,24,20,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(18,24,20,.045) 1px, transparent 1px); background-size: 42px 42px; content: ""; pointer-events: none; }
.profile-gate::after { position: fixed; inset: 0; background: radial-gradient(circle at 50% 42%, rgba(121,169,0,.1), transparent 42%); content: ""; pointer-events: none; }
.profile-shell { position: relative; z-index: 1; width: min(850px, 100%); }
.profile-brand { display: flex; align-items: center; justify-content: center; gap: 13px; color: var(--muted); font: 800 10px var(--display); letter-spacing: .14em; }
.profile-brand .brand-mark { width: 34px; height: 34px; font-size: 17px; }
.profile-heading { margin: 0 0 30px; text-align: center; }
.profile-heading p { margin: 0 0 10px; color: var(--accent); font: 800 9px var(--display); letter-spacing: .18em; text-transform: uppercase; }
.profile-heading h1 { margin: 0; font: 800 clamp(25px, 4vw, 38px) var(--display); letter-spacing: -.035em; text-transform: uppercase; }
.profile-heading > span { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; }
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.profile-card { position: relative; display: flex; min-width: 0; min-height: 224px; padding: 17px 18px 16px; flex-direction: column; align-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.96); color: var(--text); text-align: center; box-shadow: 0 10px 28px rgba(24,36,28,.06); transition: border-color .14s ease, background .14s ease, transform .14s ease; }
.profile-card::before { position: absolute; top: -1px; left: -1px; width: 32px; height: 2px; background: var(--profile-color); content: ""; }
.profile-card:not(:disabled):hover, .profile-card:not(:disabled):focus-visible { border-color: var(--profile-color); outline: 0; background: var(--panel-2); transform: translateY(-3px); }
.profile-card:disabled { cursor: wait; opacity: .45; }
.profile-card.locked { cursor: not-allowed; opacity: .34; }
.profile-alwaleed { --profile-color: var(--profile-alwaleed); }
.profile-ali { --profile-color: var(--profile-ali); }
.profile-ghanem { --profile-color: var(--profile-ghanim); }
.avatar-frame { position: relative; display: grid; width: 142px; height: 142px; place-items: center; overflow: hidden; border: 1px solid var(--line-bright); background: #fff; color: var(--profile-color); }
.avatar-frame::before, .avatar-frame::after { position: absolute; width: 12px; height: 12px; content: ""; }
.avatar-frame::before { top: -1px; left: -1px; border-top: 2px solid var(--profile-color); border-left: 2px solid var(--profile-color); }
.avatar-frame::after { right: -1px; bottom: -1px; border-right: 2px solid var(--profile-color); border-bottom: 2px solid var(--profile-color); }
.profile-avatar { width: 106px; height: 106px; fill: none; stroke: currentColor; stroke-width: 2; }
.profile-photo { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.08); opacity: 1; transform: scale(1.3); }
.profile-copy { display: grid; margin-top: 13px; gap: 7px; }
.profile-copy strong { font: 800 16px var(--display); letter-spacing: .07em; }
.profile-copy small { color: var(--muted); font: 700 9px var(--display); letter-spacing: .08em; text-transform: uppercase; }
.profile-arrow { position: absolute; right: 14px; bottom: 12px; color: var(--profile-color); font: 700 20px var(--display); }
.profile-error { margin: 14px 0 0; padding: 10px; border: 1px solid var(--danger); color: var(--danger); text-align: center; font: 700 10px var(--display); }

.offline-banner { position: sticky; top: 0; z-index: 100; padding: 8px 16px; border-bottom: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger); text-align: center; font: 700 11px var(--display); letter-spacing: .08em; text-transform: uppercase; }
.app-header { height: 72px; padding: max(9px, env(safe-area-inset-top)) 22px 9px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.header-inner { display: flex; max-width: 1320px; height: 100%; margin: 0 auto; align-items: center; justify-content: space-between; gap: 20px; }
.active-profile { display: flex; min-width: 0; align-items: center; gap: 11px; }
.header-avatar { position: relative; display: grid; width: 48px; height: 48px; flex: 0 0 48px; place-items: center; overflow: hidden; border: 1px solid var(--line-bright); background: #fff; color: var(--profile-color, var(--accent)); }
.header-avatar::before { position: absolute; top: -1px; left: -1px; z-index: 2; width: 11px; height: 11px; border-top: 2px solid var(--profile-color, var(--accent)); border-left: 2px solid var(--profile-color, var(--accent)); content: ""; }
.header-avatar .profile-photo { width: 100%; height: 100%; transform: scale(1.3); }
.header-avatar .profile-avatar { width: 39px; height: 39px; }
.active-profile-copy { display: grid; min-width: 0; line-height: 1; }
.active-profile-copy strong { overflow: hidden; color: var(--text); font: 800 13px var(--display); letter-spacing: .1em; text-overflow: ellipsis; white-space: nowrap; }
.active-profile-copy small { margin-top: 7px; overflow: hidden; color: var(--muted); font: 700 8px var(--display); letter-spacing: .12em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.identity { display: flex; align-items: center; gap: 18px; color: var(--muted); font: 700 10px var(--display); letter-spacing: .06em; text-transform: uppercase; }
.live-state { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.live-state i { width: 6px; height: 6px; background: var(--muted); }
.live-state.connected { color: var(--accent); }
.live-state.connected i { background: var(--accent); box-shadow: 0 0 8px rgba(121,169,0,.45); }
.live-state.reconnecting { color: var(--repair); }
.live-state.reconnecting i { background: var(--repair); animation: pulse 1.2s infinite; }

.shell { width: min(1320px, calc(100% - 32px)); margin: 18px auto 54px; }
.context-bar, .results { border: 1px solid var(--line); background: var(--panel); }
.context-bar { position: relative; display: flex; min-height: 70px; padding: 12px 14px 12px 18px; align-items: end; gap: 18px; }
.context-bar::before, .results::before { position: absolute; top: -1px; left: -1px; width: 34px; height: 2px; background: var(--accent); content: ""; }
.compact-field { min-width: min(430px, 46vw); }
.active-cycle-name { display: flex; min-height: 44px; padding: 0 14px; align-items: center; border: 1px solid var(--line-bright); background: #fff; color: var(--text); font: 800 14px var(--display); letter-spacing: .035em; }
.cycle-timer { position: relative; display: grid; min-width: 118px; min-height: 44px; padding: 7px 12px 6px 14px; align-content: center; border: 1px solid var(--line-bright); background: #fff; line-height: 1; }
.cycle-timer::before { position: absolute; top: -1px; bottom: -1px; left: -1px; width: 2px; background: var(--accent); content: ""; }
.cycle-timer span { color: var(--muted); font: 700 7px var(--display); letter-spacing: .12em; text-transform: uppercase; }
.cycle-timer strong { margin-top: 6px; color: var(--accent); font: 800 11px var(--display); letter-spacing: .06em; white-space: nowrap; }
.context-actions { display: flex; align-items: center; gap: 8px; }

.finder { margin-top: 12px; border: 0; background: transparent; }
.search-wrap { position: relative; display: flex; align-items: center; border: 1px solid var(--line); background: var(--panel); transition: border-color .15s ease; }
.search-wrap:focus-within { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.search-wrap > svg { position: absolute; left: 16px; z-index: 1; color: var(--accent); }
.search-wrap input { width: 100%; min-height: 54px; padding: 13px 48px; border: 0; outline: 0; background: transparent; color: var(--text); font: 700 13px var(--display); letter-spacing: .035em; }
.search-wrap input::placeholder { color: #7a867f; opacity: 1; }
.clear-search { position: absolute; right: 8px; display: grid; width: 38px; height: 38px; padding: 0; place-items: center; border: 0; background: transparent; color: var(--muted); }
.clear-search:hover { background: var(--panel-3); color: var(--text); }
.filter-toolbar { display: flex; margin-top: 8px; align-items: center; gap: 8px; }
.status-filters { display: flex; min-width: 0; flex: 1; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.status-filters::-webkit-scrollbar { display: none; }
.filter-chip { display: inline-flex; min-height: 34px; padding: 7px 11px; align-items: center; gap: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); white-space: nowrap; font: 800 10px var(--display); letter-spacing: .06em; text-transform: uppercase; }
.filter-chip:hover { border-color: var(--line-bright); color: var(--text); }
.filter-chip.active { border-color: #5f8700; background: #bce84d; color: #182300; }
.filter-chip .count { display: grid; min-width: 20px; height: 18px; padding: 0 5px; place-items: center; background: rgba(18,24,20,.06); color: inherit; font-size: 9px; }
.filter-chip.active .count { background: rgba(0,0,0,.15); }

.results { position: relative; min-height: 280px; margin-top: 12px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; border-bottom: 1px solid var(--line); background: #f6f8f5; color: #6a766f; text-align: left; white-space: nowrap; font: 800 9px var(--display); letter-spacing: .11em; text-transform: uppercase; }
thead th:nth-child(n + 2):nth-child(-n + 6) { text-align: center; }
td { height: 57px; padding: 9px 14px; border-bottom: 1px solid #e5e9e5; vertical-align: middle; font-size: 12px; }
tbody tr { transition: background .12s ease; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f5faed; box-shadow: inset 2px 0 0 var(--accent); }
.serial { color: var(--text); font: 800 14px var(--display); letter-spacing: .035em; }
.subtle { color: var(--muted); }
.equipment-cell { min-width: 180px; }
.equipment-cell span { display: block; font-weight: 650; }
.equipment-cell small { display: block; margin-top: 4px; color: var(--muted); font: 600 10px var(--display); }
.updated-cell { min-width: 145px; color: var(--muted); font: 600 10px var(--display); }
.edit-button { display: grid; width: 36px; height: 36px; padding: 0; place-items: center; border: 1px solid transparent; background: transparent; color: var(--muted); }
.edit-button:hover { border-color: var(--line-bright); background: var(--panel-3); color: var(--accent); }

.status-button { display: inline-flex; min-width: 126px; min-height: 38px; padding: 8px 10px 8px 11px; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid; outline: 0; font: 800 10px var(--display); letter-spacing: .05em; text-transform: uppercase; transition: filter .12s ease, transform .12s ease; }
.status-button:not(:disabled):hover { filter: brightness(.97); transform: translateY(-1px); }
.status-button:focus-visible { box-shadow: 0 0 0 2px rgba(121,169,0,.16); }
.status-button:disabled { cursor: default; opacity: 1; }
.status-step { font-size: 15px; line-height: 1; }
.status-repairing { border-color: #dfba8f; background: var(--repair-soft); color: var(--repair); }
.status-ready { border-color: #b1cc81; background: var(--ready-soft); color: var(--ready); }
.status-loading { border-color: #93c9d9; background: var(--loading-soft); color: var(--loading); }
.status-delivered { border-color: #bac5bf; background: var(--delivered-soft); color: var(--delivered); }

.card-list { padding: 0 14px; }
.item-card { position: relative; padding: 17px 4px; border-bottom: 1px solid var(--line); }
.item-card::before { position: absolute; top: 18px; left: -14px; width: 2px; height: 22px; background: var(--line-bright); content: ""; }
.item-card:last-child { border-bottom: 0; }
.card-top, .card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-serial { min-width: 0; }
.card-serial strong { display: block; overflow: hidden; text-overflow: ellipsis; font: 800 16px var(--display); letter-spacing: .035em; white-space: nowrap; }
.card-serial small { display: block; margin-top: 5px; color: var(--muted); font: 600 10px var(--display); }
.card-detail { margin: 12px 0 13px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.card-detail b { color: #303a34; font-weight: 650; }
.card-bottom .status-button { flex: 1; min-height: 44px; }
.cycle-tag { display: inline-flex; margin-top: 7px; padding: 4px 6px; border: 1px solid var(--line); background: #f6f8f5; color: var(--muted); font: 700 9px var(--display); letter-spacing: .04em; text-transform: uppercase; }

.button { display: inline-flex; min-height: 42px; padding: 9px 15px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; font: 800 10px var(--display); letter-spacing: .07em; text-transform: uppercase; }
.button.primary { border-color: #6e9900; background: #bce84d; color: #182300; }
.button.primary:hover { background: #c9ef6e; }
.button.secondary { border-color: var(--line-bright); background: transparent; color: var(--text); }
.button.secondary:hover { background: var(--panel-3); }
.button.danger { border-color: #e2aaa6; background: var(--danger-soft); color: var(--danger); }
.button:disabled { cursor: wait; opacity: .5; }
.icon-button { display: grid; width: 42px; height: 42px; padding: 0; place-items: center; border: 1px solid var(--line-bright); background: transparent; color: var(--muted); list-style: none; }
.icon-button::-webkit-details-marker { display: none; }
.icon-button:hover { border-color: var(--accent); color: var(--accent); }
.settings-button { width: 34px; height: 34px; }
.settings-button svg { width: 18px; height: 18px; }
.more-menu { position: relative; }
.more-menu[open] > summary { border-color: var(--accent); color: var(--accent); }
.menu { position: absolute; top: 40px; right: 0; z-index: 20; display: grid; width: 190px; padding: 5px; border: 1px solid var(--line-bright); background: var(--panel-2); box-shadow: 0 16px 40px rgba(28,40,32,.14); }
.menu button, .menu a { padding: 11px 12px; border: 0; background: transparent; color: var(--text); text-align: left; text-decoration: none; font: 700 10px var(--display); letter-spacing: .04em; text-transform: uppercase; }
.menu button:hover, .menu a:hover { background: var(--accent-soft); color: var(--accent); }

.field { display: grid; gap: 6px; }
.field > span { color: var(--muted); font: 800 9px var(--display); letter-spacing: .1em; text-transform: uppercase; }
.field b { color: var(--danger); }
.field input, .field select, .field textarea { width: 100%; min-height: 43px; padding: 10px 11px; border: 1px solid var(--line-bright); border-radius: 0; outline: 0; background: #fff; color: var(--text); }
.field textarea { min-height: 94px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.field small { color: var(--muted); font: 600 9px var(--display); }
.loading-state { display: flex; min-height: 200px; align-items: center; justify-content: center; gap: 7px; }
.loading-state span { width: 7px; height: 7px; background: var(--accent); animation: bounce 1s infinite ease-in-out; }
.loading-state span:nth-child(2) { animation-delay: .12s; }
.loading-state span:nth-child(3) { animation-delay: .24s; }
.empty-state { min-height: 250px; padding: 42px 20px; text-align: center; color: var(--muted); }
.empty-state svg { width: 34px; height: 34px; color: var(--accent); }
.empty-state h2 { margin: 14px 0 5px; color: var(--text); font: 800 14px var(--display); text-transform: uppercase; }
.empty-state p { margin: 0; font-size: 12px; }

.dialog { width: min(660px, calc(100% - 28px)); max-height: min(90vh, 800px); padding: 0; border: 1px solid var(--line-bright); border-radius: 0; background: var(--panel); color: var(--text); box-shadow: 0 22px 70px rgba(28,40,32,.2); overflow: auto; }
.dialog::backdrop { background: rgba(18,24,20,.28); backdrop-filter: blur(2px); }
.dialog form { margin: 0; }
.dialog-header { display: flex; padding: 18px 20px 14px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 4px 0 0; font: 800 17px var(--display); letter-spacing: .05em; text-transform: uppercase; }
.eyebrow { margin: 0; color: var(--accent); font: 800 9px var(--display); letter-spacing: .12em; text-transform: uppercase; }
.form-grid { display: grid; padding: 20px; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.dialog-actions { display: flex; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); align-items: center; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.form-error { margin: 0 20px 15px; padding: 10px 12px; border: 1px solid #e2aaa6; background: var(--danger-soft); color: var(--danger); font-size: 11px; }
.small-dialog { width: min(500px, calc(100% - 28px)); }
.confirm-dialog { width: min(430px, calc(100% - 28px)); padding-top: 24px; text-align: center; }
.confirm-dialog h2 { margin: 12px 22px 8px; font: 800 17px var(--display); text-transform: uppercase; }
.confirm-dialog p { margin: 0 28px 24px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.confirm-icon { display: grid; width: 42px; height: 42px; margin: auto; place-items: center; border: 1px solid var(--danger); background: var(--danger-soft); color: var(--danger); font: 900 20px var(--display); }
.toast-region { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 1000; display: grid; width: min(360px, calc(100% - 32px)); gap: 7px; }
.toast { padding: 12px 14px; border: 1px solid var(--accent); background: #fff; color: var(--text); box-shadow: 0 14px 36px rgba(28,40,32,.16); font: 700 10px/1.5 var(--display); animation: slide-in .18s ease-out; }
.toast.error { border-color: var(--danger); background: var(--danger-soft); color: #7d2420; }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 759px) {
  .profile-gate { padding: max(20px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom)); place-items: start center; }
  .profile-shell { width: min(410px, 100%); margin: auto 0; }
  .profile-brand { justify-content: flex-start; }
  .profile-heading { margin: 0 0 22px; text-align: left; }
  .profile-heading h1 { font-size: 25px; }
  .profile-heading > span { font-size: 11px; }
  .profile-grid { grid-template-columns: 1fr; gap: 8px; }
  .profile-card { min-height: 112px; padding: 12px 44px 12px 12px; flex-direction: row; text-align: left; }
  .avatar-frame { width: 86px; height: 86px; flex: 0 0 86px; }
  .profile-avatar { width: 68px; height: 68px; }
  .profile-photo { width: 100%; height: 100%; }
  .profile-copy { margin: 0 0 0 16px; }
  .profile-copy strong { font-size: 15px; }
  .profile-arrow { right: 16px; bottom: auto; top: 50%; transform: translateY(-50%); }
  .app-header { height: 64px; padding-right: 12px; padding-left: 12px; }
  .header-avatar { width: 42px; height: 42px; flex-basis: 42px; }
  .header-avatar .profile-avatar { width: 34px; height: 34px; }
  .active-profile { gap: 9px; }
  .active-profile-copy strong { font-size: 12px; }
  .active-profile-copy small { max-width: 150px; margin-top: 5px; font-size: 7px; }
  .identity { font-size: 8px; }
  .shell { width: 100%; margin: 0 0 76px; }
  .context-bar, .results { border-right: 0; border-left: 0; }
  .context-bar { min-height: 66px; padding: 11px 14px; align-items: end; gap: 8px; }
  .context-bar::before, .results::before { left: 0; }
  .compact-field { min-width: 0; flex: 1; }
  .cycle-timer { min-width: 92px; padding-right: 8px; padding-left: 10px; }
  .cycle-timer strong { font-size: 9px; }
  .finder { margin-top: 8px; padding: 0 10px; }
  .search-wrap input { min-height: 50px; padding-right: 42px; font-size: 11px; }
  .status-filters { padding-bottom: 1px; }
  .results { margin-top: 8px; }
  .table-wrap { display: none !important; }
  .dialog { width: 100%; max-width: none; max-height: 94dvh; margin: auto 0 0; border-right: 0; border-bottom: 0; border-left: 0; }
  .form-grid { grid-template-columns: 1fr; padding: 17px 15px; }
  .form-grid .full { grid-column: auto; }
  .dialog-header { padding: 16px 15px 12px; }
  .dialog-actions { position: sticky; bottom: 0; padding-right: 15px; padding-left: 15px; background: var(--panel); }
  .dialog-actions .button { flex: 1; }
  .confirm-dialog { width: calc(100% - 24px); margin: auto; border: 1px solid var(--line-bright); }
  .toast-region { right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
}

@media (min-width: 760px) { .card-list { display: none !important; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; } }
