:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-muted: #eef5f3;
  --ink: #20302f;
  --muted: #6f7d7a;
  --line: #d9e3e0;
  --teal: #087c7a;
  --teal-dark: #095f5e;
  --green: #2f8a52;
  --amber: #b66d12;
  --red: #b64242;
  --charcoal: #263635;
  --shadow: 0 18px 45px rgba(36, 54, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: var(--charcoal);
  color: #f6fbfa;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, #21a391, #e1ad53);
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #b9c8c5;
  font-size: 0.86rem;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: #cfddda;
  text-align: left;
  text-decoration: none;
}

.nav-button:hover,
.nav-button:focus-visible {
  outline: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-button.is-active {
  background: #f3fbf9;
  color: var(--charcoal);
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  display: grid;
  gap: 4px;
}

.sidebar-note span {
  color: #b9c8c5;
  font-size: 0.8rem;
}

.content {
  min-width: 0;
  padding: 22px clamp(16px, 3vw, 36px) 34px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1,
.section-heading h2,
.hero-copy h2,
.panel h3 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(1.55rem, 2.5vw, 2.2rem);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

.icon-button,
.mode-toggle,
.text-button,
.primary-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}

.mode-toggle {
  height: 42px;
  padding: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.mode-toggle span {
  min-width: 38px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.86rem;
}

.mode-toggle[aria-pressed="false"] span:first-child,
.mode-toggle[aria-pressed="true"] span:last-child {
  background: var(--teal);
  color: #ffffff;
}

.text-button {
  padding: 9px 12px;
  color: var(--teal-dark);
  font-weight: 700;
}

.primary-button {
  min-height: 42px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--teal-dark);
}

.inline-link {
  text-decoration: none;
}

.profile-chip {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  padding: 8px 11px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.login-body {
  min-height: 100vh;
  background: #e9f1ef;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 0.46fr) minmax(0, 0.54fr);
}

.login-panel {
  padding: clamp(24px, 5vw, 64px);
  background: var(--surface);
  display: grid;
  align-content: center;
  gap: 30px;
}

.login-brand .brand span {
  color: var(--muted);
}

.login-panel h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.12;
}

.login-copy {
  color: var(--muted);
  max-width: 52ch;
}

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

.login-submit {
  width: 100%;
}

.login-hint {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 14px;
  display: grid;
  gap: 4px;
}

.login-hint span {
  color: var(--muted);
}

.setup-check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.setup-check input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

.login-visual {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  display: grid;
  align-items: end;
  padding: clamp(22px, 4vw, 44px);
}

.login-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(32, 48, 47, 0.06), rgba(32, 48, 47, 0.76));
}

.login-stat-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.login-stat-grid article {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 14px;
}

.login-stat-grid strong,
.login-stat-grid span {
  display: block;
}

.login-stat-grid strong {
  font-size: 1.35rem;
}

.login-stat-grid span {
  color: var(--muted);
  font-size: 0.86rem;
}

.page-section {
  display: none;
}

.page-section.is-visible {
  display: block;
}

.ops-hero {
  position: relative;
  min-height: 280px;
  border-radius: 8px;
  overflow: hidden;
  background: #dbe8e6;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.ops-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ops-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(244, 247, 246, 0.98), rgba(244, 247, 246, 0.74) 38%, rgba(244, 247, 246, 0.04) 72%);
}

.hero-copy {
  position: relative;
  z-index: 1;
  width: min(590px, 82%);
  padding: clamp(22px, 4vw, 42px);
}

.hero-copy h2 {
  font-size: clamp(1.45rem, 3vw, 2.5rem);
  line-height: 1.18;
}

.hero-copy p:last-child {
  color: var(--muted);
  max-width: 58ch;
}

.metric-grid,
.dashboard-grid,
.tool-grid {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 16px;
}

.dashboard-grid,
.tool-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  margin-bottom: 16px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  min-height: 118px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metric-card span,
.metric-card small,
.result-list dt,
.work-list small,
.schema-stack span,
.pdpa-board span {
  color: var(--muted);
}

.metric-card strong {
  font-size: clamp(1.35rem, 2vw, 1.85rem);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-header,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-heading {
  align-items: center;
  padding: 10px 0 18px;
}

.status-pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--teal-dark);
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.is-good {
  color: var(--green);
  background: #eef8f1;
}

.bars {
  display: grid;
  gap: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 90px;
  align-items: center;
  gap: 12px;
}

.bar-row span {
  color: var(--muted);
  font-size: 0.9rem;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #edf3f1;
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.bar-row:nth-child(2) .bar-track i {
  background: var(--amber);
}

.bar-row:nth-child(3) .bar-track i {
  background: var(--green);
}

.work-list,
.check-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.work-list li,
.check-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.work-list strong,
.work-list small {
  display: block;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-top: 7px;
}

.is-good {
  background: var(--green);
}

.is-warn {
  background: var(--amber);
}

.is-danger {
  background: var(--red);
}

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

label,
.wide-label {
  display: grid;
  gap: 7px;
}

label span,
.wide-label span {
  color: var(--muted);
  font-size: 0.88rem;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 10px;
  color: var(--ink);
  background: #ffffff;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(8, 124, 122, 0.16);
  outline-offset: 2px;
}

.result-list {
  margin: 0;
  display: grid;
  gap: 11px;
}

.result-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.result-list dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.result-list .is-total {
  border-bottom: 0;
  background: var(--surface-muted);
  margin-top: 2px;
  padding: 12px;
  border-radius: 8px;
}

.mini-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

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

.permission-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.permission-item strong {
  font-size: 0.94rem;
}

.permission-state {
  min-width: 34px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 0.72rem;
}

.schema-stack,
.translation-list,
.infra-checks,
.code-sample {
  display: grid;
  gap: 10px;
}

.schema-stack div,
.translation-item,
.infra-check {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.schema-stack strong,
.schema-stack span,
.translation-item strong,
.translation-item span {
  display: block;
}

.pdpa-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.pdpa-board article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.pdpa-board strong {
  display: block;
  font-size: 1.45rem;
}

.check-mark {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: var(--green);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  margin-top: 2px;
}

.check-mark::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.schema-flow {
  display: grid;
  grid-template-columns: 1fr 34px 1fr 34px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.schema-flow div {
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 10px;
  text-align: center;
  font-weight: 800;
  background: var(--surface-muted);
}

.schema-flow span {
  height: 2px;
  background: var(--teal);
}

.code-sample {
  background: #172523;
  color: #d7f0e9;
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
}

.code-sample code {
  display: block;
  white-space: nowrap;
}

.code-sample.is-large {
  min-height: 263px;
  align-content: center;
}

.progress-track {
  height: 13px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7efed;
  margin-bottom: 16px;
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--green));
}

.infra-check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.infra-check label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.infra-check input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

.source-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0 0;
}

.source-strip a {
  color: var(--teal-dark);
  background: #e8f4f1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
}

.users-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.65fr);
  gap: 16px;
}

.user-toolbar {
  align-items: center;
}

.toolbar-actions {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 150px 150px;
  gap: 10px;
  align-items: end;
  width: min(100%, 570px);
}

.search-field {
  position: relative;
  display: block;
}

.search-field svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

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

.user-list {
  display: grid;
  gap: 10px;
}

.user-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  text-align: left;
  color: var(--ink);
  text-decoration: none;
}

.user-card:hover,
.user-card:focus-visible,
.user-card.is-selected {
  border-color: rgba(8, 124, 122, 0.6);
  box-shadow: 0 0 0 3px rgba(8, 124, 122, 0.1);
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-muted);
  color: var(--teal-dark);
  font-weight: 900;
}

.user-main {
  min-width: 0;
}

.user-main strong,
.user-main span {
  display: block;
}

.user-main strong {
  overflow-wrap: anywhere;
}

.user-main span,
.user-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.user-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.badge {
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 0.74rem;
  font-weight: 900;
  white-space: nowrap;
}

.badge.is-active {
  background: #eaf6ef;
  color: var(--green);
}

.badge.is-pending {
  background: #fff4e4;
  color: var(--amber);
}

.badge.is-suspended {
  background: #faeaea;
  color: var(--red);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  color: var(--ink);
}

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

.permission-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.permission-preview strong {
  display: block;
  margin-bottom: 8px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.permission-chip {
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--teal-dark);
  padding: 6px 9px;
  font-size: 0.82rem;
  font-weight: 800;
}

.form-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toast {
  min-height: 20px;
  color: var(--green);
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 28, 30, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(10, 28, 30, 0.22);
  padding: 20px;
}

.password-form {
  display: grid;
  gap: 12px;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-item {
  display: grid;
  grid-template-columns: minmax(120px, 160px) 1fr 1.4fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.audit-time {
  color: var(--muted);
  font-size: 0.86rem;
}

.not-found-card {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

@media (max-width: 1040px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 360px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .nav-button {
    justify-content: center;
    text-align: center;
    padding: 10px;
  }

  .nav-button svg {
    display: none;
  }

  .sidebar-note {
    display: none;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .tool-grid,
  .users-layout {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    width: 100%;
  }

  .audit-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .login-panel {
    padding: 22px 16px;
  }

  .login-stat-grid {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 300px;
  }

  .content {
    padding: 16px 12px 24px;
  }

  .topbar,
  .section-heading,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-copy {
    width: 100%;
  }

  .ops-hero::after {
    background: rgba(244, 247, 246, 0.86);
  }

  .metric-grid,
  .form-grid,
  .permission-grid,
  .pdpa-board,
  .toolbar-actions {
    grid-template-columns: 1fr;
  }

  .user-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .user-meta {
    grid-column: 1 / -1;
    justify-items: start;
    grid-template-columns: auto auto;
    align-items: center;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .result-list div {
    align-items: flex-start;
  }

  .schema-flow {
    grid-template-columns: 1fr;
  }

  .schema-flow span {
    width: 2px;
    height: 20px;
    margin: 0 auto;
  }
}

@media print {
  .sidebar,
  .topbar-actions {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .content {
    padding: 0;
  }

  .page-section {
    display: block;
    break-inside: avoid;
  }
}
