@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable.min.css");
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Lao:wght@400;600;700&display=swap");

/* Lao-NWP · mockup color + studio masthead */
:root {
  --brand: #ec6a4e;
  --brand-strong: #c8431f;
  --brand-soft: #fdf3f1;
  --brand-mid: #fce4df;

  --navy: #2f3b4c;
  --navy-soft: #3a475a;

  --ok: #22a06b;
  --ok-soft: #e8f8f0;
  --warn: #e8a317;
  --warn-soft: #fef3e2;
  --danger: #d14343;
  --danger-soft: #fdecec;
  --info: #3b5bdb;
  --info-soft: #eef2ff;

  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e5e9ef;
  --line-subtle: #eef1f4;

  --font-sans: "Pretendard Variable", Pretendard, "Noto Sans Lao",
    -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
    "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--brand-strong); text-decoration: none; }
a:hover { color: #9c3418; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ===== Masthead (lao-studio-fe) ===== */
.masthead,
.top {
  position: sticky;
  top: 0;
  z-index: 1100;
  display: flex;
  align-items: stretch;
  gap: 1.5rem;
  min-height: 3.5rem;
  padding: 0 2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.wordmark,
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:hover,
.brand:hover { color: var(--ink); text-decoration: none; }

.wordmark img {
  width: 2rem;
  height: 2rem;
  display: block;
  object-fit: contain;
}

.wordmark__brand {
  color: var(--brand);
  font-weight: 700;
}
.wordmark__product {
  color: var(--navy);
  font-weight: 600;
}

.nav,
.top-center nav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 0.25rem;
  flex: 1;
}

.nav a,
.top-center nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 1rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 120ms var(--ease);
}
.nav a:hover,
.top-center nav a:hover {
  color: var(--ink);
  text-decoration: none;
}
.nav a[aria-current="page"],
.top-center nav a.active {
  color: var(--brand);
  font-weight: 600;
}
.nav a[aria-current="page"]::after,
.top-center nav a.active::after {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 0;
  height: 2px;
  background: var(--brand);
  border-radius: 9999px;
}

.masthead__end,
.top-right {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
  flex-shrink: 0;
}

.lang-switch {
  font-size: 0.75rem;
  color: #b2aca9;
  white-space: nowrap;
}
.lang-switch a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  margin: 0 0.2rem;
}
.lang-switch a:hover { color: var(--brand); }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 9999px;
  padding: 0.35rem 0.75rem 0.35rem 0.4rem;
}
.user-avatar {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ===== Page ===== */
.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
}
.page-title.mono,
.page-title .mono { font-family: var(--font-mono); }
.page-title small {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.35rem;
}

.page-intro { display: none; }
.page-meta {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.wrap > section { margin-bottom: 1.75rem; }
.wrap > section:last-child { margin-bottom: 0; }
.wrap > .board-grid,
.wrap > .board-panel,
.wrap > .embed-section,
.wrap > .summary { margin-bottom: 1.25rem; }

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line-subtle);
  background: var(--panel);
}
.section-head h2 { margin: 0; font-size: 1rem; }
.section-head a,
.link-more {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.section-head a:hover,
.link-more:hover { color: var(--brand); }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand); }

/* ===== KPI cards (colored icons) ===== */
.summary,
.board-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.board-kpis--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 6.5rem;
  transition: box-shadow 200ms var(--ease);
}
.kpi:hover { box-shadow: var(--shadow); }
.kpi--alert {
  border-color: #f0a89f;
  background: #fff8f6;
}
.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.kpi .label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.kpi .value {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi .value-slash {
  margin: 0 0.15rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 1.25rem;
}
.kpi .value-total {
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 600;
}
.kpi .value.small {
  font-size: 0.9rem;
  font-weight: 600;
  word-break: break-all;
  letter-spacing: 0;
}
.kpi .sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: auto;
  line-height: 1.35;
}
.kpi .sub.ok { color: var(--ok); font-weight: 600; }
.kpi .sub.danger { color: var(--danger); font-weight: 600; }
.warn-val { color: var(--brand) !important; }

.kpi-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}
.kpi-icon.navy { background: var(--navy); }
.kpi-icon.coral { background: var(--brand); }
.kpi-icon.green { background: var(--ok); }
.kpi-icon.red { background: var(--danger); }
.kpi-icon.slate { background: var(--navy-soft); }
.kpi-icon.amber { background: var(--warn); color: #1e1b1a; }

.cell-sub {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Board panels ===== */
.board-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.board-panel,
.board-panel.full {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

section > h2 { margin: 0 0 0.75rem; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.table-wrap.compact,
.board-panel .table-wrap {
  margin-bottom: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}
/* navy header like mockup */
th {
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  text-transform: none;
  border-bottom: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
.table-wrap.compact th,
.table-wrap.compact td {
  padding: 0.65rem 0.9rem;
  font-size: 0.8125rem;
}
.empty {
  color: var(--muted);
  text-align: center !important;
  padding: 2.5rem 1rem !important;
  white-space: normal !important;
  font-size: 0.875rem;
}

table a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
table a:hover { color: var(--brand); }

/* ===== Status badges (solid, mockup) ===== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.4rem;
  padding: 0.15rem 0.65rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: #eef2f6;
  color: var(--navy);
  min-width: 4rem;
  white-space: nowrap;
}
.st-up, .dw-ok, .dw-complete, .job-F, .job-X {
  background: var(--ok);
  color: #fff;
}
.job-R, .dw-waiting {
  background: var(--brand);
  color: #fff;
}
.st-stale, .st-unknown, .job-Q, .job-H, .job-W, .job-S, .job-T, .job-B, .dw-delayed {
  background: var(--warn);
  color: #1e1b1a;
}
.st-down, .job-E, .dw-error {
  background: var(--danger);
  color: #fff;
}

/* ===== Forms / buttons ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--ink);
  font-weight: 600;
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.form-grid input:hover,
.form-grid select:hover,
.form-grid textarea:hover { border-color: #f0a89f; }
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(236, 106, 78, 0.2);
}
.form-grid .full { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  align-items: end;
  gap: 0.5rem;
}

.form-grid button,
.btn-del, .btn-submit, .btn-kill, .btn-del-script, .btn-del-sched,
.btn-secondary, .btn-edit, .btn-edit-script, .btn-edit-sched,
.btn-primary, a.btn-primary, a.btn-secondary, button.btn-secondary,
.btn-danger, button.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.4rem;
  padding: 0 1rem;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.84rem;
  font-family: inherit;
  text-decoration: none !important;
  transition: background 120ms var(--ease);
}

.form-grid button, .btn-submit,
.btn-primary, a.btn-primary {
  background: var(--navy);
  color: #fff !important;
}
.form-grid button:hover, .btn-submit:hover,
.btn-primary:hover, a.btn-primary:hover {
  background: var(--navy-soft);
}

.btn-del, .btn-kill, .btn-del-script, .btn-del-sched,
.btn-danger, button.btn-danger {
  background: var(--danger);
  color: #fff !important;
}
.btn-danger:hover, button.btn-danger:hover { background: #b42318; }

.btn-secondary, .btn-edit, .btn-edit-script, .btn-edit-sched,
a.btn-secondary, button.btn-secondary {
  background: var(--brand-soft);
  color: var(--brand-strong) !important;
  border: 1px solid var(--brand-mid);
}
.btn-secondary:hover, a.btn-secondary:hover, button.btn-secondary:hover {
  background: var(--brand-mid);
}

.row-actions { white-space: nowrap; }
.row-actions button, .row-actions a { margin-right: 0.35rem; }

a.btn-link, button.btn-link {
  background: transparent;
  border: 0;
  color: var(--brand-strong);
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  text-decoration: none;
  font-family: inherit;
}
a.btn-link:hover, button.btn-link:hover {
  color: #9c3418;
  text-decoration: underline;
}

.mono { font-family: var(--font-mono); font-size: 0.9em; }
.log-box {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  overflow: auto;
  max-height: 480px;
  font-size: 0.8125rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
}
.log-entry { margin-bottom: 0.875rem; }
.log-meta { color: var(--muted); font-size: 0.8125rem; margin-bottom: 0.35rem; }
.preview-image {
  max-width: 100%;
  max-height: 640px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.muted { color: var(--muted); font-size: 0.875rem; }

/* ===== Pager ===== */
.pager-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.25rem;
}
.pager-bar__meta {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.pager-bar__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}
.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}
.pager-size__select {
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.pager-size__select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(236, 106, 78, 0.2);
}
.pager {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}
.pager__btn {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.25rem 0.15rem;
}
.pager__btn:hover { color: var(--brand); }
.pager__btn.is-disabled {
  color: #b2aca9;
  pointer-events: none;
  cursor: default;
}
.pager__range {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
  text-align: center;
}
.section-head--plain {
  padding: 0;
  border: 0;
  background: transparent;
  margin-bottom: 0.75rem;
}
.section-head--plain h2 { margin: 0; }

.hint { color: var(--muted); font-size: 0.875rem; }
.msg { white-space: pre-wrap; max-width: 480px; }
.field-help {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  font-weight: 400;
}

/* ===== Charts / embed ===== */
.embed-section {
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--panel);
}
.grafana-frame {
  width: 100%;
  border: 0;
  background: #fff;
  display: block;
}
.grafana-frame-inline { height: 720px; }
body.embed-page { background: var(--bg); }
body.embed-page .masthead,
body.embed-page .top { margin-bottom: 0; }
.chart-toolbar {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0.5rem 2rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.chart-toolbar a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
}
.chart-toolbar a.on,
.chart-toolbar a:hover {
  background: var(--brand-soft);
  color: var(--brand);
  text-decoration: none;
}
.chart-toolbar .hint { color: var(--brand); font-size: 0.875rem; }
body.embed-page .grafana-frame {
  height: calc(100vh - 114px);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 960px) {
  .masthead,
  .top {
    min-height: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0 1rem;
  }
  .wordmark,
  .brand,
  .masthead__end,
  .top-right {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
  .nav,
  .top-center {
    order: 3;
    flex: 1 0 100%;
    width: 100%;
    overflow-x: auto;
  }
  .nav a,
  .top-center nav a { flex-shrink: 0; }
  .board-grid { grid-template-columns: 1fr; }
  .wrap { padding: 1.5rem 1rem 3rem; }
  .summary, .board-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board-kpis--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grafana-frame-inline { height: 480px; }
  .chart-toolbar { padding: 0.5rem 1rem; }
}
