:root {
  --bg: #f6f7f9;
  --card: #fff;
  --ink: #1d2330;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --accent: #2563eb;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  font: 14px/1.5 system-ui, "Noto Sans Thai", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
header {
  padding: 16px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
header p {
  margin: 2px 0 0;
  color: var(--muted);
}
.session {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
nav[aria-label="Main navigation"] {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  overflow-x: auto;
}
nav[aria-label="Main navigation"] a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  padding: 2px 0;
  border-bottom: 2px solid transparent;
}
nav[aria-label="Main navigation"] a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
main.console {
  padding: 20px 24px;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}
main.console input,
main.console select {
  width: 140px;
}
main.console select#account {
  field-sizing: content;
  width: auto;
  min-width: 140px;
  max-width: 100%;
  flex: 0 0 auto;
}
main.manage {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
section {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
section.wide {
  grid-column: 1 / -1;
}
h2 {
  margin: 0 0 12px;
  font-size: 15px;
}
h3 {
  margin: 0;
  font-size: 15px;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}
.page-heading h2 {
  margin: 4px 0 8px;
}
.page-heading p {
  margin: 0;
  color: var(--muted);
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
th,
td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}
td.num,
th.num {
  text-align: right;
}
td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}
button {
  font: inherit;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
input,
select,
textarea {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
textarea {
  resize: vertical;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row label {
  display: flex;
  flex-direction: row;
  align-items: center;
  font-weight: 500;
}
.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 4px 12px;
  margin-bottom: 12px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  word-break: break-all;
}
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2ff;
  color: var(--accent);
}
.pill.ok {
  background: #dcfce7;
  color: var(--ok);
}
.pill.warn {
  background: #fef3c7;
  color: var(--warn);
}
.pill.bad,
.pill.disabled {
  background: #fee2e2;
  color: var(--bad);
}
.pill.disabled {
  background: #e5e7eb;
  color: var(--muted);
}
.auth-warning {
  margin: 12px 24px 0;
  padding: 12px 16px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
}
.muted {
  color: var(--muted);
}
.err,
.error {
  color: var(--bad);
  overflow-wrap: anywhere;
}
#notice:empty,
#globalError:empty {
  display: none;
}
body > #notice,
body > #globalError {
  margin: 0 24px;
}
#notice {
  padding: 12px 16px;
  border-radius: 8px;
  background: #dcfce7;
  color: var(--ok);
}
.qr {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
}
.qr img {
  width: 200px;
  height: 200px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.big {
  font-size: 28px;
  font-weight: 600;
}
.legend,
.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  font-weight: normal;
}
.row a {
  color: var(--accent);
}
.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 {
  margin: 0;
}
.inbox-summary {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.inbox-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.inbox-field {
  min-width: 0;
  flex: 1 1 140px;
}
.inbox-field-text {
  flex: 2 1 220px;
}
main.console .inbox-filters input,
main.console .inbox-filters select {
  width: 100%;
}
.inbox-filters button {
  align-self: flex-end;
}
.inbox-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
.inbox-pager[hidden] {
  display: none !important;
}
.inbox {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.inbox-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.inbox-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: #f8fafc;
}
.inbox-card.gmail {
  border-left-color: #2563eb;
  background: #f8fbff;
}
.inbox-card.quiet {
  border-left-color: #94a3b8;
  background: #fff;
}
.inbox-card.line {
  border-left-color: #16a34a;
  background: #f6fdf8;
}
.inbox-card.test {
  border-left-color: #059669;
  background: #ecfdf5;
}
.inbox-card.error {
  border-left-color: var(--bad);
}
.inbox-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.inbox-time {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 13px;
}
.inbox-title {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.inbox-preview {
  font-size: 13px;
  overflow-wrap: anywhere;
}
.inbox-sub {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.inbox-amount {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.inbox-item + .inbox-item {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.inbox-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0;
  font-size: 12px;
}
.inbox-facts div {
  display: flex;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}
.inbox-facts dt {
  color: var(--muted);
  flex: none;
}
.inbox-facts dt::after {
  content: ":";
}
.inbox-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.inbox-detail {
  font-size: 12px;
  color: var(--muted);
}
.inbox-detail summary {
  cursor: pointer;
}
.inbox-id {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.timing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  margin: 8px 0 0;
}
.timing-grid div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}
.timing-grid dt {
  color: var(--muted);
  font-size: 11px;
}
.timing-grid dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}
.timing-grid dd.emph {
  color: var(--accent);
}
.table-wrap {
  overflow-x: auto;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 180px;
}
.actions button {
  padding: 5px 9px;
  font-size: 12px;
}
.editor {
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  max-width: 960px;
}
dialog.modal {
  border: none;
  padding: 0;
  background: transparent;
  width: min(960px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
}
dialog.modal::backdrop {
  background: rgba(17, 24, 39, 0.45);
}
dialog.modal .editor {
  margin-top: 0;
  max-width: none;
  max-height: calc(100vh - 48px);
  overflow: auto;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
.editor-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
}
label span {
  font-size: 12px;
  color: var(--muted);
  font-weight: normal;
}
.full {
  grid-column: 1 / -1;
}
.checkbox {
  flex-direction: row;
  align-items: center;
}
.checkbox input {
  width: auto;
  accent-color: var(--accent);
}
input:read-only,
textarea:read-only {
  background: #f9fafb;
  color: var(--muted);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.empty {
  padding: 24px 8px;
  color: var(--muted);
}
details summary {
  cursor: pointer;
}
pre {
  max-width: 650px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 11px;
  word-break: break-word;
}
footer {
  padding: 16px 24px;
  color: var(--muted);
  font-size: 12px;
}
.key-panel textarea {
  font-family: ui-monospace, monospace;
  overflow-wrap: anywhere;
}
body.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
body.page-login main {
  max-width: 460px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 32px;
}
body.page-login .eyebrow {
  margin: 0;
}
body.page-login h1 {
  margin: 12px 0;
  font-size: 22px;
}
body.page-login p {
  color: var(--muted);
}
body.page-login label {
  display: block;
  margin: 20px 0 6px;
}
body.page-login input,
body.page-login button {
  width: 100%;
  padding: 10px 12px;
}
body.page-login button {
  margin-top: 24px;
}
@media (max-width: 960px) {
  main.console {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  header,
  main.console,
  main.manage,
  footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .fields {
    grid-template-columns: 1fr;
  }
  .full {
    grid-column: auto;
  }
  .page-heading {
    flex-direction: column;
  }
  #notice,
  #globalError,
  .auth-warning {
    margin-left: 16px;
    margin-right: 16px;
  }
}
