:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #1f2523;
  --muted: #66706d;
  --line: #dce3df;
  --line-strong: #c5d0ca;
  --primary: #117865;
  --primary-strong: #0a5f50;
  --danger: #b73a35;
  --danger-soft: #fff0ef;
  --warn: #a86408;
  --success: #18724c;
  --shadow: 0 16px 40px rgba(26, 37, 32, .12);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #111;
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

.brand-row h1,
.topbar h1 {
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.brand-row p,
.meta-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.field input,
.field select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.field input {
  height: 40px;
  padding: 0 12px;
}

.field select {
  height: 40px;
  padding: 0 10px;
}

textarea {
  min-height: 128px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 120, 101, .12);
}

.auth-actions,
.modal-actions,
.top-actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.auth-message {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
}

.btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.btn:hover {
  border-color: #99aaa2;
  background: #f9fbfa;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
}

.btn.danger {
  border-color: #dfb0ad;
  color: var(--danger);
  background: var(--danger-soft);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.app-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.workspace {
  flex: 1;
  min-width: 0;
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
}

.toolbar {
  min-height: 48px;
  flex-wrap: wrap;
  padding: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
}

.toolbar-spacer {
  flex: 1;
  min-width: 16px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(96px, 1fr));
  gap: 10px;
}

.stats-row div {
  min-height: 54px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
}

.stats-row span {
  color: var(--muted);
  font-size: 12px;
}

.stats-row strong {
  font-size: 20px;
  line-height: 1;
}

.table-shell {
  min-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
}

.pagination {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.page-summary {
  color: var(--muted);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.page-size select,
.page-current input {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.page-size select {
  width: 76px;
  padding: 0 8px;
}

.page-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.page-current input {
  width: 64px;
  padding: 0 8px;
  text-align: center;
}

table {
  width: 100%;
  min-width: 1420px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  height: 38px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf3f0;
  color: #35413d;
  font-weight: 700;
}

tbody tr:hover {
  background: #f8fbfa;
}

tbody tr.is-selected {
  background: #e9f5f2;
}

.select-col {
  width: 42px;
  text-align: center;
}

.index-col {
  width: 62px;
}

.url-col {
  width: 260px;
  max-width: 260px;
}

.clip {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

.sec-clip {
  max-width: 360px;
}

.empty {
  height: 180px;
  text-align: center;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  justify-content: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #f6f8f7;
  color: var(--muted);
  font-size: 12px;
}

.status-success {
  border-color: #b8d8ca;
  background: #edf9f3;
  color: var(--success);
}

.status-failed {
  border-color: #ebc0bc;
  background: var(--danger-soft);
  color: var(--danger);
}

.status-running {
  border-color: #e4c892;
  background: #fff7e7;
  color: var(--warn);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(27, 35, 32, .42);
}

.modal {
  width: min(620px, 100%);
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 16px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal h2 {
  font-size: 18px;
}

.search-modal {
  width: min(560px, 100%);
}

.search-fields {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr);
  gap: 12px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.context-menu {
  position: fixed;
  z-index: 30;
  width: 190px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.menu-section {
  padding: 4px 0;
}

.menu-section + .menu-section {
  border-top: 1px solid var(--line);
}

.menu-title {
  padding: 5px 8px 3px;
  color: var(--muted);
  font-size: 12px;
}

.menu-item {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.menu-item:hover,
.menu-parent:hover > .menu-item,
.menu-parent:focus-within > .menu-item {
  background: #eef5f2;
}

.menu-item.danger {
  color: var(--danger);
}

.menu-separator {
  height: 1px;
  margin: 5px 0;
  background: var(--line);
}

.menu-parent {
  position: relative;
}

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

.submenu-arrow {
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.submenu {
  position: absolute;
  top: -6px;
  left: calc(100% - 1px);
  display: none;
  width: 190px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.menu-parent:hover > .submenu,
.menu-parent:focus-within > .submenu {
  display: block;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(440px, calc(100vw - 36px));
  padding: 10px 12px;
  border-radius: 8px;
  background: #1f2523;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    padding: 14px;
    flex-direction: column;
  }

  .workspace {
    padding: 10px;
  }

  .stats-row {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .pagination {
    align-items: stretch;
  }

  .page-actions {
    width: 100%;
  }

  .search-fields {
    grid-template-columns: 1fr;
  }

  .toolbar-spacer {
    display: none;
  }
}
