:root {
  --primary: #00205b;
  --accent: #00a3e0;
  --bg: #0c1220;
  --panel: #141c2e;
  --text: #eef3fb;
  --muted: #93a0b8;
  --line: #243049;
  --ok: #3dce8b;
  --warn: #e6b35a;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, sans-serif; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--primary);
  border-bottom: 3px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 6px;
  background: var(--accent); color: #041018; font-weight: 800;
  display: grid; place-items: center; letter-spacing: 0.04em;
}
.logo-plate {
  height: 48px;
  min-width: 48px;
  max-width: 168px;
  padding: 6px 10px;
  background: #fff;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.logo-plate img {
  display: block;
  max-height: 36px;
  max-width: 148px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.logo-plate.wide {
  max-width: 220px;
  height: 52px;
}
.logo-plate.wide img {
  max-width: 200px;
  max-height: 40px;
}
.logo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.login-dvs {
  display: flex;
  justify-content: center;
  background: #fff;
  border-radius: 8px;
  padding: 10px 14px;
}
.login-dvs img {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
}
.line-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}
.line-card {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
  padding: 16px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
}
.line-card.active { outline: 2px solid var(--accent); }
.line-card .logo-plate { max-width: 140px; }
.line-name { font-size: 13px; font-weight: 600; }
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 0; color: #c9d7ee; font-size: 13px; }

nav { display: flex; gap: 8px; flex-wrap: wrap; }
nav button, .btn {
  border: 0; border-radius: 6px; padding: 8px 12px; cursor: pointer;
  background: transparent; color: var(--text);
}
nav button.active { background: var(--accent); color: #041018; font-weight: 700; }
.btn.primary {
  background: var(--accent);
  color: #041018;
  font-weight: 800;
  font-size: 16px;
  padding: 12px 22px;
  box-shadow: 0 4px 0 #0a6a90;
  transform: translateY(0);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
  user-select: none;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:active,
.btn.primary.pressed {
  transform: translateY(4px);
  box-shadow: 0 0 0 #0a6a90;
}
.btn.primary:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: translateY(4px);
  box-shadow: 0 0 0 #0a6a90;
}
.btn.ghost { border: 1px solid var(--line); background: var(--panel); }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }
h2 { margin: 0 0 12px; font-size: 20px; }
.muted { color: var(--muted); }
.schedule-warn {
  margin: 0 0 4px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
}
.card.keep { outline: 2px solid var(--accent); }
.card label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.enc { font-weight: 700; }
.tx { color: var(--muted); font-size: 12px; }
.title { margin-top: 6px; font-size: 14px; }
.meta { color: var(--muted); font-size: 12px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.pill { padding: 4px 8px; border-radius: 999px; background: #1c2740; font-size: 12px; }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 600; }
td.ua { color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

form.stack { display: grid; gap: 10px; max-width: 420px; }
input:not([type="checkbox"]), select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #0f1728; color: var(--text);
}
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin-top: 3px;
  accent-color: var(--accent);
  cursor: pointer;
}
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card { width: min(420px, 100%); background: var(--panel); padding: 28px; border-radius: 12px; border: 1px solid var(--line); }
.err { color: #ff8d8d; min-height: 1.2em; }
.reset-row { display: flex; gap: 6px; align-items: center; }
.ship-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.feed { display: grid; gap: 2px; margin-top: 6px; font-size: 12px; }
.feed .note { font-style: italic; }
.feed-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.scripts-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0 16px; }
.scripts-panel summary { cursor: pointer; font-weight: 600; }
.link-row { display: flex; gap: 6px; align-items: center; }
.link-row select { width: 180px; padding: 5px 6px; }
.link-row input { width: 70px; padding: 5px 6px; }
.assign-ship select { width: 140px; padding: 5px 6px; }
.create-script {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 8px 0 16px;
  display: grid;
  gap: 10px;
}
.create-script .enc { margin-bottom: 0; }
.create-script-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.create-script-row input:not([type="checkbox"]),
.create-script-row select {
  width: auto;
  max-width: none;
  padding: 8px 10px;
}
.create-script-row select[name="ship_id"] { width: 220px; }
.create-script-row input[name="srt_port"] { width: 120px; }
.create-script-row input[name="multicast"] { width: 180px; }
.create-script-row input[name="passphrase"] { width: 170px; }
.create-script-row label {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.btn.small { padding: 3px 8px; font-size: 12px; }
select { max-width: 320px; }
.reset-row input { width: 160px; padding: 6px 8px; }
.okmsg { color: var(--ok); }
.apply-status {
  min-height: 1.4em;
  margin: 0 0 12px;
  font-weight: 700;
}
.apply-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(4, 10, 24, 0.78);
  display: grid;
  place-items: center;
  padding: 24px;
}
.apply-overlay[hidden] { display: none; }
.apply-modal {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 460px;
  width: min(460px, 100%);
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.apply-modal h3 {
  margin: 0 0 10px;
  font-size: 22px;
}
.apply-modal p {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
}
.apply-modal .btn.primary { min-width: 120px; }
