:root {
  --bg: #f5f7fb;
  --fg: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
.job-info {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

  --primary-soft: rgba(37, 99, 235, 0.08);
  --danger: #dc2626;
  --danger-600: #b91c1c;
  --ok: #047857;
  --warn: #92400e;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070c1b;
    --fg: #e2e8f0;
    --muted: #94a3b8;
    --border: #1f2937;
    --border-strong: #334155;
    --card: #0f172a;
    --primary: #3b82f6;
    --primary-600: #2563eb;
    --primary-soft: rgba(59, 130, 246, 0.12);
    --danger: #ef4444;
    --danger-600: #dc2626;
    --ok: #22c55e;
    --warn: #f97316;
    --shadow: 0 20px 48px rgba(2, 6, 23, 0.45);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}

a:hover,
a:focus {
  text-decoration: underline;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: radial-gradient(circle at 0% 0%, rgba(37, 99, 235, 0.14), transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(15, 23, 42, 0.12), transparent 50%);
}

.app-header {
  background: linear-gradient(135deg, #1d4ed8 0%, #0f172a 70%);
  color: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
  position: sticky;
  top: 0;
  z-index: 1400;
  height: 101px;
  overflow: visible;
}


.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  flex-wrap: nowrap;
  gap: 18px;
  align-items: center;
  min-height: 101px;
  height: 101px;
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.brand-logo-img {
  height: 147px;
  width: auto;
  vertical-align: middle;
  margin: -52px 0;
  padding: 0;
}

.brand-logo {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-logo:hover,
.brand-logo:focus {
  opacity: 0.9;
}

.brand-tagline {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.1;
  white-space: nowrap;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  margin-left: auto;
}

.nav-auth {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nav-user {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
}

.main-nav .nav-link,
.main-nav .nav-button {
  font-weight: 600;
}

.nav-button {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  padding: 6px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.nav-button:hover,
.nav-button:focus {
  background: rgba(255, 255, 255, 0.26);
  transform: translateY(-1px);
}

.nav-button:focus {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

.nav-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.35);
}

.main-nav .nav-language-select {
  background: rgba(15, 23, 42, 0.35);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  padding: 6px 12px;
  font-weight: 600;
  min-width: 130px;
  cursor: pointer;
}

@media (max-width: 920px) {
  .header-inner {
    flex-wrap: wrap;
    padding: 18px 20px;
  }

  .main-nav {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px;
    margin-left: 0;
  }

  .nav-divider {
    display: none;
  }

  .brand {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .brand-tagline {
    width: 100%;
    margin-top: 4px;
    white-space: normal;
  }
}

.main-nav .nav-language-select:focus {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

.main-nav .nav-language-select option {
  color: #0f172a;
}

.nav-link {
  position: relative;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.02em;
  padding-bottom: 4px;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.45);
  opacity: 0;
  transform: scaleX(0.5);
  transform-origin: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-link:hover::after,
.nav-link:focus::after,
.nav-link.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.nav-link.is-active {
  color: #fff;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 38px 28px 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.app-notice {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 22px 28px;
}

.app-notice-warning {
  border-color: rgba(146, 64, 14, 0.28);
  background: rgba(146, 64, 14, 0.08);
}

@media (prefers-color-scheme: dark) {
  .app-notice-warning {
    border-color: rgba(249, 115, 22, 0.38);
    background: rgba(249, 115, 22, 0.12);
  }
}

.app-notice-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.app-notice-heading {
  margin: 0 0 6px 0;
  font-size: 18px;
  font-weight: 600;
}

.app-notice-text p {
  margin: 0 0 14px 0;
  font-size: 15px;
}

.app-notice-dismiss {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.app-notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
  align-items: center;
}

@media (min-width: 768px) {
  .app-notice-body {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }
  .app-notice-actions {
    justify-content: flex-end;
  }
}

.main-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.control-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 0 0 320px;
  position: sticky;
  top: 96px;
  align-self: flex-start;
  height: fit-content;
}

.content-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.control-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  justify-content: flex-start;
}

.control-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px 20px;
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--muted);
}

.field span {
  font-weight: 600;
  color: var(--fg);
}

.field-remote {
  display: flex;
  align-items: center;
  gap: 14px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--fg);
}

.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.input-select,
.input-number,
.input-text {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  padding: 9px 12px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  font-size: 0.95rem;
  font-weight: 500;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-select:focus,
.input-number:focus,
.input-text:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.input-number {
  max-width: 140px;
}

#status {
  margin-top: -4px;
}

.status {
  margin: 0;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.status.error {
  border-color: var(--danger);
  color: var(--danger);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.layer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.layer:hover,
.layer:focus-within {
  transform: none;
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.layer .meta,
.meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.layer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}

.layer-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.14);
}

.layer-badge-remote {
  color: #b45309;
  border-color: rgba(234, 179, 8, 0.5);
  background: rgba(234, 179, 8, 0.12);
}

.layer-badge-theme {
  color: var(--primary-600);
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.12);
}

.layer-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--primary-soft);
  color: var(--primary-600);
}

.layer-title-icon.theme {
  color: var(--ok);
  border-color: rgba(37, 99, 235, 0.35);
}

.layer-title-icon.wmts {
  color: var(--primary-600);
}

.layer-title-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  background: #e2e8f0;
  color: #0f172a;
}

.btn:hover,
.btn:focus {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-600);
}

.btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover,
.btn-outline:focus {
  background: var(--primary);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover,
.btn-danger:focus {
  background: var(--danger-600);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.btn-icon:hover,
.btn-icon:focus {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-icon:disabled {
  background: var(--card);
  color: var(--muted);
  border-color: var(--border);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.delete-cache-container {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.delete-cache-container.has-cache {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.35);
}

.btn-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}

@keyframes btn-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.jobs {
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.jobs-heading {
  font-weight: 700;
  margin-bottom: 10px;
}

.job {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px dashed var(--border-strong);
}

.job[data-trigger="timer"] {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
}

.job:first-child {
  border-top: none;
}

.job .info {
  font-size: 0.85rem;
  color: var(--muted);
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--muted);
}

.progress-bar {
  position: relative;
  width: 120px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--primary);
}

.project-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px 20px;
  margin: 0 0 20px 0;
  box-shadow: var(--shadow);
}

.project-block.is-collapsed {
  padding-bottom: 16px;
  margin-bottom: 12px;
}

.project-block.is-collapsed > :not(.project-heading) {
  display: none;
}

.project-heading {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 14px 0;
}

.project-toggle {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  font-size: 1.1rem;
  padding: 0;
  cursor: pointer;
  flex: 1 1 auto;
  text-align: left;
}

.project-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
  border-radius: 12px;
}

.project-toggle .toggle-caret {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  color: var(--muted);
}

.project-block.is-collapsed .project-toggle .toggle-caret {
  transform: rotate(-90deg);
}

.project-toggle .project-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.project-toggle .heading-icon {
  flex-shrink: 0;
}

.heading-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.muted {
  color: var(--muted);
}

.schedule-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2400;
  padding: 18px;
}

.schedule-backdrop[data-open="1"] {
  display: flex;
}

.schedule-dialog {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.3);
  padding: 24px;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}

.schedule-dialog h2 {
  margin: 0 0 14px 0;
  font-size: 1.2rem;
}

.schedule-dialog fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.schedule-dialog .schedule-section {
  margin: 14px 0;
}

.schedule-dialog .frequency-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.schedule-dialog .day-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.schedule-dialog .day-grid label {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 0.8rem;
  cursor: pointer;
}

.schedule-dialog .day-grid input {
  margin: 0;
}

.schedule-dialog .yearly-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-dialog .yearly-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.schedule-dialog select,
.schedule-dialog input[type="time"],
.schedule-dialog input[type="number"],
.schedule-dialog input[type="text"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 6px;
}

.schedule-dialog .yearly-row select {
  flex: 1;
}

.schedule-dialog .yearly-row input[type="number"] {
  width: 80px;
}

.schedule-dialog .yearly-row input[type="time"] {
  width: 110px;
}

.schedule-dialog .error {
  color: var(--danger);
  font-size: 0.8rem;
  min-height: 18px;
}

.schedule-dialog .actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.recache-dialog .dialog-description {
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.recache-dialog .dialog-note {
  margin-top: 4px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--muted);
}

.recache-dialog .dialog-grid {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.recache-dialog .dialog-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recache-dialog label {
  font-size: 0.9rem;
  font-weight: 600;
}

.app-footer {
  margin-top: auto;
  background: rgba(15, 23, 42, 0.92);
  color: rgba(255, 255, 255, 0.82);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 600;
}

.footer-links a:hover,
.footer-links a:focus {
  opacity: 0.85;
}

.viewer-header .header-inner {
  padding: 18px 28px;
}

.viewer-header .brand-logo {
  font-size: 20px;
}

.viewer-header .brand-tagline {
  font-size: 13px;
  color: rgba(226, 232, 240, 0.7);
}

.viewer-footer .footer-inner {
  padding: 18px 28px;
}

.viewer-footer .footer-brand {
  font-size: 13px;
}

.viewer-footer .footer-links a {
  font-weight: 500;
}

@media (max-width: 900px) {
  .header-inner {
    padding: 20px;
    flex-direction: column;
    align-items: flex-start;
  }

  .main-nav {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .nav-divider {
    display: none;
  }

  .main-nav .nav-language-select {
    width: 100%;
    max-width: 220px;
  }

  .main-layout {
    flex-direction: column;
  }

  .control-panel {
    padding: 22px;
    position: static;
    max-height: none;
    overflow: visible;
    width: 100%;
    flex: 1 1 auto;
  }

  .control-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .input-number {
    max-width: 100%;
  }

  .content-panel {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-main {
    padding: 28px 18px 48px;
  }

  .brand-logo {
    font-size: 1.6rem;
  }

  .control-panel {
    padding: 20px;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .layer {
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }
}
