@font-face {
  font-family: "Noto Sans Thai";
  src: url("/fonts/NotoSansThai-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --background: #f5f8ff;
  --surface: #ffffff;
  --surface-strong: #f4f8ff;
  --border: #dce5f3;
  --text: #16233d;
  --muted: #62718c;
  --primary: #14c7a0;
  --primary-strong: #0aa986;
  --danger: #df536d;
  --warning: #cf8a1f;
  --blue: #4f82f5;
  font-family: "Noto Sans Thai", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--background); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 84% 12%, rgba(91,143,255,.27), transparent 30%), radial-gradient(circle at 8% 88%, rgba(20,199,160,.22), transparent 28%), var(--background); }
.login-card { width: min(100%, 420px); padding: 2.5rem; border: 1px solid rgba(204,217,238,.92); border-radius: 20px; background: rgba(255,255,255,.92); box-shadow: 0 24px 70px rgba(45,78,135,.16); }
.login-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.5rem; }
.brand-mark { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 1.5rem; padding: 4px; overflow: hidden; border-radius: 17px; background: linear-gradient(140deg, var(--primary), var(--blue)); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 8px 24px rgba(47,160,181,.18); }
.login-brand .brand-mark { flex: 0 0 auto; margin: 0; }
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-mark.small { width: 34px; height: 34px; margin: 0; padding: 2px; border-radius: 10px; }
.login-system-name { color: var(--text); font-size: 1.45rem; font-weight: 850; letter-spacing: .08em; line-height: 1; }
.login-system-type { margin-top: .36rem; color: var(--primary); font-size: .7rem; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 2.15rem; letter-spacing: -.07rem; line-height: 1.05; margin-bottom: .8rem; }
h2 { font-size: 1.75rem; margin-bottom: 0; }
h3 { font-size: 1rem; }
.eyebrow { color: var(--primary); text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; font-weight: 750; margin-bottom: .6rem; }
.muted { color: var(--muted); line-height: 1.5; }
label { display: grid; gap: .4rem; margin: 1rem 0; color: var(--muted); font-size: .84rem; }
input, select, textarea { width: 100%; padding: .72rem .8rem; border: 1px solid var(--border); border-radius: 9px; background: #fbfcff; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(20,199,160,.16); }
input[type="checkbox"] { width: auto; padding: 0; accent-color: var(--primary); }
.checkbox-field { display: flex; align-items: center; gap: .5rem; padding: .7rem 0; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 3.15rem; }
.password-toggle { position: absolute; top: 50%; right: .35rem; display: grid; place-items: center; width: 2.45rem; height: 2.45rem; transform: translateY(-50%); border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.password-toggle:hover { background: rgba(22,35,61,.06); color: var(--text); }
.password-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.password-toggle svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.password-eye-slash { display: none; }
.password-toggle.is-visible .password-eye-slash { display: block; }
textarea { min-height: 6rem; resize: vertical; }
.form-error { color: var(--danger); font-size: .86rem; }
.primary, .secondary, .danger, .text-button { border: 0; border-radius: 8px; padding: .65rem .9rem; font-weight: 700; }
.primary { background: linear-gradient(135deg, var(--primary), #52b4ef); color: #06242a; box-shadow: 0 5px 14px rgba(20,199,160,.2); }
.primary:hover { background: linear-gradient(135deg, #30d8b6, #69c3f5); }
.secondary { background: #e9effb; color: #344562; }
.danger { background: #fff0f3; color: #b93251; }
.text-button { background: transparent; color: var(--muted); padding: .25rem; }
.icon-button { display: inline-grid; place-items: center; width: 2.35rem; height: 2.35rem; padding: 0; }
.icon-button svg, .profile-tab svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.icon-button-with-label { grid-auto-flow: column; grid-auto-columns: max-content; gap: .45rem; width: auto; padding: .62rem .8rem; }
.icon-button:focus-visible, .profile-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.full { width: 100%; margin-top: 1rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 1.2rem; border-right: 1px solid var(--border); background: rgba(255,255,255,.88); box-shadow: 5px 0 24px rgba(76,105,150,.04); }
.sidebar-brand { display: flex; align-items: center; gap: .7rem; font-size: 1.25rem; font-weight: 800; }
.sidebar-tagline { margin: .9rem 0 1.4rem; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.navigation { display: grid; gap: .25rem; }
.navigation-group { display: grid; gap: .25rem; }
.navigation-parent { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .25rem; }
.navigation-parent .navigation-parent-link { min-width: 0; }
.navigation-submenu { display: grid; gap: .25rem; margin-left: .7rem; padding-left: .7rem; border-left: 1px solid var(--border); }
.navigation-submenu button { font-size: .82rem; }
.navigation button { padding: .62rem .7rem; border: 0; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; font-size: .88rem; }
.navigation button.navigation-submenu-toggle { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; padding: 0; }
.navigation-submenu-toggle svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; transition: transform .16s ease; }
.navigation-submenu-toggle.expanded svg { transform: rotate(180deg); }
.navigation button:hover { color: var(--text); background: #eef4ff; }
.navigation button.active { color: #08342f; background: linear-gradient(135deg, #a5f1df, #b9d8ff); font-weight: 800; }
.navigation button.active-parent { color: var(--primary); font-weight: 750; }
.node-link { padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; }
.node-link strong, .node-link .muted { display: block; }
.node-link:hover strong { color: var(--primary); text-decoration: underline; text-underline-offset: .18rem; }
.node-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 3px; }
.sidebar-footer { margin-top: auto; display: grid; gap: .4rem; padding-top: 1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .78rem; }
.sidebar-footer .text-button { justify-self: start; }
.content { min-width: 0; padding: 2rem clamp(1rem, 4vw, 4rem); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; }
.status-pill { padding: .42rem .7rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .78rem; }
.status-pill.good { color: #098968; border-color: rgba(20,199,160,.4); background: #f0fffa; }
.status-pill.bad { color: var(--danger); border-color: rgba(223,83,109,.35); background: #fff6f8; }
.page-content { display: grid; gap: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { min-width: 0; padding: 1.1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.card-title { color: var(--muted); font-size: .8rem; margin-bottom: .5rem; }
.metric { font-size: 1.7rem; font-weight: 800; letter-spacing: -.04rem; }
.metric small { color: var(--muted); font-size: .76rem; font-weight: 500; }
.card-action { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.access-control-deployment { border-color: rgba(20,199,160,.42); background: #f7fffc; }
.danger-zone { border-color: rgba(223,83,109,.42); background: #fffafb; }
.danger-zone .eyebrow, .danger-zone-status { color: #b93251; }
.danger-zone-status { margin: .35rem 0 0; font-weight: 700; }
.table-card { overflow: auto; padding: 0; }
.table-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.1rem 1.1rem 0; }
.table-heading h3 { margin-bottom: .4rem; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: .82rem 1rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
td.wrap { white-space: normal; word-break: break-word; }
tr:last-child td { border-bottom: 0; }
.tag { display: inline-flex; padding: .2rem .48rem; border-radius: 999px; background: #edf2fb; color: var(--muted); font-size: .7rem; font-weight: 700; }
.tag.good { background: #e3fbf4; color: #078565; }
.tag.warn { background: #fff4dd; color: var(--warning); }
.tag.bad { background: #fff0f3; color: var(--danger); }
.toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: .7rem; }
.toolbar label { margin: 0; min-width: 160px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .85rem; }
.form-grid label { min-width: 0; }
.gateway-connection-form small { color: var(--muted); line-height: 1.4; }
.bulk-provisioning-intro { background: linear-gradient(135deg, #f7fffd, #f3f8ff); }
.bulk-provisioning-form { display: grid; gap: 1rem; }
.bulk-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.bulk-form-grid label, .bulk-provisioning-form > label { margin: 0; }
.bulk-provisioning-form small { color: var(--muted); line-height: 1.4; }
.bulk-provisioning-form textarea { min-height: 7.25rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.bulk-provisioning-form #bulk-provisioning-csv { min-height: 12rem; margin-top: .55rem; }
.bulk-provisioning-actions { display: flex; justify-content: flex-end; }
.bulk-preview, .bulk-result { margin-top: 0; }
.bulk-result-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.credential-once { display: inline-block; max-width: 16rem; overflow-wrap: anywhere; color: #0b7160; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }
.history-filters { display: flex; align-items: end; flex-wrap: wrap; gap: .7rem; }
.history-filters label { margin: 0; min-width: 150px; flex: 1 1 180px; }
.history-filter-actions, .pagination-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 0; }
.pagination-page { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.profile-tabs-card { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.profile-tabs { display: flex; gap: .25rem; padding: .55rem .55rem 0; border-bottom: 1px solid var(--border); background: #f7f9fe; }
.profile-tab { display: inline-flex; align-items: center; gap: .45rem; border: 0; border-radius: 8px 8px 0 0; padding: .72rem .9rem; background: transparent; color: var(--muted); font-weight: 750; }
.profile-tab:hover { color: var(--text); background: #edf4ff; }
.profile-tab.active { background: var(--surface-strong); color: var(--primary); box-shadow: inset 0 -2px 0 var(--primary); }
.profile-tab-panel { padding: 1.1rem; }
.recovery-filters { margin: 1rem 0; }
.recovery-table { margin-top: .25rem; }
.message-id { color: #3268c8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }
.modal-table { margin: .7rem 0 1.2rem; max-height: 280px; }
.profile-tab-heading, .management-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; }
.profile-tab-heading h3, .management-card-header h4 { margin-bottom: .35rem; }
.profile-tab-heading p, .management-card-header p { margin-bottom: 0; }
.external-profile-selector { display: flex; align-items: end; justify-content: space-between; gap: .8rem; margin: 1rem 0 0; }
.external-profile-selector label { width: min(420px, 100%); margin: 0; }
.configuration-overview { display: grid; gap: 1rem; }
.configuration-metrics { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.revision-code { color: #3268c8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; overflow-wrap: anywhere; }
.runtime-setting-value { min-height: 1.7rem; margin-bottom: .45rem; font-size: 1.05rem; font-weight: 750; }
.management-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .85rem; }
.management-card { min-width: 0; padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: #fbfdff; }
.management-card-actions { display: flex; flex-wrap: wrap; gap: .42rem; margin-top: 1rem; }
.management-card-header .management-card-actions { margin-top: 0; flex-wrap: nowrap; }
.profile-data-grid { margin-top: 1rem; }
.grid-actions { display: flex; flex-wrap: nowrap; gap: .42rem; }
.topic-filter { display: inline-block; margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; color: var(--text); }
.management-details { display: grid; gap: .65rem; margin: 1rem 0 0; }
.management-details div { display: grid; gap: .16rem; }
.management-details dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.management-details dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }
.empty-state { padding: 2.2rem 1rem; border: 1px dashed var(--border); border-radius: 10px; text-align: center; }
.empty-state p { margin-bottom: .35rem; }
.empty { padding: 2rem; color: var(--muted); text-align: center; }
.notice { padding: .9rem 1rem; border-left: 3px solid var(--blue); border-radius: 0 8px 8px 0; background: #edf4ff; color: #3268c8; }
.toast { position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 5; padding: .9rem 1rem; border-radius: 10px; background: #087d64; color: #f4fffc; box-shadow: 0 12px 40px rgba(53,83,136,.2); }
.toast.error { background: #c74361; color: #fff7f8; }
dialog { width: min(640px, calc(100% - 2rem)); border: 1px solid var(--border); border-radius: 14px; background: #fff; color: var(--text); box-shadow: 0 24px 80px rgba(37,63,110,.2); }
dialog::backdrop { background: rgba(19,37,72,.28); }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
pre { overflow: auto; padding: .9rem; border-radius: 8px; background: #f2f6fc; color: #38506f; font-size: .75rem; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 2; height: auto; padding: .7rem 1rem; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-tagline, .sidebar-footer { display: none; }
  .navigation { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; padding-top: .7rem; }
  .content { padding: 1.25rem 1rem; }
  .topbar { align-items: flex-start; }
  .status-pill { display: none; }
  .profile-tab-panel { padding: .85rem; }
  .form-grid { grid-template-columns: 1fr; }
  .profile-tab-heading { align-items: flex-start; }
  .external-profile-selector { align-items: flex-start; flex-direction: column; }
  .pagination { align-items: flex-start; flex-direction: column; }
}
