:root {
  --navy-950: #062653;
  --navy-900: #0a356f;
  --navy-800: #124b8c;
  --navy-700: #1a5fa8;
  --teal-700: #117c83;
  --teal-600: #18959b;
  --teal-100: #e4f7f7;
  --gold-700: #b77b00;
  --gold-500: #e4a500;
  --gold-100: #fff5d6;
  --purple-700: #50419d;
  --purple-100: #efecff;
  --red-700: #b43131;
  --red-100: #fde8e8;
  --green-700: #237044;
  --green-100: #e4f5ea;
  --ink-900: #17263e;
  --ink-700: #334861;
  --ink-500: #67778c;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --background: #edf3f8;
  --border: #c7d5e4;
  --shadow: 0 8px 24px rgba(4, 42, 88, 0.09);
  --radius: 12px;
  --topbar-height: 66px;
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink-900);
  background: var(--background);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 15% 20%, rgba(31, 146, 157, 0.16), transparent 32%),
    linear-gradient(135deg, #f7fbff, #eaf1f7);
}

.boot-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: 280px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.boot-card img {
  width: 82px;
  height: 82px;
  object-fit: contain;
  border-radius: 50%;
}

.boot-card small {
  color: var(--ink-500);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 4px solid #d9e4ee;
  border-top-color: var(--navy-700);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-height);
  padding: 8px 18px;
  color: #fff;
  background: linear-gradient(90deg, var(--navy-950), var(--navy-800));
  box-shadow: 0 4px 16px rgba(1, 28, 60, 0.2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand img {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  object-fit: contain;
  border: 2px solid var(--gold-500);
  border-radius: 50%;
  background: #fff;
}

.brand span {
  display: grid;
  min-width: 0;
}

.brand strong {
  font-size: 1.08rem;
  line-height: 1.15;
}

.brand small {
  overflow: hidden;
  color: #d8e7f7;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.13);
}

.menu-toggle {
  display: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  color: #e9f7ff;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.72rem;
  font-weight: 800;
}

.connection-badge i {
  color: #f1b91b;
  font-size: 0.55rem;
}

.connection-badge.connected i {
  color: #68da8f;
}

.user-dropdown {
  position: relative;
}

.user-dropdown > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}

.user-dropdown > summary::-webkit-details-marker,
.nav-group > summary::-webkit-details-marker {
  display: none;
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 1200;
  width: 280px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--ink-900);
  background: var(--surface);
  box-shadow: 0 14px 32px rgba(1, 28, 60, 0.22);
}

.user-panel > strong,
.user-panel > small {
  display: block;
}

.user-panel > small {
  margin-top: 2px;
  color: var(--ink-500);
}

.user-meta {
  display: grid;
  gap: 5px;
  margin-top: 11px;
  color: var(--ink-700);
  font-size: 0.8rem;
}

.role-badge,
.status-badge,
.source-badge,
.rate-pill {
  display: inline-flex;
  width: max-content;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
}

.role-badge {
  color: var(--navy-800);
  background: #e5f0fc;
}

.user-panel hr {
  margin: 13px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.dropdown-action {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.dropdown-action:hover {
  background: var(--surface-2);
}

.dropdown-action.danger {
  color: var(--red-700);
}

.sidebar {
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  z-index: 900;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 14px 12px;
  overflow-y: auto;
  border-right: 1px solid #b9c9d9;
  background: #f8fbfe;
}

.sidebar nav {
  display: grid;
  gap: 4px;
}

.nav-link,
.nav-group > summary,
.nav-submenu a {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  color: var(--ink-700);
  font-weight: 750;
  cursor: pointer;
}

.nav-link {
  padding: 11px 12px;
}

.nav-link i,
.nav-group > summary i:first-child {
  width: 20px;
  color: var(--navy-700);
  text-align: center;
}

.nav-link:hover,
.nav-link.active,
.nav-submenu a:hover,
.nav-submenu a.active {
  color: var(--navy-900);
  background: #e3effb;
}

.nav-link.active {
  box-shadow: inset 4px 0 0 var(--gold-500);
}

.nav-group {
  border-radius: 8px;
}

.nav-group > summary {
  justify-content: space-between;
  padding: 11px 12px;
  list-style: none;
}

.nav-group > summary span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-group[open] > summary {
  color: var(--navy-900);
  background: #eef5fc;
}

.nav-group > summary > i {
  transition: transform 0.2s ease;
}

.nav-group[open] > summary > i {
  transform: rotate(180deg);
}

.nav-submenu {
  display: grid;
  gap: 3px;
  padding: 3px 0 8px 39px;
}

.nav-submenu a {
  padding: 8px 10px;
  font-size: 0.82rem;
}

.sidebar-footer {
  display: grid;
  gap: 3px;
  margin-top: auto;
  padding: 14px 10px 5px;
  color: var(--ink-500);
}

.sidebar-footer strong {
  color: var(--navy-800);
  font-size: 0.72rem;
}

.sidebar-backdrop {
  position: fixed;
  inset: var(--topbar-height) 0 0 0;
  z-index: 850;
  background: rgba(4, 28, 54, 0.42);
}

.main-content {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: calc(var(--topbar-height) + 18px) 18px 30px;
}

.page-view {
  width: min(100%, 1780px);
  margin: 0 auto;
}

.announcement {
  width: min(100%, 1780px);
  margin: 0 auto 14px;
  padding: 12px 15px;
  border: 1px solid #e5c869;
  border-left: 5px solid var(--gold-500);
  border-radius: 9px;
  color: #624600;
  background: var(--gold-100);
}

.page-loading,
.page-error {
  display: grid;
  min-height: 340px;
  place-items: center;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.page-loading > div,
.page-error > div {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: 680px;
}

.page-error i {
  color: var(--red-700);
  font-size: 2rem;
}

.hero-panel {
  position: relative;
  display: flex;
  min-height: 150px;
  align-items: center;
  gap: 20px;
  overflow: hidden;
  padding: 22px 28px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(106deg, var(--navy-950) 0 72%, var(--gold-500) 72% 75%, var(--teal-600) 75% 79%, var(--navy-950) 79% 100%);
  box-shadow: var(--shadow);
}

.hero-logo {
  display: grid;
  width: 76px;
  height: 76px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  padding: 4px;
  border: 2px solid var(--gold-500);
  border-radius: 50%;
  background: #fff;
}

.hero-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.eyebrow {
  margin: 0;
  color: var(--gold-500);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-panel h1 {
  margin: 5px 0 0;
  font-size: clamp(2rem, 3.5vw, 3.3rem);
  line-height: 1;
  letter-spacing: 0.01em;
}

.hero-panel p:last-child {
  margin: 9px 0 0;
  color: #ffd54e;
  font-size: 1rem;
  font-style: italic;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(4, 42, 88, 0.04);
}

.toolbar .grow {
  flex: 1;
}

.button,
.primary-button,
.secondary-button,
.danger-button,
.icon-action,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
}

.button,
.secondary-button,
.danger-button,
.primary-button {
  min-height: 38px;
  padding: 8px 12px;
}

.button,
.secondary-button {
  border: 1px solid #9eb2c8;
  color: var(--navy-900);
  background: #fff;
}

.button:hover,
.secondary-button:hover {
  background: #edf5fd;
}

.primary-button {
  border: 1px solid var(--navy-700);
  color: #fff;
  background: linear-gradient(90deg, var(--navy-800), var(--teal-600));
}

.primary-button:hover {
  filter: brightness(1.06);
}

.danger-button {
  border: 1px solid var(--red-700);
  color: #fff;
  background: var(--red-700);
}

.button:disabled,
.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.full {
  width: 100%;
}

.link-button {
  padding: 0;
  border: 0;
  color: var(--navy-700);
  background: transparent;
}

.input,
.select,
.textarea,
.stack-form input,
.grid-form input,
.grid-form select,
.grid-form textarea,
.table-filter {
  width: 100%;
  border: 1px solid #b7c7d8;
  border-radius: 7px;
  color: var(--ink-900);
  background: #fff;
  outline: none;
}

.input,
.select,
.stack-form input,
.grid-form input,
.grid-form select,
.table-filter {
  min-height: 40px;
  padding: 8px 10px;
}

.textarea,
.grid-form textarea {
  min-height: 88px;
  padding: 9px 10px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus,
.stack-form input:focus,
.grid-form input:focus,
.grid-form select:focus,
.grid-form textarea:focus,
.table-filter:focus {
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(26, 95, 168, 0.13);
}

.search-field {
  position: relative;
  min-width: min(100%, 320px);
  flex: 1;
}

.search-field i {
  position: absolute;
  top: 50%;
  left: 11px;
  color: var(--ink-500);
  transform: translateY(-50%);
}

.search-field input {
  padding-left: 34px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  margin-top: 14px;
}

.kpi-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
  display: flex;
  min-height: 96px;
  align-items: center;
  gap: 13px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 4px 13px rgba(4, 42, 88, 0.05);
}

.kpi-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 1.22rem;
}

.kpi-icon.blue { background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); }
.kpi-icon.teal { background: linear-gradient(135deg, var(--teal-700), #26adb2); }
.kpi-icon.gold { background: linear-gradient(135deg, var(--gold-700), var(--gold-500)); }
.kpi-icon.purple { background: linear-gradient(135deg, #413387, #6758bd); }
.kpi-icon.red { background: linear-gradient(135deg, #a82e2e, #e05b5b); }
.kpi-icon.green { background: linear-gradient(135deg, #1d633b, #4a9e65); }

.kpi-card small {
  display: block;
  color: var(--ink-500);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.035em;
}

.kpi-card strong {
  display: block;
  margin-top: 4px;
  color: var(--navy-900);
  font-size: clamp(1.05rem, 1.7vw, 1.45rem);
  line-height: 1.1;
}

.card,
.content-card {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(4, 42, 88, 0.05);
}

.card-header {
  display: flex;
  min-height: 45px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  color: #fff;
  background: linear-gradient(90deg, var(--navy-900), var(--navy-800));
  font-weight: 950;
}

.card-header.teal {
  background: linear-gradient(90deg, var(--teal-700), var(--teal-600));
}

.card-header.gold {
  color: #fff;
  background: linear-gradient(90deg, #9e6c00, var(--gold-500));
}

.card-body {
  padding: 14px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.chart-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chart-box {
  position: relative;
  height: 300px;
  padding: 12px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 11px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.table-toolbar .record-count {
  margin-left: auto;
  color: var(--ink-500);
  font-size: 0.78rem;
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.data-table {
  min-width: 1160px;
  font-size: 0.76rem;
}

.data-table.wide {
  min-width: 1680px;
}

.data-table.extra-wide {
  min-width: 2100px;
}

th,
td {
  padding: 9px 8px;
  border: 1px solid #d2dde9;
  vertical-align: middle;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #fff;
  background: #7d97ba;
  font-size: 0.68rem;
  text-align: center;
  text-transform: uppercase;
}

thead th.sortable {
  cursor: pointer;
}

thead th.sortable:hover {
  background: #6d89b0;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

tbody tr:hover {
  background: #eef5fb;
}

tfoot th,
.total-row th,
.total-row td {
  color: var(--navy-900);
  background: #dce6f2;
  font-weight: 950;
}

.grand-total th,
.grand-total td {
  border-top: 2px solid var(--ink-700);
}

.text-end {
  text-align: right;
  white-space: nowrap;
}

.text-center {
  text-align: center;
}

.wrap-cell {
  min-width: 210px;
  white-space: normal;
}

.empty-state {
  padding: 28px;
  color: var(--ink-500);
  text-align: center;
}

.rate-pill {
  color: #0753a0;
  background: #e7f1fd;
}

.rate-pill.gold {
  color: #8b5d00;
  background: var(--gold-100);
}

.source-badge.current {
  color: var(--navy-800);
  background: #e5f0fc;
}

.source-badge.continuing {
  color: var(--teal-700);
  background: var(--teal-100);
}

.status-badge.on-track,
.status-badge.completed,
.status-badge.active {
  color: var(--green-700);
  background: var(--green-100);
}

.status-badge.at-risk,
.status-badge.planned,
.status-badge.for-implementation {
  color: #8a5b00;
  background: var(--gold-100);
}

.status-badge.delayed,
.status-badge.inactive,
.status-badge.deleted,
.status-badge.cancelled {
  color: var(--red-700);
  background: var(--red-100);
}

.status-badge.in-progress {
  color: var(--purple-700);
  background: var(--purple-100);
}

.action-group {
  display: inline-flex;
  gap: 5px;
}

.icon-action {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #9eb2c8;
  color: var(--navy-800);
  background: #fff;
}

.icon-action:hover {
  background: #e8f2fc;
}

.icon-action.danger {
  border-color: #e0a6a6;
  color: var(--red-700);
}

.owner-cell {
  display: grid;
  min-width: 140px;
  gap: 2px;
}

.owner-cell small {
  color: var(--ink-500);
}

.access-notice,
.info-notice,
.warning-notice,
.error-notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: 10px;
  background: #fff;
}

.access-notice i,
.info-notice i,
.warning-notice i,
.error-notice i {
  margin-top: 2px;
  font-size: 1.05rem;
}

.access-notice.encoder,
.info-notice {
  border-left-color: var(--teal-600);
  background: #f0ffff;
}

.access-notice.admin {
  border-left-color: var(--navy-700);
  background: #f1f7ff;
}

.access-notice.viewer {
  border-left-color: #7e8c9e;
  background: #f8fafc;
}

.warning-notice {
  border-left-color: var(--gold-500);
  color: #674900;
  background: var(--gold-100);
}

.error-notice {
  border-left-color: var(--red-700);
  color: #7e2727;
  background: #fff3f3;
}

.access-notice strong,
.access-notice span,
.access-notice small {
  display: block;
}

.access-notice span {
  margin-top: 2px;
  color: var(--ink-700);
  font-size: 0.82rem;
  font-weight: 800;
}

.access-notice small {
  margin-top: 3px;
  color: var(--ink-500);
}

.app-dialog {
  width: min(96vw, 1060px);
  max-height: 92vh;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(1, 28, 60, 0.35);
}

.app-dialog::backdrop {
  background: rgba(1, 22, 46, 0.6);
  backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 17px;
  color: #fff;
  background: linear-gradient(90deg, var(--navy-900), var(--teal-600));
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.dialog-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.dialog-body {
  max-height: calc(92vh - 130px);
  padding: 17px;
  overflow-y: auto;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 17px;
  border-top: 1px solid var(--border);
  background: #f7f9fc;
}

.confirm-dialog {
  width: min(92vw, 460px);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.grid-form label,
.stack-form label {
  display: grid;
  gap: 6px;
  color: var(--ink-700);
  font-size: 0.82rem;
  font-weight: 800;
}

.grid-form .span-2 {
  grid-column: span 2;
}

.form-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 18px;
  margin-top: 14px;
  padding: 13px;
  border: 1px dashed #9bb5ce;
  border-radius: 9px;
  background: #f3f8fd;
}

.form-preview > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.form-preview strong {
  color: var(--navy-900);
}

.form-message {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.form-message.error {
  color: var(--red-700);
  background: var(--red-100);
}

.form-message.success {
  color: var(--green-700);
  background: var(--green-100);
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2000;
  display: grid;
  gap: 8px;
  width: min(92vw, 390px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--green-700);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(1, 28, 60, 0.2);
  animation: toast-in 0.2s ease-out;
}

.toast.error {
  border-left-color: var(--red-700);
}

.toast.warning {
  border-left-color: var(--gold-500);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 9px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.tab-button {
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink-700);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.tab-button.active {
  border-color: #aac0d7;
  color: var(--navy-900);
  background: #fff;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.audit-detail {
  max-width: 480px;
  white-space: normal;
}

.auth-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 18%, rgba(23, 145, 154, 0.16), transparent 32%),
    radial-gradient(circle at 88% 82%, rgba(224, 162, 0, 0.13), transparent 34%),
    linear-gradient(135deg, #eaf2f8, #f8fbfd);
}

.auth-layout {
  display: grid;
  width: min(1120px, calc(100% - 30px));
  min-height: 660px;
  grid-template-columns: 0.95fr 1.05fr;
  margin: 36px auto;
  overflow: hidden;
  border: 1px solid #b9cadd;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(3, 39, 82, 0.18);
}

.auth-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 62px);
  color: #fff;
  background:
    linear-gradient(145deg, rgba(5, 39, 82, 0.96), rgba(17, 85, 143, 0.94)),
    #0b3b77;
}

.auth-logo {
  width: 100px;
  height: 100px;
  object-fit: contain;
  padding: 5px;
  border: 3px solid var(--gold-500);
  border-radius: 50%;
  background: #fff;
}

.auth-brand-panel h1 {
  margin: 10px 0;
  font-size: clamp(2.2rem, 4vw, 3.8rem);
  line-height: 1;
}

.auth-brand-panel > p:last-of-type {
  max-width: 560px;
  color: #d8e7f7;
  line-height: 1.65;
}

.auth-feature-list {
  display: grid;
  gap: 11px;
  margin-top: 22px;
}

.auth-feature-list span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-feature-list i {
  color: var(--gold-500);
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: clamp(28px, 5vw, 58px);
}

.auth-card.wide {
  justify-content: flex-start;
  overflow-y: auto;
}

.auth-card h2 {
  margin: 5px 0;
  color: var(--navy-900);
  font-size: clamp(1.65rem, 3vw, 2.4rem);
}

.muted {
  color: var(--ink-500);
}

.stack-form {
  display: grid;
  gap: 14px;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 45px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 5px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 7px;
  color: var(--ink-500);
  background: transparent;
  transform: translateY(-50%);
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--surface-2);
}

.auth-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--navy-700);
  font-size: 0.84rem;
  font-weight: 750;
}

.checkbox-label {
  display: flex !important;
  grid-template-columns: auto 1fr !important;
  align-items: flex-start;
  gap: 9px !important;
  font-weight: 600 !important;
  line-height: 1.45;
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
  margin-top: 1px;
}

.build-label {
  color: var(--ink-500);
  text-align: center;
}

.progress-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf4;
}

.progress-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--navy-700), var(--teal-600));
}

.split-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 14px;
}

.summary-list {
  display: grid;
  gap: 9px;
}

.summary-list article {
  display: grid;
  gap: 4px;
  padding: 11px 0;
  border-bottom: 1px solid #dde5ee;
}

.summary-list article:last-child {
  border-bottom: 0;
}

.summary-list small {
  color: var(--ink-500);
}

@media (max-width: 1280px) {
  .kpi-grid.four,
  .chart-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .menu-toggle {
    display: inline-grid;
  }

  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 10px 0 30px rgba(2, 28, 58, 0.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .connection-badge {
    display: none;
  }

  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-brand-panel {
    min-height: 340px;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 60px;
  }

  .topbar {
    padding: 7px 10px;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .brand small {
    display: none;
  }

  .user-dropdown > summary span,
  .connection-badge {
    display: none;
  }

  .main-content {
    padding: calc(var(--topbar-height) + 12px) 10px 22px;
  }

  .hero-panel {
    min-height: 130px;
    padding: 18px;
    background: linear-gradient(110deg, var(--navy-950) 0 82%, var(--gold-500) 82% 86%, var(--teal-600) 86% 90%, var(--navy-950) 90%);
  }

  .hero-logo {
    width: 60px;
    height: 60px;
  }

  .hero-panel h1 {
    font-size: clamp(1.55rem, 7vw, 2.2rem);
  }

  .hero-panel p:last-child {
    font-size: 0.84rem;
  }

  .kpi-grid,
  .kpi-grid.four,
  .chart-grid,
  .chart-grid.three,
  .grid-form,
  .form-preview {
    grid-template-columns: 1fr;
  }

  .grid-form .span-2 {
    grid-column: span 1;
  }

  .table-toolbar .record-count {
    width: 100%;
    margin-left: 0;
  }

  .auth-layout {
    width: min(100% - 18px, 720px);
    margin: 9px auto;
    border-radius: 14px;
  }

  .auth-brand-panel {
    min-height: 270px;
    padding: 26px;
  }

  .auth-card {
    padding: 26px 20px;
  }
}

@media print {
  .topbar,
  .sidebar,
  .sidebar-backdrop,
  .toolbar,
  .table-toolbar,
  .announcement,
  .access-notice,
  .no-print,
  .toast-host {
    display: none !important;
  }

  .main-content {
    margin: 0;
    padding: 0;
  }

  .page-view {
    width: 100%;
  }

  .card,
  .content-card,
  .hero-panel,
  .kpi-card {
    box-shadow: none;
    break-inside: avoid;
  }

  thead th {
    position: static;
  }
}


/* Procurement Tracking */
.procurement-card .table-toolbar {
  align-items: stretch;
}
.procurement-toolbar .compact-select {
  width: auto;
  min-width: 170px;
}
.procurement-table {
  min-width: 2700px;
}
.procurement-table thead tr:first-child th {
  border-bottom-color: rgba(255,255,255,.6);
}
.procurement-table .procurement-date-group {
  color: var(--navy-950);
  background: #dce7f3;
  font-style: italic;
  letter-spacing: .02em;
}
.procurement-form-grid .form-section-label {
  margin-top: 4px;
  padding: 9px 11px;
  border-left: 4px solid var(--navy-700);
  border-radius: 6px;
  color: var(--navy-900);
  background: #edf5fd;
  font-size: .78rem;
  font-weight: 950;
  letter-spacing: .035em;
  text-transform: uppercase;
}
@media (max-width: 1100px) {
  .procurement-toolbar .compact-select {
    width: calc(50% - 5px);
  }
}
@media (max-width: 650px) {
  .procurement-toolbar .compact-select {
    width: 100%;
  }
}


/* Procurement ABC and stage enhancements */
.procurement-table th[data-key="stage"] {
  min-width: 165px;
}
.procurement-table th[data-key="abc"],
.procurement-table th[data-key="contractPrice"],
.procurement-table th[data-key="variance"] {
  min-width: 165px;
}
.procurement-form-grid select[name="stage"] {
  font-weight: 800;
  color: var(--navy-900);
  background: #f7fbff;
}
.procurement-form-grid input[name="abc"] {
  border-color: #7f70c9;
  background: #fbfaff;
  font-weight: 800;
}


/* Q3–Q4 dashboard exception analytics */
.card-header.red {
  background: linear-gradient(90deg, #8f2424, #d64f4f);
}

.split-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1280px) {
  .split-grid.three {
    grid-template-columns: 1fr;
  }
}

/* Record view modal and update timeline */
.icon-action.view {
  border-color: #9fd1d6;
  color: var(--teal-700);
}

.view-summary-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.view-summary-card > div,
.record-detail-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fbfe;
}

.view-summary-card span,
.record-detail-item span {
  color: var(--ink-500);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.view-summary-card strong,
.record-detail-item strong {
  overflow-wrap: anywhere;
  color: var(--navy-900);
}

.view-section {
  margin-top: 16px;
}

.view-section h3 {
  margin: 0 0 10px;
  color: var(--navy-900);
  font-size: 1rem;
}

.record-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.record-detail-item.span-2 {
  grid-column: span 2;
}

.timeline-help {
  margin: -4px 0 14px;
  color: var(--ink-500);
}

.record-timeline {
  display: grid;
  gap: 12px;
}

.timeline-entry {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
}

.timeline-marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--teal-600), var(--navy-800));
  box-shadow: 0 5px 14px rgba(1, 47, 92, 0.18);
}

.timeline-content {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.timeline-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timeline-title-row span,
.timeline-content small {
  color: var(--ink-500);
}

.timeline-content p {
  margin: 6px 0 3px;
}

.timeline-changes {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.timeline-changes > div {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-radius: 9px;
  background: #f4f7fb;
}

.timeline-changes span {
  color: var(--ink-500);
  font-size: 0.78rem;
  font-weight: 700;
}

.timeline-changes strong {
  overflow-wrap: anywhere;
}

.timeline-changes.muted {
  color: var(--ink-500);
  font-size: 0.88rem;
}

@media (max-width: 900px) {
  .view-summary-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .view-summary-card,
  .record-detail-grid {
    grid-template-columns: 1fr;
  }

  .record-detail-item.span-2 {
    grid-column: span 1;
  }

  .timeline-title-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

.other-option-input {
  margin-top: 8px;
  width: 100%;
  border: 1px dashed var(--line, #b8c7dc);
  background: #fffdf3;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
  margin-top: 16px;
}

.readonly-display {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

@media (max-width: 940px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

/* Procurement clickable stage analytics */
.procurement-stage-analytics .card-header small {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 800;
}

.stage-analytics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.stage-analytics-card {
  display: flex;
  min-height: 88px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 13px rgba(4, 42, 88, 0.05);
  color: var(--navy-900);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.stage-analytics-card:hover,
.stage-analytics-card.active {
  transform: translateY(-1px);
  border-color: var(--teal-700);
  box-shadow: 0 7px 18px rgba(4, 42, 88, 0.12);
}

.stage-analytics-card.active {
  background: #ecfbfd;
}

.stage-analytics-card strong {
  font-size: 1.65rem;
  line-height: 1;
}

.stage-analytics-card small {
  color: var(--ink-500);
  font-weight: 850;
}

.procurement-table th[data-key="prDate"] {
  min-width: 130px;
}

@media (max-width: 1280px) {
  .stage-analytics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .stage-analytics-grid {
    grid-template-columns: 1fr;
  }
}

/* Execution Dashboard datatable enhancements */
.dashboard-data-table {
  min-width: 0;
}

.dashboard-table-toolbar {
  align-items: stretch;
}

.dashboard-table-toolbar .search-field {
  min-width: min(100%, 240px);
}

.dashboard-filter,
.dashboard-page-size {
  width: auto;
  min-width: 140px;
}

.dashboard-page-size {
  min-width: 110px;
}

.data-table.dashboard-compact {
  min-width: 840px;
}

.table-pagination,
.dashboard-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  color: var(--ink-500);
  background: var(--surface-2);
  font-size: 0.78rem;
  font-weight: 800;
}

.pagination-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-actions .button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.74rem;
}

.sort-indicator {
  margin-left: 3px;
  opacity: 0.85;
  font-size: 0.66rem;
}

.ok-text {
  color: var(--green-700);
  font-weight: 800;
}

@media (max-width: 720px) {
  .dashboard-filter,
  .dashboard-page-size,
  .dashboard-table-toolbar .button {
    width: 100%;
  }

  .table-pagination,
  .dashboard-pagination,
  .pagination-actions {
    align-items: stretch;
    width: 100%;
  }

  .pagination-actions .button {
    flex: 1;
  }
}
