:root {
  --bg: #f5f1eb;
  --surface: #ffffff;
  --text: #201a16;
  --muted: #756b62;
  --line: #e5ddd4;
  --primary: #5b3a29;
  --primary-2: #7a513a;
  --danger: #9b2c2c;
  --ok: #247a4d;
  --warn: #a36500;
  --shadow: 0 12px 30px rgba(42, 29, 18, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  line-height: 1.7;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
  direction: ltr;
}
.brand-title { font-weight: 800; font-size: 18px; }
.brand-subtitle { color: var(--muted); font-size: 12px; direction: ltr; }
.nav { display: flex; flex-wrap: wrap; gap: 8px; }
.nav a {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.container { width: min(1280px, calc(100% - 32px)); margin: 24px auto; }
.footer {
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  direction: ltr;
  font-size: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.narrow { max-width: 860px; margin-left: auto; margin-right: auto; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.hero h1, h1, h2 { margin-top: 0; }
.hero p { color: var(--muted); max-width: 760px; }
.hero-actions, .live-actions, .form-actions, .download-list, .inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.grid { display: grid; gap: 18px; }
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat .label { display: block; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 24px; direction: ltr; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 15px;
  background: #fff;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }

.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 6px; }
.form-row label { font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: right; vertical-align: middle; }
th { background: #faf7f3; font-weight: 800; }
.actions { display: flex; gap: 10px; }
.badge { display: inline-flex; padding: 3px 10px; border-radius: 99px; background: #eee; font-size: 12px; font-weight: 800; }
.status-running { background: #e7f6ee; color: var(--ok); }
.status-finished { background: #eef0f6; color: #334; }
.status-idle { background: #fff5e1; color: var(--warn); }

canvas {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdfb;
}
.logbox {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  max-height: 260px;
  overflow: auto;
  background: #181513;
  color: #f6eee6;
  border-radius: 16px;
  padding: 14px;
}
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); font-weight: 800; }
.kv dd { margin: 0; }
.download-list a {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
}
.recommendation {
  border-right: 4px solid var(--primary);
  background: #fbf7f2;
  padding: 12px;
  border-radius: 12px;
}
.muted { color: var(--muted); }
.ltr { direction: ltr; text-align: left; }

@media (max-width: 920px) {
  .topbar, .hero, .section-head { align-items: flex-start; flex-direction: column; }
  .cards-3, .cards-4, .two-panels, .two-col, .three-col { grid-template-columns: 1fr; }
  .container { width: min(100% - 20px, 1280px); margin-top: 12px; }
  .card { padding: 16px; border-radius: 18px; }
  .footer { flex-direction: column; }
}
