:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #172033;
  --muted: #647184;
  --line: #d8e0ea;
  --line-strong: #c3cfdd;
  --blue: #2367d1;
  --blue-soft: #e8f1ff;
  --green: #16784c;
  --green-soft: #e8f6ef;
  --red: #b42318;
  --red-soft: #fff0ee;
  --amber: #946200;
  --amber-soft: #fff4d6;
  --shadow: 0 18px 42px rgba(16, 24, 40, 0.13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Noto Sans KR", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.45rem;
  font-weight: 750;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  font-weight: 750;
}

h3 {
  margin-bottom: 0;
  font-size: 0.92rem;
  font-weight: 750;
}

.capture-shell {
  display: grid;
  gap: 4px;
  min-height: 100vh;
  padding: 4px 18px 18px;
}

.topbar,
.topbar-actions,
.panel-head,
.section-head,
.modal-head,
.modal-head-actions,
.form-actions,
.execution-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.panel-head,
.section-head,
.modal-head {
  justify-content: space-between;
}

.topbar {
  min-height: 34px;
}

.topbar-actions {
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.jobs-panel,
.daily-panel,
.preview-panel,
.execution-panel,
.notification-box,
.alert {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.jobs-panel,
.daily-panel,
.alert {
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
}

.panel-head,
.section-head,
.modal-head {
  min-height: 58px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}

.section-head.compact {
  min-height: auto;
  padding: 0 0 12px;
  border-bottom: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #174ea6;
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}

.status-pill.subtle {
  background: #edf1f6;
  color: var(--muted);
}

.status-pill.good {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.warn {
  background: var(--red-soft);
  color: var(--red);
}

.method-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.method-puppeteer {
  background: #e8f6ef;
  color: #16784c;
}

.method-playwright {
  background: #f0ecff;
  color: #5b3bb8;
}

.method-selenium {
  background: #fff4d6;
  color: #946200;
}

.method-apiflash {
  background: #e8f1ff;
  color: #174ea6;
}

.method-screenshotone {
  background: #e4f7f7;
  color: #147070;
}

.muted,
.empty {
  color: var(--muted);
}

.alert {
  padding: 12px 14px;
  color: var(--red);
  background: var(--red-soft);
  font-weight: 650;
}

.primary,
.ghost,
.danger,
.icon-button {
  min-height: 38px;
  border-radius: 7px;
  font-weight: 750;
}

.primary,
.ghost,
.danger {
  padding: 8px 13px;
}

.mini {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 0.78rem;
}

.primary {
  background: var(--blue);
  color: #ffffff;
}

.primary:hover {
  background: #1857b9;
}

.ghost {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--ink);
}

.ghost:hover {
  background: var(--panel-soft);
}

.danger {
  background: var(--red-soft);
  color: var(--red);
}

.danger:hover {
  background: #ffe1dc;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--ink);
}

.table-wrap {
  position: relative;
  width: 100%;
  overflow: auto;
}

.jobs-table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
}

.jobs-table th,
.jobs-table td {
  padding: 9px 7px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.jobs-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fc;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-align: inherit;
  text-transform: inherit;
}

.sort-button:hover {
  color: var(--ink);
}

.sort-button.sorted {
  color: var(--blue);
}

.sort-indicator {
  min-width: 28px;
  color: var(--blue);
  font-size: 0.62rem;
  font-weight: 850;
  line-height: 1;
}

.jobs-table tbody tr {
  background: #ffffff;
}

.jobs-table tbody tr:hover,
.jobs-table tbody tr.selected {
  background: #f2f7ff;
}

.active-column {
  width: 78px;
  text-align: center;
}

.active-toggle {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
}

.actions-column {
  width: 208px;
}

.job-title-cell {
  width: 300px;
  min-width: 300px;
  max-width: 300px;
}

.job-title-cell strong,
.job-title-cell small {
  display: block;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.job-title-cell small,
.last-run-cell small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.last-run-cell {
  min-width: 150px;
}

.schedule-cell,
.channels-cell {
  line-height: 1.35;
}

.schedule-cell {
  font-size: calc(1rem - 3pt);
}

.channels-cell {
  font-size: 0.76rem;
}

.schedule-frequency-cell {
  min-width: 88px;
  text-align: center;
}

.jobs-table th:nth-child(4) {
  text-align: center;
}

.jobs-table th:nth-child(4) .sort-button {
  justify-content: center;
}

.schedule-time-cell {
  min-width: 86px;
}

.schedule-date-cell {
  min-width: 126px;
}

.channels-cell {
  min-width: 132px;
}

.channel-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.channel-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 21px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: inherit;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}

.channel-email {
  background: #eef2ff;
  color: #3949ab;
}

.channel-telegram {
  background: #e5f6ff;
  color: #06719f;
}

.channel-slack {
  background: #f5e9ff;
  color: #7c2d92;
}

.last-run-time {
  display: grid;
  gap: 2px;
  line-height: 1.2;
}

.table-actions {
  min-width: 208px;
}

.table-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-empty {
  padding: 36px 14px;
  color: var(--muted);
  text-align: center;
}

.daily-form,
.job-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 15px;
}

.daily-form {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.daily-head-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.daily-panel.daily-collapsed .section-head {
  min-height: 40px;
  padding: 7px 12px;
  border-bottom: 0;
}

.daily-panel.daily-collapsed .eyebrow {
  margin-bottom: 1px;
}

.daily-panel.daily-collapsed .daily-toggle-btn,
.daily-panel.daily-collapsed .toggle-row {
  min-height: 28px;
}

.daily-form button {
  align-self: end;
}

.job-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
  padding: 12px 14px 10px;
}

.job-form > label,
.job-form fieldset {
  gap: 4px;
}

.job-form > label > input,
.job-form > label > select,
.job-form > label > textarea,
.crop-grid input,
.notification-grid input,
.notification-grid select,
.notification-grid textarea {
  min-height: 34px;
  padding: 7px 9px;
}

.job-form > label > textarea {
  min-height: 64px;
}

.wide {
  grid-column: 1 / -1;
}

label,
fieldset {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span,
legend,
.preview-meta,
#previewMeta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
}

input[readonly][data-credential-display="1"],
textarea[readonly][data-credential-display="1"] {
  border-color: #bfd1e8;
  background: #f3f7fc;
  color: #40536b;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #75a7ff;
  box-shadow: 0 0 0 3px rgba(35, 103, 209, 0.14);
  outline: 0;
}

textarea {
  resize: vertical;
}

.toggle-row {
  display: inline-flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.credential-toggle {
  min-height: 40px;
  align-self: end;
  justify-content: flex-start;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(68px, 1fr));
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.day-grid legend {
  padding: 0 4px;
}

.day-grid label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 0.82rem;
}

.day-grid input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.crop-grid,
.notification-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.notification-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.notification-box {
  padding: 10px;
  background: #fbfcfe;
  box-shadow: none;
}

.channel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.channel-list {
  display: grid;
  gap: 8px;
}

.channel-card {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.channel-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.load-slack-btn {
  align-self: end;
}

.form-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.job-form .form-actions {
  gap: 8px;
}

.job-form .form-actions .primary,
.job-form .form-actions .ghost,
.job-form .form-actions .danger {
  min-height: 34px;
  padding: 7px 11px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.job-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, 100%);
  max-height: min(92vh, 980px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-head {
  background: #ffffff;
}

.job-modal .modal-head {
  min-height: 50px;
  padding: 10px 14px;
}

.modal-scroll {
  overflow: auto;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 10px;
  padding: 0 14px 12px;
}

.job-modal .panel-head,
.job-modal .section-head {
  min-height: 46px;
  padding: 10px 12px;
}

.job-modal .section-head.compact {
  min-height: auto;
  padding: 0 0 8px;
}

.preview-panel,
.execution-panel {
  overflow: hidden;
  box-shadow: none;
}

.preview-frame {
  display: grid;
  place-items: center;
  min-height: 260px;
  max-height: 440px;
  overflow: auto;
  padding: 9px;
  background: #eef3f8;
}

.preview-frame img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
}

.preview-crop-surface {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.preview-crop-surface .preview-image {
  display: block;
  max-width: 100%;
  height: auto;
  pointer-events: none;
}

.crop-selection {
  position: absolute;
  border: 2px solid var(--blue);
  border-radius: 5px;
  background: rgba(35, 103, 209, 0.16);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.18);
  pointer-events: none;
}

.preview-frame p,
.empty {
  margin: 0;
}

.execution-list {
  display: grid;
  gap: 7px;
  max-height: 360px;
  overflow: auto;
  padding: 10px;
}

.execution-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.execution-card small {
  color: var(--muted);
}

.execution-card a {
  color: var(--blue);
  font-weight: 750;
  text-decoration: none;
}

@media (max-width: 980px) {
  .daily-form,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .job-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .daily-form button {
    align-self: stretch;
  }
}

@media (max-width: 720px) {
  .capture-shell {
    padding: 12px;
  }

  .topbar,
  .topbar-actions,
  .panel-head,
  .section-head,
  .modal-head,
  .modal-head-actions,
  .daily-head-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .job-form,
  .crop-grid,
  .notification-grid,
  .day-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 0;
  }

  .job-modal {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .form-actions,
  .table-action-buttons {
    align-items: stretch;
    flex-direction: column;
  }

  .primary,
  .ghost,
  .danger {
    width: 100%;
  }
}
