* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: #f0f2f5;
  font-family: system-ui, sans-serif;
}

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: #fff;
  padding: 2.5rem 2rem;
  border-radius: 10px;
  box-shadow: 0 2px 16px rgba(0,0,0,.1);
  width: 320px;
}

h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: #111;
}

.pack-caption {
  font-size: 1rem;
  color: #444;
  margin-bottom: 1.5rem;
}

input {
  width: 100%;
  padding: .6rem .8rem;
  margin-bottom: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}

input:focus { border-color: #555; }

.login-btn {
  width: 100%;
  padding: .65rem;
  background: #222;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background .15s;
}

.login-btn:hover { background: #444; }

.error {
  color: #c0392b;
  font-size: .875rem;
  margin-bottom: 1rem;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 2rem;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.navbar-nav {
  font-size: .875rem;
  color: #666;
  text-decoration: none;
}

.navbar-nav:hover { color: #111; }

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: #111;
  text-decoration: none;
}

.navbar-brand-debug {
  color: #c0392b;
}

.navbar-logout {
  font-size: .875rem;
  color: #666;
  text-decoration: none;
}

.navbar-logout:hover { color: #111; }

.page {
  width: 100%;
  padding: 2rem 3rem;
}

.hidden { display: none; }

.cmd-bar {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

.cmd-btn {
  padding: .35rem 1rem;
  font-size: .9rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  color: #222;
  cursor: pointer;
}

.cmd-btn:hover { background: #e8e8e8; }

.cmd-btn-disabled {
  color: #aaa;
  border-color: #e0e0e0;
  background: #fafafa;
  cursor: default;
}

.pack-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.pack-header h1 { margin-bottom: .4rem; }

.btn-edit {
  flex-shrink: 0;
  align-self: flex-start;
  width: fit-content;
  margin-top: .2rem;
  padding: .3rem .9rem;
  font-size: .85rem;
  color: #333;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

.btn-edit:hover { background: #e0e0e0; }

.pack-edit-form {
  display: flex;
  flex-direction: column;
  gap: .8rem;
  max-width: 560px;
  margin-bottom: 2rem;
  padding: 1.2rem;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 6px;
}

.pack-edit-form label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .85rem;
  color: #555;
}

.pack-edit-form input,
.pack-edit-form textarea {
  font-size: .95rem;
  padding: .4rem .6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
}

.pack-edit-form textarea { resize: vertical; }

.edit-actions {
  display: flex;
  gap: .6rem;
}

.edit-actions button {
  padding: .35rem .9rem;
  font-size: .9rem;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #ccc;
  background: #f0f0f0;
}

.edit-actions button[type=submit] {
  background: #333;
  color: #fff;
  border-color: #333;
}

.edit-actions button[type=submit]:hover { background: #111; }

.form-error {
  font-size: .875rem;
  color: #c0392b;
}

.pack-list {
  list-style: none;
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.pack-item {
  background: #fff;
  border-radius: 8px;
  padding: 1.2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  gap: .4rem;
  cursor: pointer;
  transition: box-shadow .15s;
}

.pack-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,.15); }

.pack-name {
  font-weight: 600;
  color: #111;
}

.pack-caption {
  color: #666;
  font-size: .875rem;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.task-status {
  font-size: .75rem;
  margin-top: auto;
  min-height: 1.2em;
  vertical-align: middle;
}

.task-status.inqueue {
  color: #2563eb;
  animation: status-pulse 1.6s ease-in-out infinite;
}

.task-status.processing {
  color: #16a34a;
  animation: status-pulse 0.9s ease-in-out infinite;
}

.pack-add {
  border: 2px dashed #ccc;
  background: transparent;
  box-shadow: none;
  align-items: center;
  justify-content: center;
  color: #999;
}

.pack-add:hover {
  border-color: #888;
  color: #444;
  box-shadow: none;
}

.pack-add-icon {
  font-size: 1.8rem;
  line-height: 1;
  font-weight: 300;
}

.creative-item {
  padding: 0;
  overflow: hidden;
  gap: .2rem;
}

.creative-item .pack-name,
.creative-item .pack-caption {
  padding: 0 .8rem;
}

.creative-item .pack-name { padding-top: .25rem; }
.creative-item .pack-caption { padding-bottom: 0; }
.creative-item .task-status { margin-top: 0; min-height: 1em; padding: 0 .8rem .15rem; }

.creative-thumb {
  width: 100%;
  aspect-ratio: 9/16;
  object-fit: cover;
  display: block;
}

.creative-nothumb {
  background: #e0e0e0;
}

/* Creative detail page */

.creative-header {
  padding: 1.5rem 2rem .5rem;
}

.creative-header h1 {
  margin: 0;
}

.creative-header .task-status {
  margin-top: .2rem;
  display: block;
}

.creative-page {
  display: flex;
  gap: 2rem;
  padding: 2rem 3rem;
  min-height: 100vh;
  align-items: flex-start;
}

.creative-left {
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.creative-video {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.params-table td {
  padding: .35rem .5rem;
  border-bottom: 1px solid #e8e8e8;
}

.params-table td:first-child {
  color: #888;
  width: 40%;
}

.creative-prepare {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.creative-move {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.move-select {
  flex: 1;
  padding: .35rem .5rem;
  font-size: .875rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

.move-btn {
  padding: .35rem .9rem;
  font-size: .875rem;
  font-weight: 600;
  background: #f0f0f0;
  color: #222;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.move-btn:hover:not(:disabled) { background: #e0e0e0; }
.move-btn:disabled { opacity: .4; cursor: default; }

.creative-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.lang-tabs {
  display: flex;
  gap: .5rem;
}

.lang-tab {
  width: auto;
  padding: .3rem .9rem;
  background: #e0e0e0;
  color: #444;
  border-radius: 4px;
  font-size: .85rem;
  font-weight: 600;
}

.lang-tab.active {
  background: #222;
  color: #fff;
}

.lang-tab:hover:not(.active) { background: #ccc; }

.lang-content {
  font-family: system-ui, sans-serif;
  font-size: .9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  background: #fff;
  border-radius: 8px;
  padding: 1.2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.hidden { display: none; }

.not-ready {
  color: #999;
  font-style: italic;
}

/* Jobs page */

.jobs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin-top: 1.2rem;
}

.jobs-table col.col-id       { width: 8rem; }
.jobs-table col.col-host     { width: 10rem; }
.jobs-table col.col-caps     { width: 6rem; }
.jobs-table col.col-pid      { width: 5rem; }
.jobs-table col.col-status   { width: 6rem; }
.jobs-table col.col-task     { width: auto; }

.jobs-table th {
  text-align: left;
  padding: .4rem .7rem;
  font-size: .8rem;
  color: #888;
  font-weight: 600;
  border-bottom: 2px solid #e8e8e8;
}

.jobs-table td {
  padding: .5rem .7rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.jobs-id {
  font-family: monospace;
  font-size: .85rem;
  color: #555;
}

.jobs-pid {
  color: #aaa;
  font-size: .85rem;
}

.jobs-desc {
  color: #555;
}

.worker-status {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 3px;
  font-size: .8rem;
  font-weight: 600;
}

.worker-idle {
  background: #e8f5e9;
  color: #2e7d32;
}

.worker-busy {
  background: #fff3e0;
  color: #e65100;
}

.worker-offline {
  background: #f0f0f0;
  color: #999;
}

.no-workers {
  margin-top: 1.2rem;
  color: #999;
  font-style: italic;
}

/* Prepare page */

.prepare-header {
  margin-bottom: 1.5rem;
}

.prepare-body {
  max-width: 780px;
}

.prepare-lead {
  font-size: .95rem;
  color: #444;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.prepare-steps {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin-bottom: 2rem;
}

.prepare-steps td {
  padding: .55rem .7rem;
  border-bottom: 1px solid #e8e8e8;
  vertical-align: middle;
}

.step-num {
  width: 2rem;
  text-align: center;
  color: #aaa;
  font-size: .8rem;
  font-weight: 600;
}

.step-name {
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  width: 11rem;
}

.step-desc {
  color: #555;
}

.step-desc code {
  font-family: monospace;
  font-size: .85rem;
  background: #f0f0f0;
  padding: .1rem .3rem;
  border-radius: 3px;
}

.step-billed .step-name,
.step-billed .step-desc {
  color: #1a1a1a;
}

.step-billed td {
  background: #fffbf0;
}

.billed-badge {
  display: inline-block;
  padding: .15rem .5rem;
  font-size: .75rem;
  font-weight: 700;
  color: #7a4f00;
  background: #fde8a0;
  border-radius: 3px;
  white-space: nowrap;
}

.prepare-options {
  margin-bottom: 1.2rem;
}

.option-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  color: #333;
  cursor: pointer;
}

.option-check input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.prepare-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.prepare-run {
  padding: .45rem 1.4rem;
  font-size: .95rem;
  font-weight: 600;
  background: #222;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.prepare-run:hover { background: #000; }

.prepare-cancel {
  font-size: .9rem;
  color: #666;
  text-decoration: none;
}

.prepare-cancel:hover { color: #111; }

/* Summary page */

.summary-text {
  white-space: pre-wrap;
  font-family: system-ui, sans-serif;
  font-size: .9rem;
  line-height: 1.6;
}

.summary-tab-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .8rem;
}

.section-lang-bar {
  display: flex;
  gap: .4rem;
}

.section-lang-bar.hidden { display: none; }
