:root {
  color-scheme: dark;
  --bg: #090d14;
  --panel: #111823;
  --panel-soft: #151e2b;
  --line: #253143;
  --line-soft: rgba(255, 255, 255, .075);
  --text: #edf3fc;
  --muted: #8d9bb0;
  --accent: #42d99c;
  --accent-soft: rgba(66, 217, 156, .12);
  --blue: #5da8ff;
  --danger: #ff6675;
  --warning: #f5c15e;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 14% -18%, rgba(66, 217, 156, .09), transparent 34rem),
    radial-gradient(circle at 94% 2%, rgba(93, 168, 255, .11), transparent 30rem),
    var(--bg);
}

button, input, select { font: inherit; }
a { color: inherit; }
.shell { width: min(1360px, calc(100% - 48px)); margin: 0 auto; }
.inline { display: inline; margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9, 13, 20, .88);
  backdrop-filter: blur(18px);
}

.topbar .shell {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand, .top-actions, .admin-user { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #06100c;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), #a8f4d4);
  box-shadow: 0 10px 28px rgba(66, 217, 156, .2);
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand span { color: var(--muted); font-size: 11px; }
.top-actions { gap: 14px; }
.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid rgba(66, 217, 156, .32);
  border-radius: 999px;
  color: #8ce9c1;
  background: rgba(66, 217, 156, .09);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.settings-button { white-space: nowrap; }
.admin-user { gap: 8px; color: #bec9d9; font-size: 13px; }
.avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #202d3e; color: var(--accent); font-size: 11px; font-weight: 800; }

.main { padding: 38px 0 72px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 27px; }
.hero h1 { margin: 2px 0 7px; font-size: clamp(30px, 4vw, 42px); line-height: 1.08; letter-spacing: -.04em; }
.hero p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.add-button { min-height: 44px; padding-inline: 17px; }
.add-button span { font-size: 19px; line-height: 0; margin-right: 3px; }

.button, button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 13px;
  color: var(--text);
  background: #192333;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}
.button:hover, button:hover { border-color: #475b77; }
.button:active, button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.primary, button.primary { color: #06110c; border-color: transparent; background: linear-gradient(135deg, var(--accent), #a7f0d1); }
.button.quiet, button.quiet { color: var(--muted); background: transparent; }
.button.danger, button.danger { color: var(--danger); background: rgba(255, 102, 117, .08); }
.button.small, button.small { padding: 7px 10px; font-size: 12px; }

.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { display: flex; align-items: center; gap: 14px; min-height: 94px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(17, 24, 35, .82); }
.stat-icon { width: 43px; height: 43px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; font-size: 12px; font-weight: 800; }
.stat-icon.blue { color: var(--blue); background: rgba(93, 168, 255, .12); }
.stat-icon.green { color: var(--accent); background: var(--accent-soft); }
.stat-icon.red { color: var(--danger); background: rgba(255, 102, 117, .1); }
.stat-card span, .stat-card strong { display: block; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { margin-top: 1px; font-size: 25px; line-height: 1.2; }

.panel { border: 1px solid var(--line); border-radius: 15px; background: rgba(17, 24, 35, .94); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { min-height: 75px; padding: 16px 19px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 22px; }
.search { width: min(280px, 100%); position: relative; display: block; }
.search span { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--muted); font-size: 18px; }
.search input { padding-left: 36px; min-height: 38px; }

.table-wrap { overflow-x: auto; }
.task-table { width: 100%; border-collapse: collapse; min-width: 1020px; }
.task-table th { padding: 12px 16px; color: #8290a3; background: rgba(7, 11, 17, .32); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.task-table td { padding: 15px 16px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.task-table tbody tr { transition: background .15s ease; }
.task-table tbody tr:hover { background: rgba(255, 255, 255, .018); }
.task-identity { display: flex; align-items: center; gap: 11px; min-width: 180px; }
.task-logo {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(66, 217, 156, .22);
  border-radius: 11px;
  color: #7ee8bd;
  background: linear-gradient(145deg, rgba(66, 217, 156, .13), rgba(93, 168, 255, .055));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .06em;
  text-align: center;
}
.task-identity > div > strong, .task-identity > div > span, .cell-main, .cell-sub { display: block; }
.task-identity strong { font-size: 13px; }
.task-identity div > span, .cell-sub { margin-top: 2px; color: var(--muted); font-size: 11px; }
.cell-main { color: #cbd5e3; font-size: 12px; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.on { color: var(--accent); background: rgba(66, 217, 156, .1); }
.badge.off { color: var(--muted); background: rgba(141, 155, 176, .1); }
.badge.fail { color: var(--danger); background: rgba(255, 102, 117, .1); }
.actions-col { text-align: right !important; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.icon-button { width: 31px; height: 31px; padding: 0; display: grid; place-items: center; border-radius: 8px; color: #a8b5c8; background: transparent; font-size: 11px; }
.icon-button.run-now { width: auto; min-width: 42px; padding-inline: 8px; color: var(--accent); border-color: rgba(66, 217, 156, .22); }
.icon-button.danger { color: var(--danger); }
.empty { padding: 64px 24px; text-align: center; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 15px; color: var(--accent); background: var(--accent-soft); font-size: 25px; }
.empty strong { display: block; color: var(--text); font-size: 17px; }
.empty p { margin: 5px 0 18px; }
.no-results { padding: 28px; text-align: center; color: var(--muted); }

.flash { margin-bottom: 17px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.flash.success { color: var(--accent); background: var(--accent-soft); }
.flash.error { color: var(--danger); background: rgba(255, 102, 117, .08); }

input, select {
  width: 100%;
  min-height: 41px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: #0d141e;
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(93, 168, 255, .1); }
input:disabled, input:read-only { color: var(--muted); background: #101721; }
input[type="file"] { padding: 7px; }
input[type="file"]::file-selector-button { margin-right: 10px; border: 0; border-radius: 6px; padding: 6px 9px; color: #cbd6e6; background: #223044; cursor: pointer; }
.field { display: grid; align-content: start; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #c4cfde; font-size: 12px; font-weight: 700; }
.field small { color: var(--muted); font-size: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 54px; }
.input-suffix span { position: absolute; right: 10px; top: 50%; translate: 0 -50%; color: var(--muted); font-size: 11px; }
.checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.check { min-height: 64px; padding: 11px; display: flex; align-items: flex-start; gap: 9px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255, 255, 255, .015); cursor: pointer; }
.check input { width: 16px; min-height: 16px; margin-top: 2px; accent-color: var(--accent); }
.check span, .check b, .check small { display: block; }
.check b { color: #cbd5e3; font-size: 11px; }
.check small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.modal { width: min(780px, calc(100% - 28px)); max-height: min(88vh, 900px); margin: auto; padding: 0; border: 1px solid #314157; border-radius: 16px; color: var(--text); background: #111823; box-shadow: 0 30px 110px rgba(0, 0, 0, .7); overflow: hidden; }
.modal::backdrop { background: rgba(3, 6, 10, .76); backdrop-filter: blur(5px); }
.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.modal-head, .modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 20px; }
.modal-head { border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 1px 0 0; font-size: 19px; }
.modal-kicker { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.modal-close { width: 32px; height: 32px; padding: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: 20px; font-weight: 400; }
.modal-body { max-height: calc(88vh - 142px); padding: 20px; overflow-y: auto; }
.modal-foot { border-top: 1px solid var(--line); justify-content: flex-end; background: rgba(8, 12, 18, .3); }
#task-form { position: relative; }
.upload-progress {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 11, 17, .88);
  backdrop-filter: blur(8px);
}
.upload-progress[hidden] { display: none; }
.upload-progress-card {
  width: min(390px, 100%);
  padding: 28px;
  border: 1px solid #314157;
  border-radius: 16px;
  text-align: center;
  background: #111a26;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
}
.upload-spinner {
  width: 45px;
  height: 45px;
  margin: 0 auto 17px;
  border: 3px solid rgba(66, 217, 156, .16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: upload-spin .8s linear infinite;
}
.upload-progress-card h3 { margin: 4px 0 0; font-size: 18px; }
.upload-progress-card p { min-height: 36px; margin: 10px 0 18px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.upload-progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #0a1018; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04); }
.upload-progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #8decc4); transition: width .18s ease; }
.upload-progress-percent { display: block; margin: 9px 0 16px; color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px; }
.upload-progress.is-error .upload-spinner { animation: none; border-color: rgba(255, 102, 117, .25); border-top-color: var(--danger); }
.upload-progress.is-error .modal-kicker, .upload-progress.is-error .upload-progress-percent { color: var(--danger); }
@keyframes upload-spin { to { transform: rotate(360deg); } }
.form-section + .form-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line-soft); }
.section-title { display: flex; gap: 10px; margin-bottom: 14px; }
.section-title > span { width: 23px; height: 23px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; color: var(--accent); background: var(--accent-soft); font-size: 10px; font-weight: 800; }
.section-title h3, .section-title p { margin: 0; }
.section-title h3 { font-size: 13px; }
.section-title p { margin-top: 1px; color: var(--muted); font-size: 10px; }
.detail-modal { width: min(620px, calc(100% - 28px)); }
.settings-modal { width: min(760px, calc(100% - 28px)); }
.settings-note { display: grid; gap: 3px; margin-bottom: 22px; padding: 13px 15px; border: 1px solid rgba(93, 168, 255, .22); border-radius: 10px; background: rgba(93, 168, 255, .07); }
.settings-note strong { color: var(--blue); font-size: 12px; }
.settings-note span { color: var(--muted); font-size: 10px; }
.credential-status { margin-bottom: 14px; padding: 9px 11px; border-radius: 8px; color: var(--warning); background: rgba(245, 193, 94, .08); font-size: 11px; }
.credential-status.configured { color: var(--accent); background: var(--accent-soft); }
.danger-check { border-color: rgba(255, 102, 117, .18); }
.danger-check b { color: var(--danger); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.detail-item { padding: 13px 15px; border-bottom: 1px solid var(--line-soft); }
.detail-item:nth-child(odd) { border-right: 1px solid var(--line-soft); }
.detail-item span, .detail-item strong { display: block; }
.detail-item span { color: var(--muted); font-size: 10px; }
.detail-item strong { margin-top: 3px; font-size: 12px; overflow-wrap: anywhere; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login { width: min(420px, 100%); }
.login .panel-body { padding: 28px; }
.login .brand { margin-bottom: 28px; }
.login h1 { margin: 0 0 7px; font-size: 27px; }
.login p { margin: 0 0 20px; color: var(--muted); }
.login form { display: grid; gap: 14px; }
.login button.primary { margin-top: 4px; }
.setup { padding: 12px; border-radius: 9px; color: var(--warning); background: rgba(245, 193, 94, .08); }

@media (max-width: 850px) {
  .task-list-head { align-items: flex-start; flex-direction: column; }
  .search { width: 100%; }
  .form-grid.three { grid-template-columns: 1fr 1fr; }
  .form-grid.three .field:last-child { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 24px, 1360px); }
  .admin-user { display: none; }
  .version-badge { padding-inline: 7px; }
  .top-actions { gap: 7px; }
  .main { padding-top: 26px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .add-button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 75px; }
  .table-wrap { overflow: visible; }
  .task-table { min-width: 0; }
  .task-table thead { display: none; }
  .task-table, .task-table tbody, .task-table tr, .task-table td { display: block; width: 100%; }
  .task-table tr { padding: 13px; border-top: 1px solid var(--line); }
  .task-table td { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 3px; border: 0; text-align: right; }
  .task-table td::before { content: attr(data-label); color: var(--muted); font-size: 10px; text-align: left; }
  .task-table td:first-child::before { display: none; }
  .task-table td:first-child { justify-content: flex-start; }
  .actions-col { justify-content: flex-end !important; }
  .form-grid, .form-grid.three, .checks { grid-template-columns: 1fr; }
  .form-grid.three .field:last-child { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-item:nth-child(odd) { border-right: 0; }
  .modal-body { padding: 17px; }
}

@media (max-width: 480px) {
  .topbar .shell { flex-wrap: wrap; padding-block: 10px; }
  .top-actions { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .upload-spinner { animation-duration: 1.8s; }
  .upload-progress-track span { transition: none; }
}
