/* easipac planner: shell, controls, dialogs, grid pages. Maxoptra parity (docs/UI-PARITY.md).
   Sizes are CSS pixels at 100% zoom; the reference screenshots were taken on a wide, high-DPI
   display so list-page measurements were divided by ~0.49 to get these values. */

html, body { height: 100%; }
body { overflow: hidden; background: #fff; color: var(--text); font-size: 14px; }
#app { height: 100%; display: flex; flex-direction: column; min-width: 1100px; }

.spacer { flex: 1 1 auto; }
.muted { color: var(--muted); }
.tsup sup { font-size: .62em; vertical-align: baseline; position: relative; top: -.45em; margin-left: 1px; }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
.ic { display: block; flex: none; }

/* ------------------------------------------------------------------ header (reference 20-25: 54 px at 2560 wide, 12 px type) */
.topbar {
  flex: none; height: 54px; background: var(--navy); color: #fff; display: flex; align-items: stretch; position: relative; z-index: 30;
}
.brand { width: 248px; flex: none; display: flex; align-items: center; padding-left: 15px; }
.brand img { height: 30px; width: auto; display: block; }
.tabs { display: flex; align-items: stretch; gap: 20px; }
.tab {
  position: relative; display: flex; align-items: center; padding: 0 2px; color: #CCCDE2; text-decoration: none;
  font-size: 12px; letter-spacing: 0; font-weight: 400; text-transform: uppercase;
}
.tab:hover { color: #fff; }
.tab.active { color: #fff; }
.tab.active::before { content: ""; position: absolute; left: -1px; right: -1px; top: 0; height: 4px; background: var(--blue); }
.tab:focus-visible { box-shadow: inset 0 0 0 2px #fff; border-radius: 0; }
.top-icon {
  width: 40px; background: none; border: 0; color: #fff; display: flex; align-items: center; justify-content: center; opacity: .95;
}
.top-icon:hover { opacity: 1; background: rgba(255,255,255,.07); }
.userbox {
  display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #fff; padding: 0 16px 0 10px; text-align: left; position: relative;
}
.userbox:hover { background: rgba(255,255,255,.07); }
.user-lines { display: flex; flex-direction: column; line-height: 1.25; font-size: 12px; }
.user-name { font-weight: 400; }
.user-role { color: #E2E3F0; font-weight: 400; }
.live-dot { position: absolute; right: 8px; top: 9px; width: 7px; height: 7px; border-radius: 50%; background: #1DB954; }
.map-popout .topbar { display: none; }

.view-host { flex: 1 1 auto; min-height: 0; position: relative; display: flex; flex-direction: column; }
.view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.fatal { padding: 40px; color: var(--danger); }

/* ------------------------------------------------------------------ login */
.login-page { flex: 1; background: var(--panel); display: flex; align-items: flex-start; justify-content: center; padding-top: 90px; }
.login-card { width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 28px 30px 30px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 2px 10px rgba(27,28,65,.06); }
.login-card h1 { font-size: 24px; font-weight: 400; margin-bottom: 4px; color: var(--text-strong); }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field label { color: var(--muted-2); }
.login-btn { height: 40px; font-size: 16px; margin-top: 6px; }
.login-error { min-height: 18px; color: var(--danger); }

/* ------------------------------------------------------------------ form controls */
.mx-input, .mx-select, textarea.mx-input {
  height: 30px; border: 1px solid #CED2DA; border-radius: 3px; background: #fff; padding: 0 9px; font-size: 14px; color: var(--text); min-width: 0; width: 100%;
}
textarea.mx-input { height: auto; padding: 6px 9px; resize: vertical; line-height: 1.4; }
.mx-input:hover:not(:disabled), .mx-select:hover:not(:disabled) { border-color: #AEB3BF; }
.mx-input:focus, .mx-select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(0,115,255,.18); }
.mx-input:disabled, .mx-select:disabled, .mx-input[readonly] { background: #EEF0F4; color: #8A8FA0; cursor: not-allowed; }
.mx-input::placeholder { color: #B0B3BF; }
.mx-select {
  appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23354052' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.mx-input[type=number] { padding-right: 4px; }
.mx-input[type=time], .mx-input[type=date] { padding-right: 6px; }
/* checkbox and radio like the reference: pale square, blue fill with a white tick when set */
.mx-check, .mx-radio { appearance: none; -webkit-appearance: none; width: 15px; height: 15px; margin: 0; flex: none; background: #fff; border: 1px solid #C4C7D1; cursor: pointer; position: relative; vertical-align: middle; }
.mx-check { border-radius: 3px; }
.mx-radio { border-radius: 50%; }
.mx-check:hover:not(:disabled), .mx-radio:hover:not(:disabled) { border-color: #8F95A8; }
.mx-check:checked { background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-6.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat; border-color: var(--blue); }
.mx-radio:checked { border: 4px solid var(--blue); background: #fff; }
.mx-check:disabled, .mx-radio:disabled { background-color: #F1F2F5; border-color: #DADCE3; cursor: not-allowed; }
.mx-check:checked:disabled { background-color: #A9CBFF; border-color: #A9CBFF; }
.mx-radio:checked:disabled { border-color: #A9CBFF; }
.mx-check:focus-visible, .mx-radio:focus-visible { box-shadow: 0 0 0 2px rgba(0,115,255,.35); border-radius: 3px; }
.cb-label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.cb-label input:disabled + span { color: var(--muted); }

.btn { border-radius: 4px; }
.btn-sm { min-height: 24px; }
.btn-lg { min-height: 40px; font-size: 16px; padding: 0 22px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; padding: 4px; color: var(--muted); border-radius: 3px; }
.icon-btn:hover:not(:disabled) { color: var(--text); background: rgba(27,28,65,.06); }
.icon-btn:disabled { opacity: .4; }
.link { color: var(--blue-link); background: none; border: 0; padding: 0; text-decoration: none; cursor: pointer; font: inherit; }
.link:hover { text-decoration: underline; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--toolbar); color: var(--text); }

.loading-dots { display: inline-block; width: 28px; height: 28px; position: relative; animation: spin 1.1s linear infinite; }
.loading-dots i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.loading-dots i:nth-child(1) { left: 2px; top: 2px; opacity: .45; } .loading-dots i:nth-child(2) { right: 2px; top: 2px; opacity: .7; }
.loading-dots i:nth-child(3) { right: 2px; bottom: 2px; } .loading-dots i:nth-child(4) { left: 2px; bottom: 2px; opacity: .6; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; align-items: center; justify-content: center; padding: 60px; }
.empty-note { padding: 28px; text-align: center; color: var(--muted); }
.error-box { margin: 20px; padding: 14px 16px; border: 1px solid #F3B5BD; background: var(--danger-tint); color: #8E1F2F; border-radius: 4px; display: flex; gap: 12px; align-items: center; }

/* ------------------------------------------------------------------ toasts */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 5000; display: flex; flex-direction: column; gap: 8px; width: 380px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 4px; padding: 10px 10px 10px 12px; box-shadow: 0 4px 16px rgba(27,28,65,.18); }
.toast-msg { flex: 1; padding-top: 1px; word-break: break-word; }
.toast-error { border-left-color: var(--danger); } .toast-error > .ic { color: var(--danger); }
.toast-success { border-left-color: var(--success); } .toast-success > .ic { color: var(--success); }
.toast-info > .ic { color: var(--blue); }

/* ------------------------------------------------------------------ dialogs */
.scrim { position: fixed; inset: 0; background: rgba(40,44,60,.55); z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 20px 20px; overflow: auto; }
.dlg { background: #fff; border-radius: 3px; box-shadow: 0 8px 36px rgba(0,0,0,.35); max-width: 100%; display: flex; flex-direction: column; max-height: 90vh; position: relative; margin: 0 auto; }
.dlg.is-busy::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.4); }
.dlg-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px 10px; border-bottom: 1px solid var(--line-soft); flex: none; }
.dlg-title { font-size: 14px; font-weight: 700; color: var(--text-strong); }
.dlg-x { color: #555B6E; padding: 2px; }
.dlg-body { padding: 16px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.dlg-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line-soft); flex: none; background: #fff; }
.dlg-footer .btn { min-width: 84px; }
.dlg-msg { line-height: 1.5; }
.dlg-alert .dlg-header { border-bottom: 0; padding-bottom: 0; }
.dlg-alert .dlg-body { padding: 14px 16px 8px 36px; }
.dlg-alert .dlg-footer { border-top: 0; padding-top: 4px; }
.dlg-kind { width: 14px; height: 14px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.dlg-kind-error { background: #E5334B; } .dlg-kind-info { background: var(--blue); }
.dlg-info-bar { background: #FFF8E1; border: 1px solid #F3E5B0; color: #8A6A1A; padding: 8px 12px; border-radius: 3px; margin-bottom: 14px; }

/* form rows (Maxoptra: label left, control right) */
.frow { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; min-height: 32px; }
.flabel { flex: 0 0 150px; color: var(--text); line-height: 1.2; }
.fcontrol { flex: 1 1 auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.req { color: var(--danger); }
.fgroup { font-weight: 700; margin: 16px 0 8px; display: flex; align-items: center; gap: 10px; color: var(--text-strong); }
.fgroup::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.fgroup:first-child { margin-top: 0; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 36px; }
.frow.top { align-items: flex-start; } .frow.top .flabel { padding-top: 7px; }

/* tabs inside dialogs */
.dtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -16px -16px 16px; padding: 10px 16px 0; background: #fff; position: sticky; top: -16px; z-index: 2; }
.dtab { background: #F1F2F6; border: 1px solid var(--line); border-bottom: 0; border-radius: 3px 3px 0 0; padding: 6px 12px; color: var(--muted-2); font-size: 14px; position: relative; top: 1px; }
.dtab:hover { background: #E8EAF1; }
.dtab[aria-selected=true] { background: #fff; color: var(--text-strong); font-weight: 700; border-color: var(--line-strong); }

/* ------------------------------------------------------------------ popovers, menus, hover card */
.popover { position: fixed; z-index: 2000; background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; box-shadow: 0 6px 22px rgba(27,28,65,.22); }
.popover-menu { min-width: 200px; }
.menu { list-style: none; margin: 0; padding: 6px 0; }
.menu-title { padding: 8px 14px 8px; font-weight: 700; border-bottom: 1px solid var(--line); margin-bottom: 4px; color: var(--text-strong); }
.menu-sep { border-top: 1px solid var(--line); margin: 5px 0; }
.menu li { position: relative; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 7px 14px; text-align: left; color: var(--text); font-size: 14px; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--panel); box-shadow: none; }
.menu-item:disabled { color: var(--disabled); }
.menu-item .ic { color: var(--muted-2); } .menu-arrow { margin-left: auto; }
.menu-noicon { width: 16px; } .menu-label { flex: 1; white-space: nowrap; }
.menu-swatch { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.menu-sub { display: none; position: absolute; left: 100%; top: -6px; background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; box-shadow: 0 6px 22px rgba(27,28,65,.22); min-width: 190px; max-height: 60vh; overflow: auto; }
.has-sub:hover > .menu-sub, .has-sub:focus-within > .menu-sub { display: block; }
.hovercard { position: fixed; z-index: 2500; background: #2A2C46; color: #fff; border-radius: 6px; padding: 12px 14px; width: 330px; box-shadow: 0 8px 24px rgba(0,0,0,.35); pointer-events: none; font-size: 13px; }

/* ------------------------------------------------------------------ list pages (Orders, Vehicles, ...) */
.listpage { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fff; min-width: 0; }
.list-title { flex: none; height: 56px; display: flex; align-items: center; padding: 0 14px 0 16px; background: var(--grid-head); border-bottom: 1px solid var(--line-soft); gap: 8px; }
.list-title h1 { font-size: 22px; font-weight: 400; color: var(--text-strong); }
.list-title .spacer { flex: 1; }
.tb-btn { height: 34px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; background: #fff; border: 1px solid var(--line); border-radius: 4px; color: var(--text-strong); font-size: 14px; }
.tb-btn:hover { border-color: #BFC1CC; background: #FDFDFD; }
.tb-btn.active { border-color: var(--blue); color: var(--blue); }
.search-box { display: flex; height: 34px; width: 226px; border: 1px solid var(--line); border-radius: 4px; background: #fff; overflow: hidden; }
.search-box input { flex: 1; min-width: 0; border: 0; padding: 0 10px; font-size: 14px; outline: none; background: transparent; }
.search-box input::placeholder { color: #C0C3CC; }
.search-box button { width: 40px; border: 0; border-left: 1px solid var(--line); background: #fff; color: #9A9EAE; display: flex; align-items: center; justify-content: center; }
.search-box button:hover { color: var(--text); }
.gear-btn { background: none; border: 0; color: #1F2733; width: 32px; height: 34px; display: flex; align-items: center; justify-content: center; }
.gear-btn:hover { color: var(--blue); }

.grid-wrap { flex: 1; min-height: 0; overflow: auto; position: relative; }
.grid { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--grid-head); height: 32px; font-weight: 400; text-align: left; padding: 0 8px 0 10px; color: var(--text-strong); border-bottom: 1px solid var(--line-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid thead th.sortable { cursor: pointer; padding-right: 22px; user-select: none; }
.grid thead th .sort-ic { position: absolute; right: 6px; top: 8px; color: #B4B7C2; }
.grid thead th.sorted .sort-ic { color: var(--blue); }
.grid td { height: 30px; padding: 0 10px; border-bottom: 1px solid #F0F0F2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-strong); }
.grid tbody tr:hover td { background: var(--grid-hover); }
.grid tbody tr.selected td { background: var(--blue-tint); }
.grid tbody tr { cursor: default; }
.grid .chk { width: 36px; padding: 0 0 0 12px; }
.grid td.num, .grid th.num { text-align: right; }
.grid .empty td { text-align: center; color: var(--muted); padding: 40px; height: auto; }
.grid-wrap > .loading-block { position: absolute; inset: 0; background: rgba(255,255,255,.55); z-index: 3; padding: 0; }
.list-footer { flex: none; height: 56px; display: flex; align-items: center; padding: 0 6px; background: var(--grid-head); border-top: 1px solid var(--line); gap: 10px; }
.list-footer .left { display: flex; gap: 8px; flex: 1; align-items: center; }
.list-footer .right { flex: 1; display: flex; justify-content: flex-end; align-items: center; gap: 10px; color: var(--text); }
.list-footer .btn { min-height: 30px; padding: 0 15px; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--text-strong); }
.btn-ghost:hover:not(:disabled) { background: #fff; border-color: #BFC1CC; }
.btn-ghost:disabled { background: #F5F5F5; color: #B8BBC6; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager button { min-width: 30px; height: 28px; background: none; border: 1px solid transparent; border-radius: 3px; color: #8A8FA0; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
.pager button:hover:not(:disabled) { color: var(--text); }
.pager button.cur { border-color: var(--blue); color: var(--blue); font-weight: 700; background: #fff; }
.pager select { height: 28px; }
.sq-btn { width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 3px; display: flex; align-items: center; justify-content: center; color: #3A3F52; }
.sq-btn:hover { border-color: #BFC1CC; }

/* column chooser, filter popovers */
.pop-pad { padding: 12px 14px; min-width: 240px; }
.pop-pad h4 { font-weight: 700; margin-bottom: 8px; }
.pop-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.collist { max-height: 300px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }

/* custom scrollbars (thin, like the app) */
* { scrollbar-width: thin; scrollbar-color: #B9BCC8 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: #B9BCC8; border-radius: 6px; border: 2px solid #fff; }
::-webkit-scrollbar-thumb:hover { background: #9A9EAE; } ::-webkit-scrollbar-track { background: transparent; }

/* OrderWise feed watchdog bar (main.js watchFeed) */
.feed-alert { background: #B3261E; color: #fff; font-size: 12px; font-weight: 600; padding: 6px 14px; text-align: center; }
.feed-alert[hidden] { display: none; }
