/* Design tokens mirror thana.co.th */
:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f4;
  --border: #ededed;
  --border-strong: #dfdfdf;
  --text: #141414;
  --text-secondary: #212121;
  --text-muted: #4a4a4a;
  --text-faint: #8a8a8a;
  --brand: #3ecf8e;
  --brand-2: #24b47e;
  --brand-glow: rgba(62, 207, 142, 0.22);
  --on-primary: #171717;
  --up: #3ecf8e;
  --down: #e5484d;
  --warn: #d97706;
  --radius: 12px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --font: "Inter", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 600; }

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #ffffffd9;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 72px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.logo-img { height: 40px; width: auto; border-radius: 8px; display: block; }
.logo-text {
  font-weight: 700;
  font-size: 1.05rem;
  padding-left: 12px;
  border-left: 1px solid var(--border-strong);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.center-card { max-width: 380px; margin: 72px auto; box-shadow: var(--shadow-lg); }

/* Forms */
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 14px 0 6px;
  line-height: 1.4;
}
input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
input[readonly] { background: var(--surface-2); }

/* Buttons — same as .btn-primary / .btn-ghost on thana.co.th */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--brand);
  color: var(--on-primary);
  cursor: pointer;
  margin-top: 16px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button:hover { background: var(--brand-2); }

button.secondary {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text);
}
button.secondary:hover { background: var(--bg-soft); border-color: var(--text-faint); }

button.danger {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--down);
}
button.danger:hover { background: #fdecec; border-color: var(--down); }

button:disabled { opacity: 0.5; cursor: not-allowed; }
button.small { padding: 6px 10px; font-size: 0.78rem; margin-top: 0; }

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

.error { color: var(--down); font-size: 0.82rem; margin-top: 8px; }
.success { color: var(--brand-2); font-size: 0.82rem; margin-top: 8px; }
.muted { color: var(--text-faint); font-size: 0.85rem; }

/* Header user bar + tabs */
#userbar { display: flex; align-items: center; gap: 12px; }
#userbar button { margin-top: 0; }

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-right: 8px;
}
.tab {
  background: transparent;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
}
.tab:hover { background: transparent; color: var(--text); }
.tab.active { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }

/* Add form */
.add-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.add-form > div { flex: 1; min-width: 180px; }
.add-form button { margin-top: 0; height: 40px; }

/* Monitor list */
.monitor-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 8px;
  margin: 0 -8px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}
.monitor-row:hover { background: var(--bg-soft); }
#monitor-list > div:last-child .monitor-row { border-bottom: none; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.up { background: var(--up); box-shadow: 0 0 0 4px var(--brand-glow); }
.dot.down { background: var(--down); box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.18); }
.dot.unknown { background: var(--border-strong); }

.monitor-main { flex: 1; min-width: 0; }
.monitor-name { font-weight: 600; }
.monitor-url {
  color: var(--text-faint);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monitor-meta { text-align: right; font-size: 0.78rem; color: var(--text-faint); min-width: 90px; }
.monitor-meta .uptime { color: var(--text); font-weight: 700; font-size: 0.95rem; }

.heartbeats { display: flex; gap: 2px; align-items: flex-end; height: 22px; }
.heartbeats .bar { width: 5px; height: 100%; border-radius: 2px; }
.heartbeats .bar.up { background: var(--up); }
.heartbeats .bar.down { background: var(--down); }

.expiry-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.tag.ok { color: var(--brand-2); background: #ecfaf3; border-color: #bdeed6; }
.tag.warn { color: var(--warn); background: #fef6e7; border-color: #f7dca8; }
.tag.critical { color: var(--down); background: #fdecec; border-color: #f6c4c5; }

/* Log / tables */
.detail-panel {
  margin: 4px 0 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-faint); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

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

/* LINE settings */
.steps { padding-left: 20px; margin: 16px 0 8px; line-height: 1.9; font-size: 0.88rem; }
.steps li { color: var(--text-muted); }
.steps b { color: var(--text); }

.copy-row { display: flex; gap: 8px; }
.copy-row button { margin-top: 0; white-space: nowrap; }
.copy-row input { font-family: var(--mono); font-size: 0.82rem; }

.mono { font-family: var(--mono); font-size: 0.78rem; }
code {
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

@media (max-width: 720px) {
  .header-inner { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .logo-img { height: 32px; }
  #userbar { width: 100%; justify-content: space-between; }
  main { padding: 18px 16px 40px; }
  .monitor-row { flex-wrap: wrap; }
  .heartbeats { order: 5; width: 100%; }
}

.list-head { margin-bottom: 6px; }
.detail-head { margin-bottom: 8px; }
.nowrap { white-space: nowrap; }

.dot.blocked { background: #b2b2b2; box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.06); }
.heartbeats .bar.blocked { background: #d4d4d4; }
.tag.blocked { color: var(--text-muted); background: var(--surface-2); border-color: var(--border-strong); cursor: help; white-space: nowrap; }

.edit-form {
  margin: 4px 0 12px;
  padding: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
