:root {
  color-scheme: light;
  --bg: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --line: #d8e1df;
  --text: #17211f;
  --muted: #66736f;
  --accent: #0f766e;
  --accent-2: #e2b645;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 18px 50px rgba(19, 34, 31, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1080px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

body.auth-locked .app-shell {
  display: none;
}

body:not(.auth-locked) .auth-screen {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

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

.auth-brand {
  margin-bottom: 18px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tabs button {
  background: #e8efed;
  color: var(--text);
}

.auth-tabs button.active {
  background: var(--accent);
  color: #fff;
}

.auth-card label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-card button[type="submit"] {
  width: 100%;
  margin-top: 16px;
}

.auth-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-weight: 700;
}

button,
input,
textarea {
  font: inherit;
}

button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #115e59;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button.secondary {
  background: #e8efed;
  color: var(--text);
}

button.danger {
  width: 34px;
  height: 34px;
  padding: 0;
  background: #fff0ee;
  color: var(--danger);
}

button.danger-wide {
  background: #fff0ee;
  color: var(--danger);
}

button.danger-wide:hover {
  background: #ffdeda;
}

input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
}

textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  border-color: var(--accent);
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfdfc;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: linear-gradient(135deg, #124a5f, #1c8477);
  color: #fff;
  font-weight: 900;
  font-size: 20px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h2 {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
}

.brand p,
.topbar p,
label,
.run-status,
.empty,
.site-domain,
.meta {
  color: var(--muted);
}

.panel,
.log-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(19, 34, 31, 0.05);
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 15px;
}

.panel label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
}

.panel button[type="submit"] {
  width: 100%;
  margin-top: 14px;
}

.panel-head,
.topbar,
.query-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-head span {
  min-width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #edf4f2;
  color: var(--accent);
  font-weight: 800;
}

.site-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.site-item {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.site-item.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.site-main {
  min-width: 0;
  cursor: pointer;
}

.site-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.site-domain {
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.workspace {
  padding: 22px;
  min-width: 0;
}

.topbar {
  min-height: 78px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar h2 {
  font-size: 22px;
}

.actions {
  display: flex;
  gap: 10px;
}

.query-tools {
  margin: 16px 0;
}

#keywordForm {
  display: grid;
  grid-template-columns: minmax(320px, 620px) 150px;
  gap: 10px;
}

.run-status {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
  font-weight: 700;
}

.bulk-panel {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.progress-panel {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.progress-meta span,
.progress-query {
  color: var(--muted);
  font-weight: 700;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8efed;
}

#progressFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.progress-query,
.progress-activity {
  margin-top: 9px;
  min-height: 20px;
}

.progress-activity {
  color: var(--accent);
}

#bulkKeywordForm {
  display: grid;
  grid-template-columns: 1fr 170px;
  gap: 10px;
  align-items: start;
}

#bulkKeywordForm button {
  height: 88px;
}

.table-wrap {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: #3e4a47;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  height: 58px;
}

.query-col {
  width: 34%;
}

.url-col {
  width: 24%;
}

.position {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 28px;
  border-radius: 6px;
  background: #eef8f3;
  color: var(--ok);
  font-weight: 900;
}

.position.empty-pos {
  background: #f3f5f5;
  color: #87918e;
}

.position.error-pos {
  background: #fff0ee;
  color: var(--danger);
}

.url-link {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
  text-decoration: none;
}

.meta {
  margin-top: 4px;
  font-size: 12px;
}

.empty {
  display: none;
  padding: 36px;
  text-align: center;
}

.empty.visible {
  display: block;
}

.log-panel {
  margin-top: 16px;
  padding: 16px;
}

.log-panel pre {
  min-height: 92px;
  max-height: 180px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #17211f;
  color: #dce8e5;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}
