:root {
  --bg: #f3f1eb;
  --card: #fffdf8;
  --ink: #1c1a16;
  --muted: #6d675c;
  --line: #e4ddd0;
  --accent: #0f6e56;
  --accent2: #c45c26;
  --danger: #a33b2b;
  --ok: #1f7a45;
  --shadow: 0 10px 30px rgba(40, 30, 10, 0.08);
  --radius: 14px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #efe6d4 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, #dcebe4 0%, transparent 35%),
    var(--bg);
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card h1 { margin: 0 0 6px; font-size: 1.5rem; }
.login-card label { display: block; margin: 14px 0 6px; font-size: 0.92rem; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
}
.login-card button {
  margin-top: 18px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.layout {
  width: min(1100px, calc(100% - 32px));
  margin: 24px auto 48px;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.top h1 { margin: 0 0 4px; font-size: 1.6rem; }
.muted { color: var(--muted); margin: 0; }
.link { color: var(--accent); text-decoration: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 14px; font-size: 1.1rem; }
.muted-card { background: #faf7f1; }

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.badge.on { background: #dff3e6; color: var(--ok); }
.badge.off { background: #f1e6e3; color: var(--danger); }

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 18px;
}
.grid3 .span2 { grid-column: span 2; }
.k { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 2px; }
.v { font-weight: 600; word-break: break-all; }

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.form-row label { min-width: 56px; color: var(--muted); }
.form-row input,
.form-row select {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
}

.task-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.task-field > label {
  color: var(--muted);
  font-size: 0.92rem;
}
.task-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}
.task-box {
  flex: 1 1 0;
  min-width: 0;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 12px;
  box-sizing: border-box;
  overflow: hidden;
}
.task-box:focus-within {
  border-color: var(--accent);
}
.task-box select,
.task-box input {
  display: block;
  width: 100%;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  line-height: 40px;
  padding: 0;
  margin: 0;
  box-shadow: none;
  vertical-align: middle;
}
.task-box select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236d675c' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  background-size: 12px 8px;
  padding-right: 20px;
}
.task-field .hint {
  margin: 0;
}
@media (max-width: 640px) {
  .task-row {
    flex-direction: column;
  }
}

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.95rem;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.warn { background: var(--accent2); border-color: var(--accent2); color: #fff; }
button.ghost { background: transparent; }
button:hover { filter: brightness(0.97); }
.hint { margin: 12px 0 0; color: var(--muted); font-size: 0.88rem; }

.sched-block { margin-top: 16px; }
.sub-title { margin: 0; font-size: 1rem; }
.sched-wrap { max-height: 280px; margin-top: 10px; }
.sched-table .c-name { width: 22%; }
.sched-table .c-flag { width: 18%; }
.sched-table .c-times { width: 30%; }
.sched-table .c-next { width: 12%; }
.sched-table .c-cd { width: 18%; }
.sched-table tr.dim td { color: var(--muted); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.table-wrap { overflow: auto; max-height: 360px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table,
.shot-table {
  table-layout: fixed;
  width: 100%;
}
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  line-height: 1.35;
}
th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--card);
  white-space: nowrap;
}
.col-time {
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.col-cmd,
.col-status,
.col-result,
.col-size,
.col-link,
.col-act {
  white-space: nowrap;
}
.col-task,
.col-msg,
.col-cmd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-size,
.col-status,
.col-result,
.col-link,
.col-act {
  text-align: center;
}
.col-act { width: 56px; }
.empty-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 18px 10px !important;
}

.queue-table .c-time { width: 28%; }
.queue-table .c-cmd { width: 16%; }
.queue-table .c-task { width: 36%; }
.queue-table .c-status { width: 20%; }

.result-table .c-time { width: 26%; }
.result-table .c-cmd { width: 28%; }
.result-table .c-result { width: 14%; }
.result-table .c-msg { width: 32%; }

.ok { color: var(--ok); }
.fail { color: var(--danger); }

.toast {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #e8f5ef;
  color: var(--ok);
}
.toast.err { background: #f8e8e4; color: var(--danger); }
.err {
  background: #f8e8e4;
  color: var(--danger);
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
}

code {
  background: #efe9df;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}
ol { margin: 0; padding-left: 1.2rem; color: var(--muted); line-height: 1.7; }

.shot-grid {
  overflow: auto;
  max-height: 420px;
}
.shot-grid table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.shot-table .c-time { width: 30%; }
.shot-table .c-task { width: 34%; }
.shot-table .c-size { width: 12%; }
.shot-table .c-link { width: 12%; }
.shot-table .c-act { width: 12%; }
.shot-grid th,
.shot-grid td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.shot-grid th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
  white-space: nowrap;
}
.shot-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.shot-page-info {
  color: var(--muted);
  font-size: 0.88rem;
}
.danger-btn {
  border: 0 !important;
  background: transparent !important;
  color: var(--danger) !important;
  padding: 0 !important;
  font-size: 0.85rem !important;
  line-height: 1.2 !important;
  height: auto !important;
  min-height: 0 !important;
  box-shadow: none !important;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.danger-btn:hover {
  filter: none;
  opacity: 0.75;
}
.shot-table tr.row-unread td {
  color: var(--danger);
  font-weight: 600;
}
.shot-table tr.row-unread td .muted {
  color: #c45a5a;
}
.shot-table tr.row-unread .link {
  color: var(--danger);
}
.pool-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pool-mode-fields[hidden],
.form-row[hidden] {
  display: none !important;
}
.pool-table td:last-child {
  white-space: nowrap;
}
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 28, 0.45);
}
.modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.18);
}
.modal-card h3 {
  margin: 0;
  font-size: 1.1rem;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 860px) {
  .two-col, .grid3 { grid-template-columns: 1fr; }
  .grid3 .span2 { grid-column: auto; }
  .form-row { flex-direction: column; align-items: stretch; }
}
