.password-field { position: relative; display: block; }
.password-field input { width: 100%; padding-right: 48px; }
.password-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 5px; border: 0; background: transparent; color: #647084; cursor: pointer; }
.password-toggle:hover { color: #162033; }
.password-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-page-content { width: min(100%, 520px); }

:root {
  color-scheme: light;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #d7dee8;
  --text: #162033;
  --muted: #647084;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warning: #a16207;
  --danger: #b42318;
  --complete: #315a94;
  --shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.locked { overflow: hidden; }
[hidden] { display: none !important; }
button, input { font: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 86px;
  padding: 18px clamp(16px, 4vw, 44px);
  background: #182235;
  color: #ffffff;
  border-bottom: 1px solid #2b3952;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.logout-button { color: #e5edf7; background: #22304a; border-color: #34445f; }

.login-overlay {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 20px;
  background: rgba(17, 24, 39, 0.72);
}

.login-panel {
  display: grid; width: min(100%, 390px); gap: 16px; padding: 26px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.login-panel h1 { margin-bottom: 4px; color: var(--text); font-size: 26px; }
.login-panel .eyebrow { color: var(--accent-strong); }

.eyebrow {
  margin: 0 0 4px; color: #9fb3c8;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 5vw, 40px); line-height: 1; }
h2 { margin-bottom: 0; font-size: 18px; }
h3 { margin-bottom: 8px; font-size: 16px; }

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  padding: 22px clamp(16px, 4vw, 44px) 44px;
}

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow);
}

.create-panel { align-self: start; padding: 20px; }
.table-panel { min-width: 0; }

.panel-heading {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border);
}

.create-panel .panel-heading { padding: 0 0 18px; }
.form { display: grid; gap: 16px; padding-top: 18px; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }

input {
  width: 100%; min-height: 42px; padding: 10px 11px;
  border: 1px solid #c7d0df; border-radius: 6px;
  color: var(--text); background: #ffffff; outline: none;
}

input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14); }

.inline-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.inline-input span { color: var(--muted); }

.primary-button, .text-button, .danger-button, .icon-button {
  border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 800;
}

.primary-button { min-height: 42px; color: #ffffff; background: var(--accent); }
.primary-button:hover { background: var(--accent-strong); }

.text-button, .danger-button { min-height: 34px; padding: 6px 10px; background: #ffffff; }
.text-button { color: var(--accent-strong); border-color: #9cc9c4; }
.danger-button { color: var(--danger); border-color: #f0b4ae; }

.icon-button {
  display: grid; width: 42px; height: 42px; place-items: center;
  color: #e5edf7; background: #22304a; border-color: #34445f; font-size: 22px;
}

.badge, .status {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 26px; padding: 4px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 800; white-space: nowrap;
}

.badge { color: #115e59; background: #d7f3ef; }
.status-active { color: #115e59; background: #d7f3ef; }
.status-hit { color: var(--warning); background: #fff0c2; }
.status-complete { color: var(--complete); background: #dceafe; }
.status-expired { color: #5f6675; background: #e8edf5; }

.subtle, .message { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.message { min-height: 18px; }
.message.error { color: var(--danger); }

.table-wrap { overflow-x: auto; }

table { width: 100%; min-width: 980px; border-collapse: collapse; }

th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); background: var(--surface-2); font-size: 12px; text-transform: uppercase; }
td { font-size: 14px; }

.url-cell { max-width: 260px; overflow-wrap: anywhere; }
.link-cell { display: grid; gap: 6px; }
.link-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; align-items: start; }
.link-cell a { color: var(--accent-strong); font-weight: 800; overflow-wrap: anywhere; }
.copy-link-button {
  display: grid; width: 28px; height: 28px; place-items: center;
  color: var(--accent-strong); background: #ffffff;
  border: 1px solid #9cc9c4; border-radius: 6px; cursor: pointer;
}

.copy-link-button:hover, .copy-link-button:focus-visible {
  color: #ffffff; background: var(--accent); outline: none;
}

.copy-link-button.copied {
  color: #ffffff; background: var(--complete); border-color: var(--complete);
}

.copy-link-button svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.link-cell a { color: var(--accent-strong); font-weight: 800; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }

.stage-list { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }

.stage-toggle {
  width: fit-content; min-height: 30px; padding: 5px 9px;
  color: var(--accent-strong); background: #ffffff;
  border: 1px solid #9cc9c4; border-radius: 6px;
  cursor: pointer; font: inherit; font-weight: 800;
}

.details-row td { padding: 0; background: #f7fafc; }

.diagnostic-panel { display: grid; gap: 14px; padding: 16px 20px 18px; border-top: 1px solid var(--border); }

.diagnostic-meta { display: flex; flex-wrap: wrap; gap: 10px 18px; color: var(--muted); font-size: 13px; }

.diagnostic-log { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }

.diagnostic-log li {
  display: grid; grid-template-columns: 100px minmax(0, 1fr) 110px;
  gap: 10px; align-items: center; min-height: 36px; padding: 8px 10px;
  background: #ffffff; border: 1px solid var(--border); border-radius: 6px;
}

.stage-id { color: var(--text); font-weight: 800; }
.stage-value { overflow-wrap: anywhere; color: var(--muted); }
.diagnostic-log time { color: var(--muted); font-size: 13px; text-align: right; }

.empty-state { padding: 42px 20px; text-align: center; }
.empty-state p { margin-bottom: 0; color: var(--muted); }

@media (max-width: 920px) { .layout { grid-template-columns: 1fr; } }

@media (max-width: 560px) {
  .topbar { min-height: 76px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .diagnostic-log li { grid-template-columns: 1fr; }
  .diagnostic-log time { text-align: left; }
}
