/* ============================================================
   Monitoring — tema, tata letak, dan komponen
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --bg-soft: #eceef1;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --border: #e4e7eb;
  --border-strong: #d3d8de;
  --text: #16191d;
  --text-muted: #667085;
  --text-subtle: #98a1ad;
  --accent: #0f9b6c;
  --accent-strong: #0b7d56;
  --accent-soft: #e6f5ee;

  --ok: #12a06a;
  --ok-bg: #e4f6ed;
  --ok-fg: #0c7a50;
  --warn: #d38b0b;
  --warn-bg: #fdf2df;
  --warn-fg: #9a6407;
  --down: #d94a41;
  --down-bg: #fdeceb;
  --down-fg: #b0332c;
  --idle: #98a1ad;
  --idle-bg: #eef0f3;
  --idle-fg: #6b7480;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.18);
  --radius: 14px;
  --radius-sm: 9px;
  --titlebar-h: 48px;
  --font: "Segoe UI Variable Display", "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #101317;
  --bg-soft: #14181d;
  --surface: #181c22;
  --surface-2: #1e232a;
  --border: #272d35;
  --border-strong: #333b45;
  --text: #e9ecf0;
  --text-muted: #97a1ad;
  --text-subtle: #6f7986;
  --accent: #2bb684;
  --accent-strong: #34c894;
  --accent-soft: #14342a;

  --ok: #2bb684;
  --ok-bg: #12332a;
  --ok-fg: #61d3a8;
  --warn: #e0a032;
  --warn-bg: #362a14;
  --warn-fg: #efc074;
  --down: #ec6259;
  --down-bg: #3a1e1d;
  --down-fg: #f79289;
  --idle: #6f7986;
  --idle-bg: #22272e;
  --idle-fg: #97a1ad;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

/* Aturan `display` di bawah lebih kuat daripada UA stylesheet untuk [hidden],
   jadi atribut hidden harus ditegaskan ulang. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

svg {
  display: block;
}

.spacer {
  flex: 1;
}

.no-drag {
  -webkit-app-region: no-drag;
}

/* ------------------------------------------------------------ bilah judul */

.titlebar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--titlebar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 150px 0 16px; /* ruang untuk tombol jendela bawaan Windows */
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
  z-index: 40;
}

.titlebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.titlebar__logo {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(160deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.titlebar__logo svg {
  width: 15px;
  height: 15px;
}

.titlebar__title {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.titlebar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------------------------------------------------------------- tombol */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.06s ease;
  -webkit-app-region: no-drag;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn__icon svg,
.btn [data-icon] svg {
  width: 15px;
  height: 15px;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn--ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn--icon {
  width: 32px;
  padding: 0;
  justify-content: center;
  color: var(--text-muted);
  border-color: transparent;
}

.btn--icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--danger {
  background: var(--down);
  border-color: var(--down);
  color: #fff;
}

.btn--danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--down-fg);
}

.btn--danger-ghost:hover {
  background: var(--down-bg);
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-strong);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------------ area */

.app {
  height: 100%;
  padding: calc(var(--titlebar-h) + 20px) 24px 40px;
  overflow-y: auto;
  overflow-x: hidden;
}

.app::-webkit-scrollbar,
.drawer__body::-webkit-scrollbar,
.modal__body::-webkit-scrollbar {
  width: 10px;
}

.app::-webkit-scrollbar-thumb,
.drawer__body::-webkit-scrollbar-thumb,
.modal__body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 6px;
}

.section-label {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* --------------------------------------------------------------- ringkasan */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stat__label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.stat__value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat__meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-subtle);
}

.stat--ok .stat__value {
  color: var(--ok-fg);
}
.stat--warn .stat__value {
  color: var(--warn-fg);
}
.stat--down .stat__value {
  color: var(--down-fg);
}

/* ------------------------------------------------------------------ grup */

.group {
  margin-bottom: 28px;
}

.group__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.group__head .section-label {
  margin: 0;
}

.group__count {
  font-size: 11px;
  color: var(--text-subtle);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

/* ----------------------------------------------------------------- kartu */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card--disabled {
  opacity: 0.62;
}

.card__top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.card__dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--idle);
}

.card--ok .card__dot {
  background: var(--ok);
}
.card--warn .card__dot {
  background: var(--warn);
}
.card--down .card__dot {
  background: var(--down);
}

.card--down .card__dot,
.card--checking .card__dot {
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 currentColor;
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.card__name {
  font-weight: 620;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__latency {
  flex: none;
  font-size: 12.5px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.card__badge {
  margin-left: auto;
  flex: none;
}

.card__detail {
  margin-top: 7px;
  padding-left: 18px;
  font-size: 12.8px;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card--down .card__detail {
  color: var(--down-fg);
}

.card__spark {
  margin-top: 12px;
  padding-left: 18px;
  height: 18px;
}

.card__spark svg {
  width: 100%;
  height: 18px;
}

.spark__bar--ok {
  fill: var(--ok);
  opacity: 0.55;
}
.spark__bar--warn {
  fill: var(--warn);
  opacity: 0.75;
}
.spark__bar--down {
  fill: var(--down);
  opacity: 0.85;
}

.card__actions {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.card:hover .card__actions {
  opacity: 1;
  transform: none;
}

.card__actions .btn--icon {
  width: 28px;
  height: 28px;
}

/* ------------------------------------------------------------------ pill */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--idle-bg);
  color: var(--idle-fg);
  white-space: nowrap;
}

.pill--ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.pill--warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.pill--down {
  background: var(--down-bg);
  color: var(--down-fg);
}

.pill--summary {
  -webkit-app-region: no-drag;
}

/* ---------------------------------------------------------------- kosong */

.empty {
  max-width: 520px;
  margin: 60px auto;
  text-align: center;
}

.empty__art {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 22px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.empty__art svg {
  width: 36px;
  height: 36px;
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.empty p {
  margin: 0 0 22px;
  color: var(--text-muted);
  line-height: 1.6;
}

.empty__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* -------------------------------------------------------------- aktivitas */

.events__list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.event {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.event:last-child {
  border-bottom: 0;
}

.event__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--idle);
}

.event--ok .event__dot {
  background: var(--ok);
}
.event--warn .event__dot {
  background: var(--warn);
}
.event--down .event__dot {
  background: var(--down);
}

.event__name {
  font-weight: 570;
}

.event__detail {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event__time {
  margin-left: auto;
  flex: none;
  color: var(--text-subtle);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- panel */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.32);
  z-index: 45;
  animation: fade 0.16s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: slide-in 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

.drawer__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 16px 14px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer__title {
  font-size: 16px;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.drawer__sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

.drawer__foot {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
  font-size: 13px;
  margin: 0 0 18px;
}

.kv dt {
  color: var(--text-muted);
}

.kv dd {
  margin: 0;
  word-break: break-word;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.metric__label {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric__value {
  margin-top: 3px;
  font-size: 17px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.chart {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 18px;
}

.chart svg {
  width: 100%;
  height: 72px;
}

.chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart__area {
  fill: var(--accent);
  opacity: 0.12;
}

.chart__empty {
  font-size: 12.5px;
  color: var(--text-subtle);
  text-align: center;
  padding: 18px 0;
}

/* ---------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: rgba(16, 24, 40, 0.42);
  animation: fade 0.16s ease;
}

.modal__card {
  width: min(720px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal__card--narrow {
  width: min(520px, 100%);
}

@keyframes pop {
  from {
    transform: scale(0.97) translateY(8px);
    opacity: 0;
  }
}

.modal__head {
  display: flex;
  align-items: center;
  padding: 18px 16px 14px 22px;
  border-bottom: 1px solid var(--border);
}

.modal__head h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 640;
  letter-spacing: -0.01em;
  flex: 1;
}

.modal__body {
  padding: 20px 22px;
  overflow-y: auto;
}

.modal__lead {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.modal__body .section-label {
  margin-top: 22px;
}

.modal__body .section-label:first-child {
  margin-top: 0;
}

/* ------------------------------------------------------- pemilihan jenis */

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.type-card {
  display: flex;
  gap: 11px;
  padding: 14px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.08s ease;
}

.type-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.type-card__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.type-card__icon svg {
  width: 18px;
  height: 18px;
}

.type-card--fonnte .type-card__icon {
  background: #e7f8ee;
  border-color: #cdeddb;
  color: #128c4a;
}
.type-card--brevo .type-card__icon {
  background: #e8f1fd;
  border-color: #d2e3fb;
  color: #1c64c4;
}
.type-card--cloudflare .type-card__icon {
  background: #fdf0e3;
  border-color: #f7dfc4;
  color: #c1741a;
}
.type-card--website .type-card__icon {
  background: #eeecfd;
  border-color: #dedafb;
  color: #5b4bd0;
}
.type-card--http .type-card__icon {
  background: #e9f6f8;
  border-color: #d2ecf0;
  color: #16808f;
}
.type-card--tcp .type-card__icon {
  background: #f0f1f4;
  border-color: #e2e4e9;
  color: #5b6472;
}
.type-card--import .type-card__icon {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent-strong);
}

.type-card__title {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.35;
}

.type-card__desc {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 570;
}

.type-chip svg {
  width: 15px;
  height: 15px;
}

.form__typebar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

/* -------------------------------------------------------------- formulir */

.field {
  display: block;
  margin-bottom: 14px;
}

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 570;
  color: var(--text);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.field textarea {
  height: auto;
  min-height: 76px;
  padding: 9px 11px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field__hint {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-subtle);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form__actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.form__actions--inline {
  margin-top: 4px;
}

/* ------------------------------------------------------------- switch    */

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 14px;
  font-size: 13px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch__track {
  flex: none;
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.16s ease;
}

.switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.switch input:checked + .switch__track {
  background: var(--accent);
}

.switch input:checked + .switch__track .switch__thumb {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch__track {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --------------------------------------------------------- hasil uji     */

.test-result {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-top: 4px;
}

.test-result--ok {
  background: var(--ok-bg);
  border-color: transparent;
  color: var(--ok-fg);
}
.test-result--warn {
  background: var(--warn-bg);
  border-color: transparent;
  color: var(--warn-fg);
}
.test-result--down {
  background: var(--down-bg);
  border-color: transparent;
  color: var(--down-fg);
}

.test-result svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
}

.test-result__title {
  font-weight: 600;
}

.test-result__detail {
  margin-top: 2px;
  opacity: 0.92;
}

/* -------------------------------------------------------- daftar device  */

.device-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.device {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.device:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.device input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.device__name {
  font-weight: 570;
  font-size: 13.5px;
}

.device__meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.device__badge {
  margin-left: auto;
}

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 70vw;
  padding: 11px 16px;
  border-radius: 11px;
  background: #1b1f26;
  color: #f3f5f7;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast--error {
  background: var(--down);
}

.toast svg {
  width: 16px;
  height: 16px;
  flex: none;
}

@keyframes toast-in {
  from {
    transform: translate(-50%, 12px);
    opacity: 0;
  }
}

/* ------------------------------------------------------------ responsif  */

@media (max-width: 900px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.spin svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   Layar masuk (mode web/PWA)
   ============================================================ */

.login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login__card {
  width: min(360px, 100%);
  padding: 30px 26px 26px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

.login__logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 15px;
  background: linear-gradient(160deg, var(--accent), var(--accent-strong));
}

.login__card h1 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.login__card p {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

.login__input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.login__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login__submit {
  width: 100%;
  height: 40px;
  justify-content: center;
}

.login__error:not(:empty) {
  margin-top: 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--down-bg);
  color: var(--down-fg);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ============================================================
   Tata letak layar kecil (HP / PWA)
   ============================================================ */

@media (max-width: 720px) {
  .titlebar {
    padding: 0 10px 0 12px; /* tanpa tombol jendela bawaan */
    gap: 8px;
  }

  .titlebar__title {
    display: none; /* logo + pill sudah cukup */
  }

  .titlebar__actions {
    gap: 4px;
  }

  /* Tombol jadi ikon saja agar muat (span ikon tetap tampil) */
  .titlebar__actions .btn span:not(.btn__icon):not([data-icon]) {
    display: none;
  }

  .titlebar__actions .btn {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .pill--summary {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    line-height: 22px;
  }

  .app {
    padding: calc(var(--titlebar-h) + 14px) 14px calc(32px + env(safe-area-inset-bottom));
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 20px;
  }

  .stat__value {
    font-size: 22px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  /* Tidak ada hover di layar sentuh: tombol aksi selalu tampak,
     dan diletakkan pada barisnya sendiri agar tidak menutupi badge status. */
  .card__actions {
    position: static;
    opacity: 1;
    transform: none;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 10px;
    background: transparent;
  }

  .card__actions .btn--icon {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--surface-2);
  }

  .card:hover {
    transform: none;
  }

  /* Panel detail menjadi lembar bawah */
  .drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 88vh;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    animation: sheet-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .drawer__foot {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  @keyframes sheet-in {
    from {
      transform: translateY(28px);
      opacity: 0;
    }
  }

  /* Dialog memenuhi layar */
  .modal {
    padding: 0;
    place-items: stretch;
  }

  .modal__card,
  .modal__card--narrow {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: 0;
    border-radius: 0;
  }

  .modal__foot {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .type-grid {
    grid-template-columns: 1fr;
  }

  .metric-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .metric__value {
    font-size: 15px;
  }

  .kv {
    grid-template-columns: 118px 1fr;
  }

  .event__detail {
    display: none; /* ruang sempit: cukup nama + waktu */
  }

  /* Sasaran sentuh lebih besar */
  .btn {
    height: 38px;
  }

  .field input[type="text"],
  .field input[type="password"],
  .field input[type="number"],
  .field select {
    height: 42px;
    font-size: 16px; /* cegah iOS auto-zoom saat fokus */
  }
}

@media (display-mode: standalone) {
  /* Terpasang di layar utama: beri ruang untuk status bar sistem */
  .titlebar {
    height: calc(var(--titlebar-h) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  .app {
    padding-top: calc(var(--titlebar-h) + env(safe-area-inset-top) + 14px);
  }
}

/* Kode sebaris pada teks bantuan */
.field__hint code,
.modal__lead code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
}

#cronCommand {
  font-size: 11.5px;
  word-break: break-all;
}
