:root {
  color-scheme: light;
  --blue: #0875e1;
  --blue-dark: #075eb4;
  --blue-soft: #eaf3ff;
  --ink: #162033;
  --text: #3f4b5e;
  --muted: #5f6b7d;
  --line: #dfe5ec;
  --line-strong: #cdd6e0;
  --surface: #ffffff;
  --surface-soft: #f5f7fa;
  --success: #0f7049;
  --danger: #b42318;
  --shadow: 0 8px 24px rgba(21, 39, 64, 0.08);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body.orbitone-extension {
  width: 420px;
  min-width: 360px;
  min-height: 560px;
  margin: 0;
  color: var(--text);
  background: var(--surface);
  font: 14px/1.45 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.popup-shell {
  min-height: 560px;
  padding: 0 18px 14px;
}

.app-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  height: 66px;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

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

.brand img {
  width: 31px;
  height: 31px;
}

.brand div {
  display: grid;
  line-height: 1.05;
}

.brand span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand strong {
  color: var(--ink);
  font-size: 18px;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.icon-button,
.field-icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.icon-button:hover,
.field-icon-button:hover {
  color: var(--blue);
  border-color: #9ecbfa;
}

.icon-button:focus-visible,
.field-icon-button:focus-visible,
.button:focus-visible,
.segment:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(8, 117, 225, 0.17);
  outline-offset: 1px;
}

.icon-button svg,
.field-icon-button svg {
  width: 17px;
  height: 17px;
}

.icon-button.compact {
  width: 31px;
  height: 31px;
  border: 0;
}

.site-context {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.site-indicator {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(15, 112, 73, 0.1);
}

.site-context div {
  display: grid;
  min-width: 0;
}

.site-context small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.site-context strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-count {
  margin-left: auto;
  padding: 3px 7px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
}

.setup-state {
  display: grid;
  min-height: 360px;
  align-content: center;
  justify-items: center;
  padding: 36px 18px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 8px;
}

.empty-icon svg {
  width: 25px;
  height: 25px;
}

.setup-state h1 {
  margin: 17px 0 5px;
  color: var(--ink);
  font-size: 21px;
}

.setup-state p {
  max-width: 300px;
  margin: 0 0 20px;
  color: var(--muted);
}

.connection-bar {
  display: grid;
  align-items: center;
  margin-bottom: 10px;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
}

.connection-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.connection-bar label svg {
  width: 15px;
  height: 15px;
}

.connection-bar select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 9px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.segmented-tabs {
  display: grid;
  padding: 3px;
  background: #edf1f5;
  border-radius: 7px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segment {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 720;
}

.segment.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 3px rgba(21, 39, 64, 0.1);
}

.segment svg {
  width: 16px;
  height: 16px;
}

.tab-panel {
  padding-top: 13px;
}

.search-form {
  display: grid;
  min-height: 42px;
  align-items: center;
  padding: 0 5px 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
}

.search-form > svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.search-form input {
  min-width: 0;
  padding: 8px 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.results {
  display: grid;
  max-height: 355px;
  margin-top: 11px;
  overflow: auto;
  gap: 8px;
}

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  text-align: center;
}

.credential-card {
  display: grid;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.credential-card.exact {
  border-color: #acd4fb;
}

.credential-copy {
  min-width: 0;
}

.credential-copy h2 {
  overflow: hidden;
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credential-copy p,
.credential-copy small {
  display: block;
  overflow: hidden;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credential-copy small {
  color: #748094;
}

.credential-actions {
  display: grid;
  grid-template-columns: repeat(3, 31px);
  gap: 5px;
}

.credential-actions .icon-button {
  width: 31px;
  height: 31px;
}

.credential-actions .primary-action {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.credential-actions button:disabled {
  cursor: default;
  opacity: 0.38;
}

.credential-security {
  display: grid;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  grid-column: 1 / -1;
  gap: 9px;
}

.security-loading,
.security-error {
  padding: 10px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 5px;
  font-size: 11px;
}

.security-error {
  color: var(--danger);
}

.security-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.security-summary > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.security-summary small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.security-summary strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.age-aging {
  color: #9a6700 !important;
}

.age-old {
  color: var(--danger) !important;
}

.password-health {
  display: grid;
  gap: 4px;
}

.password-health-track {
  display: block;
  height: 5px;
  overflow: hidden;
  background: #e7ebf0;
  border-radius: 3px;
}

.password-health-track > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--danger);
  border-radius: inherit;
  transition: width 160ms ease;
}

.password-health-track > span[data-score="2"] {
  background: #b7791f;
}

.password-health-track > span[data-score="3"],
.password-health-track > span[data-score="4"] {
  background: var(--success);
}

.compact-health small {
  color: var(--muted);
  font-size: 10px;
}

.security-hint {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.security-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
}

.small-button svg {
  width: 14px;
  height: 14px;
}

.rotation-box {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) 31px auto;
  gap: 6px;
}

.rotation-box input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 5px 8px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  font: 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.history-list {
  display: grid;
  max-height: 150px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.history-row {
  display: grid;
  min-height: 42px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  grid-template-columns: minmax(0, 1fr) 31px 31px;
  gap: 5px;
}

.history-row > div {
  display: grid;
  min-width: 0;
}

.history-row code {
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row small {
  color: var(--muted);
  font-size: 9px;
}

.save-form {
  display: grid;
  max-height: 405px;
  overflow: auto;
  padding-right: 2px;
  gap: 10px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.field > span:first-child {
  color: var(--text);
  font-size: 11px;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
}

.field textarea {
  min-height: 58px;
  resize: vertical;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.password-field {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) 34px 34px;
}

.password-field input {
  grid-column: 1 / -1;
  grid-row: 1;
  padding-right: 76px;
}

.password-field .field-icon-button {
  z-index: 1;
  width: 30px;
  height: 30px;
  grid-row: 1;
  border: 0;
}

.password-field .field-icon-button:first-of-type {
  grid-column: 2;
}

.password-field .field-icon-button:last-of-type {
  grid-column: 3;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 720;
}

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

.button-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.button svg {
  width: 17px;
  height: 17px;
}

.full-width {
  width: 100%;
}

.status-line {
  min-height: 24px;
  padding: 8px 1px 0;
  color: var(--muted);
  font-size: 11px;
}

.status-line.error {
  color: var(--danger);
}

.status-line.success {
  color: var(--success);
}

.popup-footer {
  display: flex;
  min-height: 35px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  padding-top: 9px;
  color: #748094;
  border-top: 1px solid var(--line);
  font-size: 10px;
}

.popup-footer span {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popup-footer svg {
  width: 13px;
  height: 13px;
  color: var(--success);
}

@media (max-width: 380px) {
  body.orbitone-extension {
    width: 360px;
    min-width: 360px;
  }

  .popup-shell {
    padding-inline: 14px;
  }
}
