:root {
  color-scheme: light;
  --page: #f3f6f9;
  --page-accent: #e9f0f5;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #eef3f7;
  --ink: #132235;
  --ink-soft: #3d4d60;
  --muted: #6a7889;
  --line: #dce4eb;
  --line-strong: #c7d2dc;
  --brand: #116b78;
  --brand-hover: #0b5661;
  --brand-soft: #e4f3f4;
  --navy: #0f2742;
  --navy-soft: #e8eef5;
  --success: #157347;
  --success-soft: #e8f6ef;
  --warning: #8a5a00;
  --warning-soft: #fff4d7;
  --danger: #b42318;
  --danger-hover: #941c13;
  --danger-soft: #fdecea;
  --info: #1769aa;
  --info-soft: #e9f3fb;
  --shadow-xs: 0 1px 2px rgba(15, 39, 66, .04);
  --shadow-sm: 0 8px 22px rgba(15, 39, 66, .07);
  --shadow-md: 0 18px 48px rgba(15, 39, 66, .10);
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 20px;
  --content: 1200px;
  --header-content: 1440px;
  --focus: 0 0 0 4px rgba(17, 107, 120, .17);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(17, 107, 120, .08), transparent 30rem),
    linear-gradient(180deg, var(--page-accent) 0, var(--page) 18rem, var(--page) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { color: #fff; background: var(--brand); }
a { color: var(--brand); text-underline-offset: .16em; }
a:hover { color: var(--brand-hover); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button, select { touch-action: manipulation; }
h1, h2, h3 { color: var(--navy); text-wrap: balance; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--navy);
  box-shadow: var(--shadow-md);
  transform: translateY(-180%);
  transition: transform .18s ease;
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(199, 210, 220, .82);
  background: rgba(255, 255, 255, .91);
  box-shadow: 0 4px 18px rgba(15, 39, 66, .045);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.site-header__inner {
  width: min(var(--header-content), calc(100% - 40px));
  min-height: 74px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--navy);
  font-weight: 800;
  letter-spacing: -.025em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--navy); }
.brand__mark {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(17, 107, 120, .16);
  border-radius: 13px;
  background: linear-gradient(145deg, #fff, #eef7f8);
  box-shadow: var(--shadow-xs);
}
.brand__mark img { width: 38px; height: 38px; object-fit: contain; }
.brand__name { overflow: hidden; text-overflow: ellipsis; }

.main-nav {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.main-nav a {
  position: relative;
  flex: 0 0 auto;
  padding: 9px clamp(8px, .85vw, 13px);
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: .91rem;
  font-weight: 690;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
  transition: color .16s ease, background .16s ease, transform .16s ease;
}
.main-nav a:hover {
  color: var(--navy);
  background: var(--surface-strong);
}
.main-nav a.active {
  color: var(--brand-hover);
  background: var(--brand-soft);
}
.main-nav a.active::after {
  position: absolute;
  right: 12px;
  bottom: 3px;
  left: 12px;
  height: 2px;
  border-radius: 999px;
  background: var(--brand);
  content: "";
}

.nav-toggle {
  display: none;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--navy);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  font-weight: 750;
  cursor: pointer;
}
.nav-toggle__icon,
.nav-toggle__icon::before,
.nav-toggle__icon::after {
  width: 18px;
  height: 2px;
  display: block;
  border-radius: 999px;
  background: currentColor;
  transition: transform .18s ease, opacity .18s ease;
}
.nav-toggle__icon { position: relative; }
.nav-toggle__icon::before,
.nav-toggle__icon::after { position: absolute; left: 0; content: ""; }
.nav-toggle__icon::before { top: -6px; }
.nav-toggle__icon::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle__icon { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__icon::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__icon::after { top: 0; transform: rotate(-45deg); }

.header-tools {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
.guest-tools { grid-column: 3; }

.language-switcher {
  position: relative;
  min-width: 128px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.language-switcher:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.language-switcher:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.language-switcher__icon {
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--brand-hover);
  background: var(--brand-soft);
  font-size: .7rem;
  font-weight: 900;
}
.language-select {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 22px 0 0;
  border: 0;
  outline: 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: .86rem;
  font-weight: 720;
  cursor: pointer;
}

.account {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}
.account form { margin: 0; }
.account__identity {
  max-width: 150px;
  display: grid;
  line-height: 1.18;
  text-align: right;
}
.account__identity strong {
  overflow: hidden;
  color: var(--ink);
  font-size: .87rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account__identity span {
  overflow: hidden;
  color: var(--muted);
  font-size: .76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.container {
  width: min(var(--content), calc(100% - 40px));
  flex: 1 0 auto;
  margin: clamp(26px, 4vw, 46px) auto clamp(54px, 7vw, 86px);
}
.container.narrow { width: min(720px, calc(100% - 40px)); }

.page-heading {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
}
.page-heading > div:first-child { min-width: 0; }
.page-heading h1 {
  margin: 0 0 6px;
  font-size: clamp(1.85rem, 4vw, 2.65rem);
  line-height: 1.08;
  letter-spacing: -.045em;
}
.page-heading h2 {
  margin: 0 0 5px;
  font-size: clamp(1.18rem, 2vw, 1.42rem);
  line-height: 1.2;
  letter-spacing: -.025em;
}
.page-heading p { max-width: 72ch; margin: 0; color: var(--muted); }
.page-heading > a:not(.button) { flex: 0 0 auto; font-weight: 700; text-decoration: none; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.panel,
.stat {
  border: 1px solid rgba(199, 210, 220, .82);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-sm);
}
.panel {
  padding: clamp(19px, 2.4vw, 28px);
  margin-bottom: 22px;
  border-radius: var(--radius-lg);
}
.panel h2,
.panel h3 { margin-top: 0; letter-spacing: -.025em; }
.panel > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 20px; margin-bottom: 22px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .panel,
.grid > .stat { min-width: 0; margin-bottom: 0; }

.stat {
  position: relative;
  min-height: 132px;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--radius-lg);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), #5aa6ad);
  content: "";
}
.stat::after {
  position: absolute;
  right: -26px;
  bottom: -38px;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--brand-soft);
  content: "";
}
.stat:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.stat span { position: relative; z-index: 1; color: var(--muted); font-size: .88rem; font-weight: 750; }
.stat strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 10px;
  color: var(--navy);
  font-size: clamp(2rem, 4vw, 2.65rem);
  line-height: 1;
  letter-spacing: -.045em;
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 5px 14px rgba(17, 107, 120, .18);
  font-weight: 760;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.button:hover { color: #fff; background: var(--brand-hover); box-shadow: 0 7px 18px rgba(17, 107, 120, .24); transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button.secondary { color: var(--ink); border-color: var(--line); background: var(--surface); box-shadow: var(--shadow-xs); }
.button.secondary:hover { color: var(--navy); border-color: var(--line-strong); background: var(--surface-strong); box-shadow: var(--shadow-xs); }
.button.danger { background: var(--danger); box-shadow: 0 5px 14px rgba(180, 35, 24, .16); }
.button.danger:hover { background: var(--danger-hover); }
.button.ghost { color: var(--ink-soft); border-color: var(--line); background: transparent; box-shadow: none; }
.button.ghost:hover { color: var(--navy); background: var(--surface-strong); box-shadow: none; }
.button.small { min-height: 34px; padding: 6px 10px; border-radius: 8px; font-size: .82rem; }
.button[disabled] { opacity: .52; cursor: not-allowed; transform: none; }

label { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: .9rem; font-weight: 760; }
.field { margin-bottom: 18px; }
input:not([type]),
input[type="text"],
input[type="password"],
input[type="date"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(15, 39, 66, .025);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
textarea { min-height: 116px; resize: vertical; }
input::placeholder,
textarea::placeholder { color: #93a0ae; }
input:hover,
select:hover,
textarea:hover { border-color: #aab8c5; }
input:focus,
select:focus,
textarea:focus { border-color: var(--brand); box-shadow: var(--focus); }
input:disabled,
select:disabled,
textarea:disabled { color: var(--muted); background: var(--surface-strong); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
.help { margin-top: 6px; color: var(--muted); font-size: .84rem; }

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px) auto;
  gap: 14px;
  align-items: end;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  scrollbar-color: #a9b7c4 var(--surface-strong);
  scrollbar-width: thin;
}
table { width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; background: var(--surface); }
th, td { padding: 14px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th {
  position: sticky;
  z-index: 1;
  top: 0;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: .76rem;
  font-weight: 820;
  letter-spacing: .065em;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #fbfcfd; }
tr:last-child td { border-bottom: 0; }
td strong { color: var(--navy); }
.table-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.table-actions form { margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 810;
  line-height: 1.1;
  white-space: nowrap;
}
.badge.success { color: var(--success); border-color: #c6e8d6; background: var(--success-soft); }
.badge.warning { color: var(--warning); border-color: #edd99e; background: var(--warning-soft); }
.badge.danger { color: var(--danger); border-color: #efc5c1; background: var(--danger-soft); }
.badge.info { color: var(--info); border-color: #c9dff0; background: var(--info-soft); }
.badge.neutral { color: #566575; border-color: #d8e0e7; background: #f0f3f6; }

.flash-stack { width: min(var(--content), calc(100% - 40px)); margin: 18px auto -10px; }
.flash {
  position: relative;
  padding: 14px 16px 14px 18px;
  margin-bottom: 10px;
  border: 1px solid;
  border-left-width: 4px;
  border-radius: 11px;
  box-shadow: var(--shadow-xs);
}
.flash.success { color: #0f633e; border-color: #aad9c3; background: #eef9f3; }
.flash.warning { color: #795500; border-color: #e4cb82; background: #fff8e3; }
.flash.danger { color: #8c1d15; border-color: #efb7b3; background: #fff2f1; }
.flash.info { color: #155d8e; border-color: #b7d6ee; background: #f0f7fc; }
.flash ul { margin: 8px 0 0; padding-left: 20px; }

.empty {
  padding: 44px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.list { margin: 0; padding: 0; list-style: none; }
.list > li {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.list > li > div { min-width: 0; }
.list > li:last-child { border-bottom: 0; }
.list a { color: var(--navy); text-decoration: none; }
.list a:hover { color: var(--brand); }
.meta { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }

.subpiece-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px auto;
  gap: 9px;
  align-items: center;
  margin-bottom: 9px;
}

.checkbox-group {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.checkbox-group legend { padding: 0 6px; color: var(--ink-soft); font-weight: 760; }
.checkbox-group label { margin-bottom: 9px; }

.auth-shell {
  width: 100%;
  min-height: 0;
  flex: 1 0 auto;
  display: grid;
  place-items: center;
  padding: clamp(34px, 7vw, 82px) 20px;
}
.auth-card { width: min(490px, 100%); padding: clamp(25px, 5vw, 38px); box-shadow: var(--shadow-md); }
.auth-card h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 5vw, 2.35rem); letter-spacing: -.04em; }
.auth-card .brand { margin-bottom: 20px; }

.site-footer {
  flex: 0 0 auto;
  margin-top: auto;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, .88);
  font-size: .82rem;
  backdrop-filter: blur(12px);
}
.site-footer__inner {
  width: min(var(--content), calc(100% - 40px));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.muted { color: var(--muted); }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.inline select,
.inline input[type="password"] { width: auto; min-width: 160px; }
.no-margin { margin: 0; }
code {
  padding: .15em .35em;
  border-radius: 5px;
  color: #35485b;
  background: var(--surface-strong);
  font-size: .88em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

:focus-visible { outline: none; box-shadow: var(--focus); }

@media (max-width: 1220px) {
  .site-header__inner { grid-template-columns: auto auto minmax(0, 1fr); gap: 14px; }
  .nav-toggle { display: inline-flex; grid-column: 2; justify-self: start; }
  .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    display: none;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    padding: 10px 0 16px;
    border-top: 1px solid var(--line);
  }
  .main-nav.open { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .main-nav a { padding: 11px 13px; text-align: center; }
  .header-tools { grid-column: 3; grid-row: 1; }
}

@media (max-width: 900px) {
  .grid.three,
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > .actions { grid-column: 1 / -1; }
  .account__identity { display: none; }
  .account { padding-left: 0; border-left: 0; }
}

@media (max-width: 700px) {
  .site-header__inner { width: min(100% - 24px, var(--header-content)); min-height: 66px; grid-template-columns: minmax(0, 1fr) auto; }
  .brand__mark { width: 42px; height: 42px; flex-basis: 42px; }
  .brand__mark img { width: 34px; height: 34px; }
  .nav-toggle { grid-column: 2; justify-self: end; }
  .header-tools {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    display: none;
    justify-content: space-between;
    padding: 0 0 12px;
  }
  .main-nav.open ~ .header-tools { display: flex; }
  .guest-tools { grid-column: 2; grid-row: 1; width: auto; display: flex; padding: 0; }
  .main-nav { grid-row: 3; }
  .main-nav.open { grid-template-columns: 1fr 1fr; }
  .language-switcher { min-width: 124px; }
  .container,
  .container.narrow,
  .flash-stack,
  .site-footer__inner { width: min(100% - 24px, var(--content)); }
  .container { margin-top: 24px; margin-bottom: 52px; }
  .page-heading { flex-direction: column; align-items: stretch; gap: 15px; }
  .page-heading .actions { width: 100%; }
  .page-heading .actions .button { flex: 1 1 auto; }
  .grid.two,
  .grid.three,
  .grid.four,
  .filters { grid-template-columns: 1fr; }
  .filters > .actions { grid-column: auto; }
  .panel { padding: 19px; border-radius: 16px; }
  .stat { min-height: 118px; padding: 19px; border-radius: 16px; }
  .list > li { align-items: flex-start; }
  .subpiece-row { grid-template-columns: 1fr; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
  .site-footer__inner { min-height: 84px; flex-direction: column; justify-content: center; gap: 3px; text-align: center; }
}

@media (max-width: 480px) {
  .brand__name { max-width: 190px; font-size: .84rem; }
  .guest-tools .language-switcher { min-width: 112px; }
  .main-nav.open { grid-template-columns: 1fr; }
  .header-tools { align-items: stretch; flex-direction: column; }
  .header-tools .language-switcher { width: 100%; }
  .account { width: 100%; }
  .account form,
  .account .button { width: 100%; }
  .actions { align-items: stretch; }
  .actions .button { flex: 1 1 100%; }
  .inline { align-items: stretch; flex-direction: column; }
  .inline select,
  .inline input[type="password"] { width: 100%; }
}

@media (max-width: 360px) {
  .brand__name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  .site-header,
  .site-footer,
  .no-print,
  .flash-stack,
  .skip-link { display: none !important; }
  body { display: block; background: #fff; }
  .container { width: 100%; margin: 0; }
  .panel,
  .table-wrap,
  .stat { border-color: #aaa; box-shadow: none; }
  table { min-width: 0; }
  th { position: static; }
}

/* 2.1.3 deployment and layout hardening */
html,
body { min-height: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
}

.dashboard-stats { margin-bottom: 24px; }
.dashboard-panels { margin-top: 0; }

.language-switcher__icon svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Keep the native dropdown compact while leaving enough room for future names. */
.language-switcher { min-width: 148px; }
.language-select { min-width: 92px; }

@media (max-width: 700px) {
  .language-switcher { min-width: 142px; }
}
