/* EMS Equipment Control: design system
   One system: one type scale, one radius scale, one button pair, one card style.
   Motion: hover/press feedback only. Nothing moves because the page scrolled.
   Everything rests under prefers-reduced-motion. */

/* ---------- Fonts (local files, work offline) ---------- */
@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url(/fonts/plex-sans-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Plex"; font-weight: 500; font-display: swap; src: url(/fonts/plex-sans-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url(/fonts/plex-sans-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Plex"; font-weight: 700; font-display: swap; src: url(/fonts/plex-sans-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(/fonts/plex-sans-arabic-400.woff2) format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(/fonts/plex-sans-arabic-500.woff2) format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(/fonts/plex-sans-arabic-600.woff2) format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(/fonts/plex-sans-arabic-700.woff2) format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  interpolate-size: allow-keywords;

  --font: "Plex", "Plex Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;

  /* brand */
  --navy: #082b49; --navy-2: #0c3a60; --blue: #0875ae; --orange: #f28b28;

  /* surfaces and text */
  --bg: #f3f6f9; --surface: #ffffff; --surface-2: #f7f9fb; --sunken: #eaf0f5;
  --line: #dbe4ec; --line-strong: #c3d0db;
  --text: #0f2a3d; --text-2: #3d566a; --muted: #5b7183;
  --accent: var(--blue); --accent-text: #ffffff; --accent-soft: #e4f1f8;
  --focus: #0875ae55;

  /* status */
  --in: #14684f; --in-bg: #e2f4ec; --out: #86490b; --out-bg: #fff0db; --danger: #a52f2c; --danger-bg: #fdeae9;
  --attendance-under: #8a5a00; --attendance-under-bg: #fff0c2; --attendance-holiday: #0875ae; --attendance-holiday-bg: #e2f1f9;
  --attendance-off-bg: #e8edf1;
  --attendance-incomplete: #b54708; --attendance-incomplete-bg: #ffedd5;
  --attendance-over: var(--in); --attendance-over-bg: var(--in-bg);

  /* radius scale */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;

  /* elevation */
  --sh-sm: 0 1px 2px #0a2b4510, 0 1px 1px #0a2b4508;
  --sh-md: 0 6px 18px #0a2b4514, 0 2px 4px #0a2b4509;
  --sh-lg: 0 24px 60px #0a2b4533, 0 4px 12px #0a2b4514;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 120ms; --t: 200ms;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #061a2a; --navy-2: #0a2a42; --blue: #34aadb; --orange: #f49a42;
  --bg: #0a1620; --surface: #112431; --surface-2: #14293a; --sunken: #0d1d28;
  --line: #25404f; --line-strong: #345568;
  --text: #e8f1f6; --text-2: #bfd0da; --muted: #9db2bf;
  --accent: #34aadb; --accent-text: #04202f; --accent-soft: #123649;
  --focus: #34aadb66;
  --in: #67d0a5; --in-bg: #15382f; --out: #ffbc69; --out-bg: #3b2b19; --danger: #ff9690; --danger-bg: #432321;
  --attendance-under: #ffd277; --attendance-under-bg: #45391f; --attendance-holiday: #34aadb; --attendance-holiday-bg: #123649;
  --attendance-off-bg: #263640;
  --attendance-incomplete: #ffb36e; --attendance-incomplete-bg: #462918;
  --attendance-over: var(--in); --attendance-over-bg: var(--in-bg);
  --sh-sm: 0 1px 2px #00000040;
  --sh-md: 0 8px 22px #00000050;
  --sh-lg: 0 28px 70px #00000080;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 var(--font); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.012em; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 650; margin: 28px 0 12px; }
h3 { font-size: 16px; font-weight: 650; margin: 18px 0 8px; }
p { margin: 0; }
.sub { color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ar { color: var(--muted); font-size: 14px; text-align: left; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
svg.i { width: 1.2em; height: 1.2em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.main { padding-top: 24px; padding-bottom: 56px; min-height: 60vh; }

/* ---------- App header ---------- */
.top {
  position: relative; color: #fff; border-bottom: 3px solid var(--orange);
  background: linear-gradient(120deg, var(--navy-2) 0%, var(--navy) 60%);
}
.top::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(#ffffff0a 1px, transparent 1px), linear-gradient(90deg, #ffffff0a 1px, transparent 1px);
  background-size: 36px 36px;
  -webkit-mask-image: linear-gradient(90deg, transparent 20%, #000 100%); mask-image: linear-gradient(90deg, transparent 20%, #000 100%);
}
.top-in { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 20px; padding-bottom: 20px; }
.brand-lockup { display: flex; align-items: center; gap: 16px; min-width: 0; }
.ems-logo { display: block; flex: 0 0 150px; width: 150px; height: 46px; border-radius: var(--r-md); object-fit: cover; object-position: center; background: #fff; }
.brand-divider { width: 1px; height: 44px; background: #ffffff33; }
.department-title { min-width: 0; }
.department-title h1 { color: #fff; font-size: 22px; margin: 2px 0 1px; }
.department-title .sub { color: #bcd2e2; font-size: 13px; }
.eyebrow { color: var(--orange); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.user-chip { display: flex; align-items: center; gap: 12px; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px; font-weight: 650; letter-spacing: .02em; color: #fff;
  background: linear-gradient(140deg, var(--blue), #0a5f8c); box-shadow: inset 0 0 0 1px #ffffff33;
}
#avatar { background-repeat: no-repeat; background-color: #0879a8; }
.crop-zoom { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0; }
.crop-zoom input { width: min(260px, 55vw); }
.crop-stage { display: grid; place-items: center; }
.crop-stage canvas { width: min(320px, 75vw); height: min(320px, 75vw); touch-action: none; border-radius: 8px; background: #dce4e9; }
.notification-button { position: relative; }
.notification-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; color: #fff; background: #c63d37; font-size: 11px; }
.notification-item { padding: 13px 4px; border-bottom: 1px solid var(--line); }
.notification-item.unread { background: color-mix(in srgb, var(--blue) 7%, transparent); }
.notification-item div { margin: 4px 0; }
.notification-item small { color: var(--muted); }
.password-checklist { display:grid; gap:5px; margin:8px 0 14px; color:var(--text-2); font-size:13px; }
.password-checklist label { display:flex; align-items:center; gap:8px; }
.password-checklist input { width:15px; height:15px; margin:0; accent-color:#16835f; }
.password-checklist label.met { color:#16835f; }
.who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.account-label { color: #9fbbce; font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.who b { color: #fff; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: 4px; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; font: inherit; font-size: 13px; font-weight: 600;
  color: #e5f0f7; background: #ffffff12; border: 1px solid #ffffff2e; border-radius: var(--r-sm); cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast) var(--ease), border-color var(--t-fast);
}
.icon-btn:hover { background: #ffffff22; border-color: #ffffff55; transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0) scale(.97); }

/* ---------- Navigation ---------- */
.tabbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 90%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.tabbar .tabs { position: relative; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabbar .tabs::-webkit-scrollbar { display: none; }
.tabbar .tab {
  position: relative; display: inline-flex; align-items: center; gap: 9px; padding: 15px 16px; border: 0; border-radius: 0; background: none;
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: color var(--t-fast);
}
.tabbar .tab:hover { color: var(--text); }
.tabbar .tab.active { color: var(--text); box-shadow: inset 0 -3px 0 var(--accent); }
.tabbar .tab.active svg.i { color: var(--accent); }
html.ink .tabbar .tab.active { box-shadow: none; }
.tab-ink { position: absolute; left: 0; bottom: 0; height: 3px; width: var(--w, 0); transform: translateX(var(--x, 0)); background: var(--accent); border-radius: 3px 3px 0 0; transition: transform .3s var(--ease), width .3s var(--ease); pointer-events: none; }

/* ---------- Buttons and links (one pair) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); cursor: pointer; box-shadow: var(--sh-sm);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--sh-md); border-color: var(--accent); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: var(--sh-sm); }
.btn.primary { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { min-height: 34px; padding: 0 13px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled, .btn.busy { opacity: .7; cursor: progress; transform: none; }
.btn.busy { position: relative; color: transparent; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-text); border-top-color: transparent; animation: spin .7s linear infinite; }
.btn:not(.primary).busy::after { border-color: var(--text); border-top-color: transparent; }
.link {
  display: inline; padding: 6px 0; font: inherit; font-size: 13px; font-weight: 500; color: var(--text-2); background: none; border: 0; cursor: pointer;
  background-image: linear-gradient(currentColor, currentColor); background-repeat: no-repeat; background-position: 0 calc(100% - 3px); background-size: 0 1px; transition: background-size .25s var(--ease), color var(--t-fast);
}
.link:hover { color: var(--accent); background-size: 100% 1px; }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: var(--r-sm); color: var(--muted); background: transparent; cursor: pointer; }
.password-toggle:hover { color: var(--accent); background: var(--surface-2); }
.password-toggle .i { width: 19px; height: 19px; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }

/* ---------- Chips and badges ---------- */
.badge, .chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before, .chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.in, .chip.in { color: var(--in); background: var(--in-bg); }
.badge.out, .chip.out { color: var(--out); background: var(--out-bg); }
.badge.late, .chip.none, .chip.late { color: var(--danger); background: var(--danger-bg); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin-bottom: 12px; box-shadow: var(--sh-sm); }
.row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.name { font-weight: 600; font-size: 16px; }
.detail { margin-top: 6px; font-size: 14px; color: var(--muted); }
.detail b { color: var(--text); font-weight: 600; }
.detail a { color: var(--accent); text-decoration: none; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 24px; margin: 14px 0 0; }
.facts dt { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-weight: 500; font-size: 14px; }
.facts dd.late { color: var(--danger); }
.note { background: var(--out-bg); color: var(--out); border-radius: var(--r-md); padding: 11px 14px; font-size: 14px; margin: 12px 0; }
.okbox { background: var(--in-bg); color: var(--in); border-radius: var(--r-md); padding: 11px 14px; font-size: 14px; margin: 12px 0; }
.err { color: var(--danger); font-size: 14px; margin-top: 8px; }
.err:empty { display: none; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 32px 0 12px; }
.section-head h2 { margin: 0; }

/* Loan cards: a coloured edge shows the state */
.card.loan { position: relative; padding-left: 20px; }
.card.loan::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--line-strong); }
.card.loan.out::before { background: var(--orange); }
.card.loan.late::before { background: var(--danger); }
.card.loan.in::before { background: var(--in); }
.loan-title { display: flex; align-items: center; gap: 12px; }
.mini-icon { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--accent-soft); font-size: 22px; }

/* ---------- Item tiles ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile {
  display: flex; flex-direction: column; align-items: stretch; gap: 0; text-align: left; padding: 20px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-sm); cursor: pointer;
  transition: transform var(--t) var(--ease), box-shadow var(--t), border-color var(--t);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--accent); }
.tile:active { transform: translateY(0) scale(.99); }
.tile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tile .icon {
  width: 64px; height: 64px; display: grid; place-items: center; font-size: 34px; line-height: 1; border-radius: var(--r-md);
  background: linear-gradient(145deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 40%, var(--surface)));
  box-shadow: inset 0 0 0 1px var(--line);
}
.tile .tname { margin-top: 16px; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.tile .ar { margin-top: 2px; }
.tile-foot { display: block; margin-top: auto; padding-top: 18px; }
.meter { display: block; height: 6px; border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--fill, 0%); border-radius: inherit; background: linear-gradient(90deg, var(--in), color-mix(in srgb, var(--in) 70%, var(--accent))); }
.tile.is-empty .meter i { width: 0; }
.count { margin-top: 10px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.count.none { color: var(--danger); }
.count b { color: var(--text); font-weight: 700; font-size: 15px; }
.count.none b { color: var(--danger); }

/* ---------- Forms ---------- */
label { display: block; margin: 14px 0 5px; font-size: 13px; font-weight: 500; color: var(--text-2); }
input, textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line-strong)); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--focus); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a8f9f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="checkbox"], input[type="radio"] { width: 18px; min-height: 18px; height: 18px; padding: 0; accent-color: var(--accent); vertical-align: -3px; }
input[type="file"] { padding: 8px; }
input[type="file"]::file-selector-button { margin-right: 12px; padding: 7px 13px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; cursor: pointer; }
.remember-option { display: flex; align-items: center; gap: 9px; margin: 14px 0 0; color: var(--text-2); cursor: pointer; }
.remember-option input { flex: none; }

/* ---------- Dialog ---------- */
dialog {
  width: min(560px, 94vw); max-height: 92vh; padding: 24px; overflow: auto; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
}
dialog:has(#projectForm) { width: min(780px, 96vw); }
dialog[open] { animation: dlg-in .22s var(--ease); }
dialog::backdrop { background: #04121e99; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog[open]::backdrop { animation: fade-in .2s ease-out; }
.dlg-x { position: sticky; top: 0; float: right; z-index: 2; margin: -10px -10px 0 8px; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; color: var(--muted); background: none; border: 0; border-radius: var(--r-sm); cursor: pointer; transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast); }
.dlg-x:hover { color: var(--text); background: var(--sunken); }
.dlg-x:active { transform: scale(.92); }
#dlgBody > form > h3:first-child, #dlgBody > h3:first-child { margin: 0 40px 4px 0; font-size: 20px; }
.sheet-head { display: flex; align-items: center; gap: 16px; margin: 0 40px 6px 0; }
.sheet-head .icon { width: 64px; height: 64px; display: grid; place-items: center; font-size: 36px; line-height: 1; border-radius: var(--r-md); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--line); }
.sheet-head .name { font-size: 20px; }
dialog h2 { margin: 22px 0 10px; font-size: 16px; }
dialog .card { box-shadow: none; background: var(--surface-2); }
.timeline { position: relative; margin: 0; padding: 0 0 0 18px; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 14px; font-size: 14px; color: var(--muted); }
.timeline li::before { content: ""; position: absolute; left: -18px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--in); }
.timeline li b { color: var(--text); font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; display: flex; align-items: center; gap: 10px; max-width: min(92vw, 460px); padding: 12px 18px;
  font-size: 14px; font-weight: 500; color: var(--bg); background: var(--text); border-radius: var(--r-pill); box-shadow: var(--sh-lg);
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity var(--t), transform var(--t) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg.i { color: var(--in-bg); stroke-width: 2.4; }

/* ---------- Empty and loading states ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 56px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.empty .empty-ico { width: 56px; height: 56px; display: grid; place-items: center; margin-bottom: 6px; color: var(--accent); background: var(--accent-soft); border-radius: 50%; }
.empty .empty-ico svg.i { width: 26px; height: 26px; }
.empty b { color: var(--text); font-size: 16px; font-weight: 600; }
.skel { border-radius: var(--r-md); background: linear-gradient(90deg, var(--sunken) 25%, color-mix(in srgb, var(--sunken) 55%, var(--surface)) 50%, var(--sunken) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel.tile-skel { height: 196px; border-radius: var(--r-lg); }
.skel.row-skel { height: 96px; margin-bottom: 12px; }

/* ---------- Photos: zoom inside the frame ---------- */
.photo-frame { display: block; overflow: hidden; background: var(--sunken); }
.photo-frame img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.photo-frame:hover img { transform: scale(1.03); }

/* ---------- Attendance ---------- */
.section-tabs { display: flex; flex-wrap: wrap; gap: 6px; width: fit-content; max-width: 100%; padding: 4px; margin: 8px 0 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.section-tab { min-height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.section-tab:hover { color: var(--text); background: color-mix(in srgb,var(--accent-soft) 70%,transparent); }
.section-tab.active { color: var(--text); background: var(--surface); box-shadow: var(--sh-sm); }
.supplies-panel > h3 { margin: 0 0 12px; }
.supply-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,235px),1fr)); gap: 14px; }
.supply-tile-wrap { position: relative; min-width: 0; }
.supply-tile-wrap .tile { width: 100%; min-height: 200px; }
.supply-edit { position: static; float: right; min-height: 30px; margin-top: 6px; padding: 0 10px; }
.attendance-history-toolbar { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.attendance-history-toolbar h3 { flex: 1; margin: 0; text-align: center; }
.attendance-history-toolbar select { width: auto; min-width: 170px; margin: 0; }
.admin-attendance-list { display: grid; gap: 10px; }
.admin-attendance-event { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0; }
.attendance-request-admin { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; align-items: center; }
.attendance-request-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.attendance-request-actions input { min-width: 180px; margin: 0; }
.calendar-year { display: flex; gap: 12px; align-items: center; margin: 0 0 16px; }
.calendar-year label { margin: 0; }
.calendar-year select { width: auto; min-width: 110px; }
.month-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.month { padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--sh-sm); }
.month h3 { margin: 0 0 10px; font-size: 14px; font-weight: 650; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.day-head, .day { min-height: 32px; display: grid; place-items: center; font-size: 12px; }
.day-head { color: var(--muted); font-weight: 600; }
.day { padding: 0; font: inherit; font-size: 12px; color: var(--text-2); background: none; border: 0; border-radius: 50%; cursor: default; }
.day.today { box-shadow: inset 0 0 0 2px var(--orange); color: var(--text); font-weight: 700; }
.day.has-event { color: var(--accent-text); background: var(--accent); font-weight: 650; cursor: pointer; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast); }
.day.has-event:hover { transform: scale(1.12); box-shadow: var(--sh-md); }
.attendance-list { margin-top: 28px; }
.attendance-summary { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin: 14px 0; }
.attendance-summary .card { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; }
.attendance-summary .card span { color: var(--muted); font-size: 13px; }
.attendance-summary .card b { font-size: 20px; white-space: nowrap; }
.overtime-value { color: var(--in); }
.undertime-value,.absent-value { color: var(--danger); }
.attendance-calendar { margin-top: 14px; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.calendar-toolbar h3 { margin: 0; }
.attendance-days { grid-template-columns: repeat(7,minmax(0,1fr)); }
.attendance-day { min-height: 62px; align-content: center; gap: 2px; border-radius: var(--r-sm); cursor: pointer; }
.attendance-day span { font-weight: 650; }
.attendance-day small { font-size: 9px; line-height: 1.1; }
.attendance-day.off,.attendance-day.upcoming,.attendance-day.before-account { color: var(--muted); background: var(--surface-2); }
.attendance-day.off { background: var(--attendance-off-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--muted) 24%, transparent); }
.attendance-day.holiday { color: var(--attendance-holiday); background: var(--attendance-holiday-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--attendance-holiday) 22%, transparent); }
.day-head-off { color: var(--muted); opacity: .68; }
.attendance-day.worked { color: var(--in); background: var(--in-bg); }
.attendance-day.overtime { color: var(--attendance-over); background: var(--attendance-over-bg); }
.attendance-day.undertime { color: var(--attendance-under); background: var(--attendance-under-bg); }
.attendance-day.absent { color: var(--danger); background: var(--danger-bg); }
.attendance-day.incomplete { color: var(--attendance-incomplete); background: var(--attendance-incomplete-bg); }
.attendance-day.in-progress { color: var(--accent); background: var(--accent-soft); }
.attendance-day.off-worked,.attendance-day.holiday-worked { color: var(--attendance-over); background: var(--attendance-over-bg); }
.attendance-day.off.today { color: var(--muted); background: var(--attendance-off-bg); opacity: 1; }
.attendance-user-folders { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 12px; margin-top: 14px; }
.attendance-user-folder { display: flex; align-items: center; gap: 12px; width: 100%; margin: 0; padding: 16px; text-align: left; cursor: pointer; }
.attendance-user-folder > span:nth-child(2) { display: grid; gap: 3px; min-width: 0; flex: 1; }
.attendance-user-folder small { color: var(--muted); overflow-wrap: anywhere; }
.attendance-folder-icon { color: var(--accent); display: grid; place-items: center; width: 42px; height: 42px; border-radius: var(--r-sm); background: var(--accent-soft); }
.folder-arrow { font-size: 24px; color: var(--muted); }
.attendance-punch-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.attendance-punch-pair > div { display: grid; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.attendance-punch-pair span { color: var(--muted); font-size: 13px; }
.attendance-punch-pair b { font-size: 18px; }
.attendance-camera { display: grid; place-items: center; width: min(100%,560px); min-height: 220px; margin: 14px auto 8px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: #07131c; }
.attendance-camera video,.attendance-camera img { display: block; width: 100%; max-height: 55vh; object-fit: contain; }
.attendance-capture-actions,.attendance-location-row { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 10px 0; }
.attendance-location-row { justify-content: space-between; }
.attendance-punch-meta { display: grid; gap: 5px; margin-top: 6px; font-size: 12px; }
.attendance-punch-meta .sub { font-size: 12px; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: var(--line-strong); }
.legend-worked { background: var(--in); }.legend-absent { background: var(--danger); }.legend-incomplete { background: var(--attendance-incomplete); }.legend-off { background: var(--muted); }.legend-holiday { background: var(--accent); }
.legend-overtime { background: var(--attendance-over); }.legend-undertime { background: var(--attendance-under); }
.attendance-admin-tools { margin-top: 14px; }
.attendance-admin-tools h3 { margin-top: 0; }
.holiday-form { display: grid; grid-template-columns: 1fr 1.4fr auto; align-items: end; gap: 10px; }
.holiday-form label { margin-top: 0; }
.holiday-list { display: grid; gap: 8px; margin-top: 14px; }
.holiday-list .row { align-items: center; font-size: 13px; }
.attendance-event,.attendance-request-history { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.attendance-request-history .badge { flex: none; }
.attendance-day-details .attendance-modal-photo { display: block; max-width: 160px; max-height: 160px; margin-top: 10px; border-radius: var(--r-md); }
.attendance-day-details form { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 8px; }
.attendance-day-details form h3 { margin-top: 12px; }
.event-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.event-photo { width: 84px; height: 84px; border-radius: var(--r-md); flex: none; }
.event-photo img { width: 100%; height: 100%; }

/* ---------- Projects ---------- */
.project-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; align-items: start; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; margin-top: 12px; }
.admin-grid .card { margin: 0; }
@media (min-width: 900px) {
  .project-list > .project-card:only-child .project-media { height: 220px; }
  .project-list > .project-card:only-child .sys-list { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
}
.project-card { display: flex; flex-direction: column; padding: 0; margin: 0; overflow: hidden; transition: transform var(--t) var(--ease), box-shadow var(--t), border-color var(--t); }
.project-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.operation-project { overflow: hidden; }
.operation-project .project-body { display: grid; gap: 12px; }
.operation-project h3,.operation-project h4 { margin: 0; }
.operation-project-thumb { display:block; width:100%; height:190px; object-fit:cover; background:var(--surface-2); }
.receipt-drop-zone { min-height: 160px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 18px; border: 2px dashed var(--line); border-radius: var(--r-md); background: var(--surface-2); text-align: center; transition: border-color var(--t), background var(--t); }
.receipt-drop-zone.is-dragging { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.receipt-drop-zone > span:first-child .i { width: 28px; height: 28px; color: var(--accent); }
.receipt-file-name { max-width: 100%; overflow-wrap: anywhere; font-size: 13px; color: var(--text-2); }
.receipt-history { margin-top: 18px; }
.receipt-history .section-title { display: flex; align-items: center; gap: 8px; }
.receipt-history .section-title .i { color: var(--accent); }
.project-media { height: 190px; }
.project-body { padding: 18px 20px 20px; }
.project-body .detail { margin-top: 8px; }
.project-dates { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.project-dates b { color: var(--text); font-weight: 600; }
.project-date-fields { grid-template-columns: 1fr 1fr; gap: 10px; }
.sys-list { display: grid; gap: 10px; margin-top: 16px; }
.sys { border: 1px solid var(--line); border-radius: var(--r-md); padding: 4px 14px 8px; background: var(--surface-2); }
.sys h3 { display: flex; align-items: center; gap: 9px; margin: 10px 0 4px; font-size: 14px; }
.sys h3 svg.i { color: var(--accent); }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: 14px; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }
.members { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.stat-pill { padding: 4px 11px; font-size: 12px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--text-2); }

/* ---------- Project editor (collapsible branches) ---------- */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details::details-content { block-size: 0; overflow: clip; transition: block-size .22s var(--ease), content-visibility .22s allow-discrete; }
details[open]::details-content { block-size: auto; }
.tree-node { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 0 14px 12px; margin: 12px 0; overflow: hidden; box-shadow: none; }
.tree-node > summary, .tree-child > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tree-node > summary { margin: 0 -14px; padding: 14px 16px; font-size: 15px; font-weight: 650; background: var(--accent-soft); border-bottom: 1px solid transparent; transition: background var(--t-fast); }
.tree-node > summary:hover { background: color-mix(in srgb, var(--accent-soft) 80%, var(--accent)); }
.tree-node[open] > summary { border-bottom-color: var(--line); }
.tree-node:not([open]), .tree-child:not([open]) { padding-bottom: 0; }
.tree-node > summary::after, .tree-child > summary::after {
  content: ""; flex: none; width: 18px; height: 18px; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .22s var(--ease);
}
.tree-node[open] > summary::after, .tree-child[open] > summary::after { transform: rotate(180deg); }
.tree-child { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 0 12px 10px; margin: 10px 0; }
.tree-child > summary { margin: 0 -12px; padding: 11px 13px; font-weight: 600; font-size: 14px; background: var(--surface-2); border-radius: var(--r-sm); }
.tree-child[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.tree-node > .system-fields { margin: 12px 0 0 4px; padding-left: 12px; border-left: 2px solid var(--line); }
.branch-toggle { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 15px; font-weight: 650; color: var(--text); cursor: pointer; }
.tree-child .branch-toggle { font-size: 14px; font-weight: 600; }
details.card { padding: 0 14px 12px; }
.engineer-list { max-height: 230px; overflow: auto; margin-top: 8px; padding: 4px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.engineer-option { display: flex; align-items: center; gap: 12px; margin: 0; padding: 10px 6px; font-size: 14px; color: var(--text); border-bottom: 1px solid var(--line); border-radius: 0; cursor: pointer; transition: background var(--t-fast); }
.engineer-option:last-child { border-bottom: 0; }
.engineer-option:hover { background: var(--accent-soft); }
.engineer-option small { display: block; color: var(--muted); }
.engineer-option.selected { background: var(--accent-soft); }
.camera-row { margin: 10px 0; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.camera-row .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
.catalog-help { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ---------- Admin ---------- */
.user-row { display: flex; align-items: center; gap: 14px; }
.user-row .avatar { width: 42px; height: 42px; }
.user-meta { min-width: 0; flex: 1; }
.user-row .actions { margin: 0; justify-content: flex-end; }
.user-meta .detail { margin-top: 2px; overflow-wrap: anywhere; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---------- Sign in ---------- */
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-art {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; padding: 44px 56px; color: #e7f1f8; overflow: hidden;
  background: radial-gradient(120% 90% at 0% 0%, #0f4a75 0%, transparent 60%), linear-gradient(160deg, #0a3558, #061f35 70%);
  border-right: 3px solid var(--orange);
}
.auth-art::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(#ffffff0b 1px, transparent 1px), linear-gradient(90deg, #ffffff0b 1px, transparent 1px); background-size: 40px 40px; -webkit-mask-image: radial-gradient(90% 80% at 80% 30%, #000, transparent); mask-image: radial-gradient(90% 80% at 80% 30%, #000, transparent); }
.auth-art > * { position: relative; }
.art-brand { display: flex; align-items: center; gap: 14px; }
.art-brand .brand-copy b { display: block; font-size: 14px; font-weight: 650; color: #fff; }
.art-brand .brand-copy span { font-size: 12px; color: #a9c4d6; }
.art-lead { max-width: 30ch; margin: 12px 0 0; font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -.025em; color: #fff; }
.art-lead + p { max-width: 46ch; margin-top: 14px; font-size: 15px; color: #b9d0df; }
.art-points { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.art-points li { display: flex; gap: 14px; align-items: flex-start; font-size: 14px; color: #b9d0df; }
.art-points li b { display: block; color: #fff; font-weight: 600; font-size: 15px; }
.art-points .pt-ico { flex: none; width: 38px; height: 38px; display: grid; place-items: center; color: var(--orange); background: #ffffff12; border: 1px solid #ffffff22; border-radius: 10px; }
.art-diagram { width: 100%; max-width: 480px; height: auto; margin-top: 4px; }
.art-diagram .node { fill: #ffffff10; stroke: #ffffff44; stroke-width: 1.2; transition: stroke .2s; }
.art-diagram .glyph { fill: none; stroke: #e7f1f8; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.art-diagram .wire { stroke: #ffffff30; stroke-width: 1.5; fill: none; }
.art-diagram .pulse { stroke: var(--orange); stroke-width: 2.4; stroke-linecap: round; fill: none; stroke-dasharray: 10 90; stroke-dashoffset: 100; animation: pulse-run 2.4s .3s var(--ease) 2 both; }
.art-diagram:hover .pulse { animation-name: pulse-run-b; }
.art-diagram:hover .node { stroke: #ffffff88; }
.art-diagram text { font: 600 11px var(--font); fill: #a9c4d6; letter-spacing: .06em; text-transform: uppercase; }
.auth-main { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 32px 24px; }
.auth-top { position: absolute; top: 20px; right: 24px; display: flex; align-items: center; gap: 12px; }
.auth-top .icon-btn { color: var(--text-2); background: var(--surface); border-color: var(--line-strong); }
.auth-top .icon-btn:hover { background: var(--sunken); border-color: var(--accent); }
.auth-brand { display: none; align-items: center; gap: 12px; width: 100%; max-width: 440px; margin-bottom: 24px; }
.auth-brand .brand-copy b { display: block; font-size: 14px; color: var(--text); }
.auth-brand .brand-copy span { font-size: 12px; color: var(--muted); }
.auth-brand .ems-logo { border: 1px solid var(--line); }
.auth-panel { width: 100%; max-width: 440px; }
.auth-panel h1 { margin: 6px 0 6px; font-size: 30px; }
.auth-panel > .sub { margin-bottom: 22px; }
.auth-panel .tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 18px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-md); }
.auth-panel .tab { flex: 1; min-height: 40px; padding: 0 12px; font: inherit; font-size: 14px; font-weight: 600; color: var(--text-2); background: none; border: 0; border-radius: var(--r-sm); cursor: pointer; transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast); }
.auth-panel .tab:hover { color: var(--text); }
.auth-panel .tab.active { color: var(--text); background: var(--surface); box-shadow: var(--sh-sm); }
.auth-panel .card { margin: 0; padding: 22px; box-shadow: var(--sh-md); border-radius: var(--r-lg); }
.auth-panel .card label:first-child { margin-top: 0; }
.auth-panel .card .btn.block { margin-top: 18px; }
.auth-panel .card .link { margin-top: 6px; }

/* ---------- Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes meter-in { from { width: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse-run { from { stroke-dashoffset: 100; } to { stroke-dashoffset: -10; } }
@keyframes pulse-run-b { from { stroke-dashoffset: 100; } to { stroke-dashoffset: -10; } }
#view.fresh { animation: view-in .2s ease-out; }
#view.fresh .meter i { animation: meter-in .7s .1s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .art-diagram .pulse { stroke-dashoffset: -10; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-brand { display: flex; }
  .auth-main { justify-content: flex-start; padding-top: 72px; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .main { padding-top: 18px; }
  .top-in { flex-direction: column; align-items: stretch; gap: 16px; padding-top: 16px; padding-bottom: 16px; }
  .brand-lockup { gap: 12px; }
  .brand-divider { display: none; }
  .ems-logo { flex-basis: 120px; width: 120px; height: 38px; }
  .department-title h1 { font-size: 19px; }
  .user-chip { justify-content: space-between; }
  .who b { max-width: 170px; }
  .top-actions .icon-btn span { display: none; }
  .top-actions .icon-btn { padding: 0; width: 40px; height: 40px; justify-content: center; }
  .top-actions .notification-button { position:relative; min-width:40px; width:40px; padding:0; font-size:0; }
  .top-actions .notification-button .notification-label { display:none; }
  .top-actions .notification-button::before { content:"🔔"; font-size:17px; line-height:1; }
  .top-actions .notification-button .notification-count { display:inline-grid; position:absolute; top:-5px; right:-5px; min-width:17px; height:17px; padding:0 3px; font-size:10px; }
  h1 { font-size: 24px; }
  .page-head h2 { font-size: 21px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .tile { padding: 16px; }
  .tile .icon { width: 52px; height: 52px; font-size: 28px; }
  .tile .tname { font-size: 15px; margin-top: 12px; }
  .tile-top .chip { display: none; }
  .tabbar .tab { padding: 14px 12px; }
  .month-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .month { padding: 10px; }
  .day-head, .day { min-height: 26px; font-size: 11px; }
  .project-list { grid-template-columns: 1fr; }
  .camera-row .grid { grid-template-columns: 1fr; }
  dialog { padding: 20px 18px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .auth-panel h1 { font-size: 26px; }
  .event-card { align-items: flex-start; }
  .attendance-summary { grid-template-columns: 1fr; }
  .attendance-summary .card b { font-size: 18px; }
  .holiday-form { grid-template-columns: 1fr; align-items: stretch; }
  .holiday-form .btn { width: 100%; }
  .attendance-days { gap: 2px; }
  .attendance-day { min-height: 50px; }
  .attendance-day small { font-size: 8px; }
  .attendance-event { align-items: flex-start; }
  .attendance-history-toolbar { flex-wrap: wrap; }
  .attendance-history-toolbar h3 { flex: 1 0 100%; order: -1; }
  .attendance-history-toolbar select { flex: 1; min-width: 0; }
  .attendance-request-admin { grid-template-columns: 1fr; }
  .attendance-request-actions { justify-content: flex-start; }
  .attendance-request-actions input { flex: 1 1 100%; }
  .admin-attendance-event { align-items: flex-start; }
  .section-tabs { width: 100%; }
  .section-tab { flex: 1; padding: 0 8px; }
}

/* ---------- Product interface refinement ---------- */
:root {
  --bg: #f1f5f8;
  --surface-2: #f7f9fb;
  --line: #d8e2e9;
  --line-strong: #bdcbd5;
  --sh-sm: 0 1px 2px #082b4909, 0 3px 10px #082b4907;
  --sh-md: 0 12px 28px #082b4910, 0 3px 8px #082b4908;
  --sh-lg: 0 26px 72px #082b4930, 0 6px 18px #082b4914;
}
:root[data-theme="dark"] {
  --bg: #091923;
  --surface: #102532;
  --surface-2: #142c3a;
  --line: #25404f;
  --line-strong: #3a5969;
  --sh-sm: 0 2px 7px #00000025;
  --sh-md: 0 12px 28px #00000032;
  --sh-lg: 0 26px 72px #00000065;
}
body { background: var(--bg); }
.wrap { max-width: 1240px; }
.main { padding-top: 30px; }
.top { border-bottom-width: 2px; }
.top::before { opacity: .55; background-size: 44px 44px; }
.top-in { min-height: 96px; }
.tabbar { background: color-mix(in srgb,var(--surface) 94%,transparent); }
.tabbar .tabs { gap: 8px; padding-top: 7px; }
.tabbar .tab { margin: 0 0 7px; padding: 11px 15px; border-radius: var(--r-sm); }
.tabbar .tab.active { color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.tabbar .tab.active svg.i { color: inherit; }
.page-head { align-items: center; margin-bottom: 22px; }
.page-head h2 { font-size: 26px; letter-spacing: -.025em; }
.page-head .sub { margin-top: 5px; max-width: 68ch; }
.card { border-color: var(--line); box-shadow: var(--sh-sm); }
.section-tabs { padding: 5px; gap: 4px; border-radius: 11px; background: color-mix(in srgb,var(--surface-2) 84%,var(--bg)); }
.section-tab { min-height: 38px; padding-inline: 16px; }
.section-tab.active { color: var(--accent); }
.supplies-panel { padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-sm); }
.supplies-panel > h3 { margin-bottom: 16px; color: var(--text-2); font-size: 14px; font-weight: 600; }
.supply-grid { gap: 16px; }
.supply-tile-wrap .tile { min-height: 214px; border-radius: 14px; }
.tile .icon { border-radius: 13px; background: var(--accent-soft); box-shadow: none; }
.tile .tname { font-size: 17px; }
.tile:hover { border-color: color-mix(in srgb,var(--accent) 48%,var(--line)); }
.attendance-summary { gap: 14px; margin: 18px 0; }
.attendance-summary .card { min-height: 76px; padding: 16px 18px; border-radius: 13px; }
.attendance-summary .card:nth-child(1) { border-left: 3px solid var(--attendance-over); }
.attendance-summary .card:nth-child(2) { border-left: 3px solid var(--attendance-under); }
.attendance-summary .card:nth-child(3) { border-left: 3px solid var(--danger); }
.attendance-summary .card:nth-child(4) { border-left: 3px solid var(--attendance-incomplete); }
.attendance-summary { grid-template-columns: repeat(4,minmax(0,1fr)); }
.attendance-summary .incomplete-value { color: var(--attendance-incomplete); }
.attendance-summary .card span { font-size: 13px; }
.attendance-summary .card b { font-size: 22px; }
.attendance-calendar { padding: 20px; border-radius: var(--r-lg); }
.calendar-toolbar { min-height: 42px; margin-bottom: 16px; }
.calendar-toolbar h3 { font-size: 18px; }
.calendar-toolbar .btn { min-width: 40px; }
.attendance-days { gap: 5px; }
.day-head { min-height: 34px; font-size: 12px; letter-spacing: .02em; }
.attendance-day { min-height: 68px; border-radius: 10px; font-size: 13px; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast), filter var(--t-fast); }
.attendance-day:hover { transform: translateY(-1px); box-shadow: 0 4px 12px #082b4914; filter: saturate(1.06); }
.attendance-day.today { box-shadow: inset 0 0 0 2px var(--orange); }
.attendance-day small { font-size: 10px; font-weight: 600; }
.calendar-legend { gap: 10px 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.legend-dot { width: 9px; height: 9px; }
.project-list { gap: 18px; }
.project-card { border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.project-card:hover { border-color: color-mix(in srgb,var(--accent) 30%,var(--line)); box-shadow: var(--sh-md); }
.project-media { height: 210px; background: var(--sunken); }
.project-body { padding: 20px 22px 22px; }
.project-body > h3 { font-size: 19px; letter-spacing: -.015em; }
.project-dates { padding: 11px 13px; border: 1px solid var(--line); background: var(--surface-2); }
.progress-summary { background: var(--surface); }
.progress-summary .progress { height: 9px; }
.progress-section { padding: 17px 18px; border-radius: 14px; }
.phase-progress { padding: 14px; border-color: color-mix(in srgb,var(--line) 84%,var(--accent)); border-radius: 10px; }
.attendance-user-folder { min-height: 80px; border-radius: 13px; transition: transform var(--t-fast) var(--ease),box-shadow var(--t-fast),border-color var(--t-fast); }
.attendance-user-folder:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--sh-md); }
.attendance-request-admin { border-radius: 13px; }
.auth-main { background: var(--bg); }
.auth-panel { max-width: 460px; }
.auth-panel h1 { letter-spacing: -.035em; }
.auth-panel .card { padding: 26px; border-color: var(--line); box-shadow: var(--sh-md); }
.auth-panel .tabs { margin-top: 24px; }
.auth-panel .card .btn.block { min-height: 48px; font-size: 15px; }
dialog { border-radius: 18px; }

@media (max-width: 760px) {
  .main { padding-top: 22px; }
  .top-in { min-height: auto; }
  .page-head { align-items: flex-start; margin-bottom: 18px; }
  .page-head h2 { font-size: 23px; }
  .supplies-panel { padding: 16px; }
  .attendance-calendar { padding: 12px; }
  .attendance-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .attendance-summary .card { align-items: flex-start; flex-direction: column; gap: 5px; }
  .attendance-days { gap: 3px; }
  .attendance-day { min-height: 54px; border-radius: 8px; }
  .calendar-legend { gap: 9px 14px; }
  .project-body { padding: 17px; }
}

/* ---------- Project progress ---------- */
.progress { height: 8px; border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--orange))); transition: width .35s var(--ease); }
.progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.progress-head b { display: inline-flex; align-items: baseline; gap: 10px; color: var(--text); font-weight: 600; }
.progress-head .pct { color: var(--accent); font-weight: 700; }
.progress-summary { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.progress-summary .progress-head { margin-bottom: 8px; }
.project-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-top: 16px; }
.project-foot .members { margin: 0; flex: 1 1 220px; }
.project-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.project-actions [data-complete-project] { padding: 8px 12px; font-size: 13px; white-space: nowrap; }
.project-delivery-action { display: flex; justify-content: flex-end; margin-top: 14px; }
.project-delivery-action .btn { padding: 8px 12px; font-size: 13px; }
.project-delivered { margin: 12px 0; }
.project-foot .btn .i { width: 16px; height: 16px; margin-left: 4px; transition: transform var(--t) var(--ease); }
.project-foot .btn:hover .i { transform: translateX(3px); }
dialog:has(.project-details) { width: min(980px, 96vw); }
.project-details h2 { margin: 0 0 4px; padding-right: 44px; font-size: 22px; }
.project-details .project-media { display: block; height: 200px; margin-top: 16px; border-radius: var(--r-md); }
.project-details .section-title { margin: 28px 0 0; font-size: 16px; }
.progress-panel { margin-top: 24px; }
.progress-head.big { align-items: flex-end; margin-bottom: 10px; }
.progress-head.big h3 { margin: 0; font-size: 18px; color: var(--text); }
.progress-head.big .pct { font-size: 28px; line-height: 1; }
.progress-section { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.progress-section h4 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; color: var(--text); }
.progress-section h4 .i { color: var(--accent); }
.progress-item { display: grid; grid-template-columns: 1fr; gap: 10px 14px; align-items: start; padding: 14px 0 4px; margin-top: 14px; border-top: 1px solid var(--line); }
.progress-item .pi-main { display: grid; gap: 6px; }
.progress-item .pi-main .sub { font-size: 13px; }
.phase-progress-list { display: grid; gap: 10px; }
.phase-progress { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.phase-progress-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 13px; color: var(--text); }
.phase-progress-head span { color: var(--muted); }
.phase-progress-entry { display: grid; grid-template-columns: 150px minmax(140px, 1fr) auto; gap: 10px; align-items: end; margin-top: 10px; }
.progress-item .pi-qty { margin: 0; font-size: 12px; color: var(--muted); }
.progress-item .pi-qty input { margin-top: 4px; padding: 9px 10px; }
.progress-item .pi-note { grid-column: 1 / 3; min-height: 0; resize: vertical; }
.phase-progress-entry .pi-note { grid-column: auto; width: 100%; }
.progress-item .pi-save { justify-self: start; align-self: center; width: auto; min-height: 34px; padding: 7px 11px; font-size: 12px; }
.phase-progress .pi-history { margin-top: 8px; font-size: 13px; }
.pi-history summary { cursor: pointer; font-weight: 600; color: var(--text-2); padding: 4px 0; }
.pi-history .timeline { margin-top: 10px; }
@media (max-width: 760px) {
  .phase-progress-entry { grid-template-columns: 1fr; }
  .phase-progress-entry .pi-save { justify-self: start; width: auto; padding: 8px 12px; }
  .project-actions { width: 100%; justify-content: stretch; }
  .project-actions .btn { width: 100%; justify-content: center; }
  .project-foot .btn { width: 100%; justify-content: center; }
  .project-details .project-media { height: 150px; }
}

/* Keep the project detail panels in the same visual system as the project cards. */
.progress-summary { background: var(--surface); border-radius: 14px; }
.progress-summary .progress { height: 9px; }
.progress-section { padding: 17px 18px; border-radius: 14px; }
.phase-progress { padding: 14px; border-color: color-mix(in srgb,var(--line) 84%,var(--accent)); border-radius: 10px; }
.project-card-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.project-card-tools .project-delete { color: var(--danger); border-color: color-mix(in srgb,var(--danger) 35%,var(--line)); box-shadow: none; }
.project-card-tools .project-delete:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
@media (max-width: 760px) {
  .phase-progress-entry { grid-template-columns: 1fr; }
  .phase-progress-entry .pi-save { justify-self: start; width: auto; padding: 8px 12px; }
  .project-actions,.project-foot .btn { width: 100%; }
  .project-actions .btn,.project-foot .btn { justify-content: center; }
  .project-details .project-media { height: 150px; }
  .project-card-tools { width: 100%; justify-content: flex-start; }
}

/* Branded first-load screen */
.boot-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; overflow: hidden; padding: 24px; color: #edf5f9; background: #071e31; opacity: 1; visibility: visible; transition: opacity 240ms ease,visibility 240ms ease; }
.boot-screen.hidden { display: none !important; }
.boot-screen-exit { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-grid { position: absolute; inset: 0; opacity: .32; background-image: linear-gradient(#ffffff09 1px,transparent 1px),linear-gradient(90deg,#ffffff09 1px,transparent 1px); background-size: 48px 48px; mask-image: radial-gradient(ellipse at center,#000 8%,transparent 76%); }
.boot-screen::before,.boot-screen::after { content: ""; position: absolute; width: min(58vw,680px); aspect-ratio: 1; border: 1px solid #ffffff0b; border-radius: 50%; pointer-events: none; }
.boot-screen::before { transform: translate(48%, -42%); }
.boot-screen::after { transform: translate(-55%, 58%) scale(.68); border-color: #f28b281a; }
.boot-panel { position: relative; display: flex; flex-direction: column; align-items: center; width: min(100%,430px); padding: 42px 40px 34px; border: 1px solid #ffffff1c; border-radius: 22px; background: linear-gradient(160deg,#10344d 0%,#0a293f 100%); box-shadow: 0 28px 80px #0005,inset 0 1px #ffffff0c; text-align: center; }
.boot-logo-frame { display: grid; place-items: center; width: 108px; height: 108px; padding: 8px; margin-bottom: 24px; overflow: hidden; border: 1px solid #ffffffa8; border-radius: 21px; background: #fff; box-shadow: 0 12px 30px #00132155; }
.boot-logo-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.boot-eyebrow { color: #79c7e7; font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.boot-panel h1 { margin: 9px 0 5px; color: #fff; font-size: clamp(23px,4vw,29px); letter-spacing: -.035em; }
.boot-panel p { color: #adc3d1; font-size: 14px; }
.boot-status { display: flex; align-items: center; gap: 10px; margin-top: 32px; color: #d5e4ec; font-size: 13px; }
.boot-signal { display: flex; align-items: center; gap: 3px; height: 14px; }
.boot-signal i { width: 4px; height: 5px; border-radius: 3px; background: #f28b28; animation: boot-signal 900ms ease-in-out infinite alternate; }
.boot-signal i:nth-child(2) { animation-delay: 180ms; }
.boot-signal i:nth-child(3) { animation-delay: 360ms; }
.boot-progress { width: min(100%,270px); height: 3px; margin-top: 15px; overflow: hidden; border-radius: 99px; background: #ffffff1a; }
.boot-progress i { display: block; width: 36%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#34aadb,#f28b28); animation: boot-progress 1.5s ease-in-out infinite; }
@keyframes boot-signal { to { height: 13px; } }
@keyframes boot-progress { from { transform: translateX(-110%); } to { transform: translateX(300%); } }
@media (max-width: 520px) {
  .boot-screen { padding: 18px; }
  .boot-panel { padding: 34px 24px 28px; border-radius: 18px; }
  .boot-logo-frame { width: 94px; height: 94px; margin-bottom: 20px; }
  .boot-status { margin-top: 27px; }
}
@media (prefers-reduced-motion: reduce) {
  .boot-signal i { animation: none; height: 7px; }
  .boot-progress i { animation: none; transform: translateX(80%); }
}


/* ---------- Fixes: phone user cards, profile page ---------- */
.notification-count.hidden { display: none !important; }
@media (max-width: 760px) {
  .user-row { flex-wrap: wrap; align-items: flex-start; }
  .user-meta { flex: 1 1 calc(100% - 60px); min-width: 0; }
  .user-row .actions { flex: 1 1 100%; justify-content: flex-start; gap: 8px; }
  .user-row .actions .btn { flex: 1 1 auto; justify-content: center; }
}
.profile-card { display: grid; gap: 20px; max-width: 760px; }
.profile-photo { display: flex; align-items: center; gap: 18px; }
.profile-photo img, .profile-photo #profileInitials { width: 96px; height: 96px; border-radius: 50%; flex: none; }
.profile-photo img { object-fit: cover; border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--accent), var(--sh-sm); }
.profile-photo #profileInitials { display: grid; place-items: center; font-size: 30px; font-weight: 700; letter-spacing: .02em; color: #fff; background: linear-gradient(135deg, var(--navy), var(--accent)); box-shadow: 0 0 0 2px var(--accent); }
.profile-photo [hidden] { display: none !important; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid label { display: grid; gap: 6px; margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.form-grid label input, .form-grid label textarea { margin: 0; font-weight: 400; color: var(--text); }
.form-grid .wide { grid-column: 1 / -1; }
.profile-role { justify-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; color: var(--in); background: var(--in-bg); }
.profile-role::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.profile-card fieldset { margin: 0; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.profile-card legend { padding: 0 8px; font-size: 13px; font-weight: 700; color: var(--text); }
.profile-card fieldset label { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 14px; color: var(--text); }
.profile-card fieldset input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.profile-card fieldset .sub { margin: 8px 0 2px; font-size: 12.5px; }
.profile-card > .btn.primary { justify-self: start; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } .profile-photo { flex-direction: column; align-items: flex-start; } .profile-card > .btn.primary { justify-self: stretch; } }

/* Live updates: shown when someone else changed what you're looking at while you were typing */
.live-bar { display: flex; align-items: center; gap: 10px; background: var(--in-bg); color: var(--in); border: 1px solid var(--line); border-radius: var(--r-md); padding: 9px 12px; margin: 0 0 12px; font-size: 14px; }
.live-bar span { flex: 1; min-width: 0; }
.live-bar .btn { flex: none; padding: 6px 12px; }
.live-bar .i { flex: none; }
