:root {
  color-scheme: dark;
  --bg: #071426;
  --panel: #0e2139;
  --panel-2: #142b48;
  --line: #244261;
  --text: #f7fbff;
  --muted: #9db1c8;
  --red: #ef252b;
  --red-dark: #c8171d;
  --blue: #448cff;
  --green: #32c178;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, rgba(68, 140, 255, .2), transparent 35%),
    radial-gradient(circle at 90% 90%, rgba(239, 37, 43, .16), transparent 34%),
    var(--bg);
}

.login-card {
  width: min(100%, 440px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(14, 33, 57, .96);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .38);
}

.brand, .topbar-brand { display: flex; align-items: center; gap: 14px; }
.brand img, .topbar-brand img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
}
.brand h1 { margin: 2px 0 4px; font-size: 1.55rem; }
.brand p { margin: 0; color: var(--muted); }
.eyebrow { margin: 0; color: #78a8ff !important; font-size: .72rem; font-weight: 800; letter-spacing: .13em; }

.login-form { display: grid; gap: 17px; margin-top: 28px; }
label { display: grid; gap: 8px; color: #dbe8f6; font-weight: 700; font-size: .9rem; }
input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #365573;
  border-radius: 12px;
  outline: 0;
  background: #081a2e;
  color: var(--text);
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(68, 140, 255, .16); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 70px; }
.text-button {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #8fb6ed;
  font-weight: 700;
}

.primary-button, .secondary-button, .icon-button, .module-tab {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 800;
}
.primary-button { border: 0; background: var(--red); color: #fff; }
.primary-button:hover { background: var(--red-dark); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button, .icon-button {
  padding: 0 15px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}
.form-error {
  margin: 0;
  padding: 11px 13px;
  border: 1px solid rgba(239, 37, 43, .5);
  border-radius: 10px;
  background: rgba(239, 37, 43, .12);
  color: #ffc4c6;
}
.login-footer { margin-top: 22px; color: var(--muted); font-size: .82rem; text-align: center; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--green); }

.app-shell { min-height: 100dvh; padding-bottom: 58px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  padding: 10px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 20, 38, .94);
  backdrop-filter: blur(14px);
}
.topbar-brand img { width: 42px; height: 42px; border-radius: 9px; }
.topbar-brand strong, .topbar-brand small { display: block; }
.topbar-brand small { margin-top: 2px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.content { width: min(1100px, 100%); margin: 0 auto; padding: 22px 18px 34px; }
.welcome-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
}
.welcome-card h1 { margin: 5px 0; font-size: clamp(1.35rem, 4vw, 2rem); }
.welcome-card p { margin: 0; color: var(--muted); }

.module-tabs { display: flex; gap: 9px; margin: 18px 0; overflow-x: auto; scrollbar-width: none; }
.module-tabs::-webkit-scrollbar { display: none; }
.module-tab {
  flex: 0 0 auto;
  padding: 0 17px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
}
.module-tab.active { border-color: var(--red); background: var(--red); color: #fff; }

.section-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 22px 0 12px; }
.section-title h2 { margin: 0; font-size: 1.18rem; }
.section-title span { color: var(--muted); font-size: .82rem; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric-card, .project-card, .empty-card {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.metric-card small, .project-card small { color: var(--muted); }
.metric-card strong { display: block; margin-top: 8px; font-size: 1.55rem; overflow-wrap: anywhere; }
.metric-card:nth-child(4n+1) { border-top: 3px solid #815aff; }
.metric-card:nth-child(4n+2) { border-top: 3px solid var(--blue); }
.metric-card:nth-child(4n+3) { border-top: 3px solid #f3a522; }
.metric-card:nth-child(4n) { border-top: 3px solid var(--green); }
.project-list { display: grid; gap: 11px; }
.notification-list { display: grid; gap: 10px; }
.record-list { display: grid; gap: 11px; }
.project-card { display: grid; grid-template-columns: 1fr auto; gap: 13px; align-items: center; }
.project-card h3 { margin: 0 0 5px; font-size: 1rem; overflow-wrap: anywhere; }
.project-card p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; }
.project-progress { min-width: 68px; text-align: right; color: #8db7ff; font-weight: 800; }
.notification-card {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
}
.notification-card.unread { background: #122945; }
.notification-mark { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: #5c7086; }
.notification-card.unread .notification-mark { background: var(--red); box-shadow: 0 0 0 4px rgba(239, 37, 43, .12); }
.notification-card h3 { margin: 0; font-size: .98rem; }
.notification-card p { margin: 5px 0; color: #ccdaea; font-size: .9rem; line-height: 1.45; }
.notification-card small { color: var(--muted); }
.record-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
}
.record-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.record-card h3 { margin: 3px 0 0; font-size: 1rem; }
.record-card small { color: var(--muted); }
.record-card p { margin: 10px 0; color: #c8d7e8; font-size: .9rem; line-height: 1.45; }
.record-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.record-card dl div { padding: 9px; border-radius: 10px; background: #091b30; }
.record-card dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.record-card dd { margin: 4px 0 0; font-weight: 800; overflow-wrap: anywhere; }
.status-pill {
  flex: 0 0 auto;
  max-width: 130px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(68, 140, 255, .14);
  color: #91b9ff;
  font-size: .72rem;
  font-weight: 800;
  text-align: center;
}
.empty-card { color: var(--muted); text-align: center; }
.interactive-card { cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
.interactive-card:hover, .interactive-card:focus-visible {
  border-color: #3d6ea0;
  outline: none;
  transform: translateY(-1px);
}
.cache-notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(243, 165, 34, .45);
  border-radius: 10px;
  background: rgba(243, 165, 34, .12);
  color: #ffd9a0;
  font-size: .86rem;
}
.connectivity-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 16px;
  background: #1d3f66;
  color: #e7f1ff;
  font-size: .84rem;
  font-weight: 700;
  text-align: center;
}
.connectivity-banner.is-offline { background: #6b2b12; color: #ffe5d8; }
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(4, 12, 22, .55);
  backdrop-filter: blur(4px);
}
.loading-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: min(280px, calc(100vw - 32px));
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.loading-card p { margin: 0; color: var(--muted); font-weight: 700; }
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #2a4664;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}
.detail-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Shared mobile/sub-dashboard shell (module toolbar, sub-tabs, filters,
   compact record cards) — standardized across Timesheet, DPR and future
   ERP sub-dashboards (Mobile ERP Dashboard/Timesheet/DPR correction task). */
.module-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0 4px;
}
.module-toolbar-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.module-toolbar-nav { display: flex; gap: 6px; width: 100%; }
.module-toolbar-title h2 { margin: 0; font-size: 1.18rem; }
.module-toolbar-title span { color: var(--muted); font-size: .82rem; }
.module-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.compact-card.unread { border-color: rgba(68, 140, 255, .45); }

.sub-tabs { display: flex; gap: 6px; margin: 12px 0; overflow-x: auto; scrollbar-width: none; }
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tab {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: .86rem;
}
.sub-tab.active { border-color: var(--blue); background: rgba(68, 140, 255, .14); color: #cfe0ff; }

.search-filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 16px; }
.search-field { position: relative; flex: 1 1 220px; min-width: 0; }
.search-field input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px 0 36px;
  border: 1px solid #365573;
  border-radius: 12px;
  background: #081a2e;
  color: var(--text);
}
.search-field::before {
  content: "⌕";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 800;
}
.filter-field { flex: 0 1 160px; min-width: 130px; }
.filter-field select, .filter-field input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #365573;
  border-radius: 12px;
  background: #081a2e;
  color: var(--text);
}
.filter-clear-button { flex: 0 0 auto; }

.record-count-chip {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.compact-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.compact-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.compact-card-title { min-width: 0; }
.compact-card-title h3 {
  margin: 2px 0 0;
  font-size: .98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compact-card-title small { color: var(--muted); }
.compact-card-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 0; }
.compact-card-meta div { min-width: 0; padding: 8px; border-radius: 9px; background: #091b30; }
.compact-card-meta dt { color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; }
.compact-card-meta dd { margin: 3px 0 0; font-weight: 800; font-size: .86rem; overflow-wrap: anywhere; }
.compact-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.compact-card-actions .secondary-button, .compact-card-actions .text-chip-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: .82rem;
}
.text-chip-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
}

.status-pill.status-approved, .status-pill.status-completed { background: rgba(50, 193, 120, .16); color: #7fe6ac; }
.status-pill.status-pending { background: rgba(243, 165, 34, .16); color: #ffcf7d; }
.status-pill.status-rejected, .status-pill.status-returned { background: rgba(239, 37, 43, .16); color: #ffb0b2; }
.status-pill.status-draft { background: rgba(157, 177, 200, .16); color: #cbd8e6; }

.skeleton-card {
  height: 92px;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 37%, var(--panel) 63%);
  background-size: 400% 100%;
  animation: skeleton-shine 1.4s ease infinite;
}
@keyframes skeleton-shine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.error-card {
  padding: 14px;
  border: 1px solid rgba(239, 37, 43, .4);
  border-radius: 14px;
  background: rgba(239, 37, 43, .08);
  color: #ffc4c6;
}
.detail-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.detail-summary {
  margin: 0 0 14px;
  color: #c8d7e8;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}
.detail-grid div {
  min-width: 0;
  padding: 10px;
  border-radius: 10px;
  background: #091b30;
}
.detail-grid dt {
  color: var(--muted);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.detail-grid dd {
  margin: 4px 0 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.module-view, .content, .form-panel, .record-list, .compact-card { min-width: 0; max-width: 100%; }
.form-panel {
  display: grid;
  gap: 12px;
  width: 100%;
  margin: 12px 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0b1d33;
  overflow-x: clip;
}
.form-title { font-weight: 800; color: #dbe8f6; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-panel label {
  display: grid;
  gap: 6px;
  color: #cfe0f2;
  font-size: .86rem;
  font-weight: 700;
  min-width: 0;
  max-width: 100%;
}
.form-panel input, .form-panel select, .form-panel textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #365573;
  border-radius: 10px;
  background: #081a2e;
  color: var(--text);
}
/* Long BOQ option labels must not expand the native select past the card. */
.form-panel select {
  text-overflow: ellipsis;
  white-space: nowrap;
}
.checkbox-row { display: flex !important; flex-direction: row; align-items: center; gap: 8px; }
.checkbox-row input { min-height: auto; width: auto; }
.form-panel fieldset {
  display: grid;
  gap: 8px;
  border: 1px solid #365573;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0;
}
.form-panel fieldset legend { padding: 0 6px; color: #cfe0f2; font-size: .82rem; font-weight: 700; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.danger-button {
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid rgba(239, 37, 43, .5);
  border-radius: 12px;
  background: rgba(239, 37, 43, .12);
  color: #ffc4c6;
  font-weight: 800;
}
.mobile-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(18px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: #061120;
  color: var(--muted);
  font-size: .75rem;
}

@media (min-width: 760px) {
  .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .project-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 440px) {
  .login-screen { padding: 14px; }
  .login-card { padding: 23px 19px; }
  .brand { align-items: flex-start; }
  .brand img { width: 46px; height: 46px; }
  .brand h1 { font-size: 1.3rem; overflow-wrap: anywhere; }
  .content { padding: 16px 12px 34px; }
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .topbar-brand strong { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .welcome-card { align-items: flex-start; flex-wrap: wrap; padding: 16px; }
  .welcome-card h1 { overflow-wrap: anywhere; }
  .welcome-card .secondary-button { min-width: 46px; padding: 0 10px; font-size: 0; }
  .welcome-card .secondary-button::after { content: "↻"; font-size: 1.25rem; }
  .card-grid, .record-card dl, .detail-grid, .form-row { grid-template-columns: 1fr; }
  .project-card { grid-template-columns: 1fr; }
  .project-progress { text-align: left; }
  .status-pill { max-width: 100%; }
  .record-card-head { flex-wrap: wrap; }
  .module-tab { padding: 0 14px; }
  .module-toolbar { flex-direction: column; align-items: flex-start; }
  .module-toolbar-actions { width: 100%; }
  .module-toolbar-actions .secondary-button { flex: 1 1 auto; }
  .filter-field { flex: 1 1 100%; }
  .compact-card-title h3 { white-space: normal; overflow-wrap: anywhere; }
}

@media (max-width: 360px) {
  .login-card { padding: 18px 14px; }
  .brand h1 { font-size: 1.18rem; }
  .icon-button { padding: 0 10px; font-size: .85rem; }
  .section-title { align-items: flex-start; flex-direction: column; }
}
