:root {
  --bg: #0b0f14;
  --card: #141a22;
  --card2: #1a222d;
  --border: #273141;
  --text: #eef2f7;
  --muted: #8b98a8;
  --accent: #3d8bfd;
  --accent2: #2dd4a8;
  --danger: #f07178;
  --warn: #e6b450;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100%;
}
body {
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

#app { max-width: 720px; margin: 0 auto; padding: 12px 14px 40px; }

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.muted { color: var(--muted); font-size: 13px; }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 {
  margin: 0 0 10px;
  font-size: 16px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat {
  background: var(--card2);
  border-radius: 12px;
  padding: 12px;
}
.stat .n {
  font-size: 22px;
  font-weight: 700;
}
.stat .l {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: 600;
}
.field { margin-bottom: 12px; }
input[type="text"],
input[type="number"],
input[type="search"],
textarea,
select {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  outline: none;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
}
.btn.danger { background: var(--danger); }
.btn.success { background: var(--accent2); color: #062018; }
.btn.block { width: 100%; }
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.row > .grow { flex: 1 1 auto; min-width: 0; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.item .title {
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-word;
}
.item .meta {
  font-size: 12px;
  color: var(--muted);
}
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #243044;
  color: #c5d0de;
  margin-right: 4px;
}
.badge.on { background: rgba(45, 212, 168, 0.15); color: var(--accent2); }
.badge.off { background: rgba(240, 113, 120, 0.15); color: var(--danger); }
.badge.tag { background: rgba(61, 139, 253, 0.15); color: #8cbcff; }
.badge.st-done { background: rgba(45, 212, 168, 0.15); color: var(--accent2); }
.badge.st-running { background: rgba(61, 139, 253, 0.15); color: #8cbcff; }
.badge.st-scheduled { background: rgba(230, 180, 80, 0.15); color: var(--warn); }
.badge.st-failed, .badge.st-cancelled { background: rgba(240, 113, 120, 0.15); color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.chip.active {
  background: rgba(61, 139, 253, 0.2);
  border-color: var(--accent);
  color: #cfe2ff;
}

.check-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card2);
}
.check-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.check-item:last-child { border-bottom: none; }
.check-item input { margin-top: 3px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
  z-index: 50;
  max-width: 90%;
  font-size: 14px;
}
.toast.hidden, .hidden { display: none !important; }
.toast.err { background: #7f1d1d; }

.auth-error {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.auth-error .box {
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
}
.auth-error h1 { font-size: 18px; margin: 0 0 10px; }
.auth-error p { color: var(--muted); margin: 0 0 8px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  font-size: 14px;
}

.seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.seg button {
  flex: 1 1 auto;
  min-width: 70px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--muted);
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.seg button.active {
  background: rgba(61, 139, 253, 0.18);
  border-color: var(--accent);
  color: #fff;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: -4px;
  margin-bottom: 10px;
}

.progress {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 999px;
  transition: width .3s ease;
}

.preview-box {
  background: var(--card2);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
}
.preview-box .msg {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}
.media-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.media-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: #0f141b;
  border: 1px solid var(--border);
}
.media-video {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  background: #1a2330;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.confirm-banner {
  background: rgba(230, 180, 80, 0.12);
  border: 1px solid rgba(230, 180, 80, 0.35);
  color: #f0d78c;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  font-weight: 600;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-head {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0;
}
.cal-cell {
  min-height: 52px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  font-size: 11px;
}
.cal-cell.empty { opacity: 0.35; }
.cal-cell .d { font-weight: 700; margin-bottom: 2px; }
.cal-cell .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin: 1px;
}
.cal-cell.has { border-color: var(--accent); }
.step-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.step-bar span {
  flex: 1;
  text-align: center;
  font-size: 11px;
  padding: 6px;
  border-radius: 8px;
  background: var(--card2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.step-bar span.on {
  background: rgba(61, 139, 253, 0.2);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}
