/* ─── KG brand tokens ─────────────────────────────────────────────────────── */
:root {
  --paper:    #F4EFE6;
  --sand:     #E7DCCB;
  --grey:     #9B9286;
  --ink:      #2A2520;
  --oxblood:  #7C3A33;
  --radius:   2px;
  --font:     'Inter', system-ui, sans-serif;
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--oxblood); text-decoration: none; }
a:hover { text-decoration: none; }

/* ─── Public layout ─────────────────────────────────────────────────────────── */
.public-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.kg-monogram { width: 44px; height: 44px; margin-bottom: 2.5rem; }

.public-title {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--grey);
  margin-bottom: 0.5rem;
}

.public-heading {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 1rem;
}

.public-body {
  font-size: 0.9375rem;
  color: var(--grey);
  max-width: 380px;
  margin-bottom: 2.5rem;
  line-height: 1.65;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  transition: opacity 0.15s;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:active { opacity: 0.7; }
.btn-primary  { background: var(--oxblood); color: #fff; }
.btn-secondary { background: var(--sand); color: var(--ink); }
.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-danger { background: #8B1A1A; color: #fff; }

/* ─── Login form ────────────────────────────────────────────────────────────── */
.login-wrap { width: 100%; max-width: 340px; margin: 0 auto; }
.login-wrap form { display: flex; flex-direction: column; gap: 0.75rem; }

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--grey);
  margin-bottom: 0.3rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  font-family: var(--font);
  font-size: 0.9375rem;
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--grey); }
.field textarea { min-height: 120px; resize: vertical; }
.error-msg { font-size: 0.85rem; color: var(--oxblood); margin-top: 0.25rem; }

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--sand);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.footer-legal { font-size: 0.775rem; color: var(--grey); line-height: 1.55; }
.footer-link  { font-size: 0.775rem; color: var(--grey); }

/* ─── Utils ─────────────────────────────────────────────────────────────────── */
.hr { border: none; border-top: 1px solid var(--sand); margin: 2rem 0; }
.label-caps {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey);
}

/* ─── Cabinet layout ────────────────────────────────────────────────────────── */
.cab-layout { display: flex; flex-direction: column; min-height: 100vh; }

.cab-header {
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 52px;
  gap: 1.5rem;
  flex-shrink: 0;
}

.cab-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--paper);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
}
.cab-logo:hover { opacity: 1; text-decoration: none; }

.cab-nav { display: flex; align-items: center; gap: 0.25rem; flex: 1; }

.cab-nav-item {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: rgba(244,239,230,0.6);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  transition: color 0.15s, background 0.15s;
}
.cab-nav-item:hover,
.cab-nav-item.active {
  color: var(--paper);
  background: rgba(244,239,230,0.08);
}

.cab-header-right { display: flex; align-items: center; gap: 1rem; margin-left: auto; }

.lang-toggle {
  display: flex;
  background: rgba(244,239,230,0.08);
  border-radius: var(--radius);
  overflow: hidden;
}

.lang-btn {
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: none;
  background: none;
  color: rgba(244,239,230,0.5);
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s, background 0.15s;
}
.lang-btn.active { background: rgba(244,239,230,0.15); color: var(--paper); }

.cab-username { font-size: 0.8rem; color: rgba(244,239,230,0.5); }

.cab-logout {
  font-size: 0.8rem;
  color: rgba(244,239,230,0.4);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
  transition: color 0.15s;
}
.cab-logout:hover { color: rgba(244,239,230,0.7); }

.cab-main { flex: 1; padding: 2rem 1.5rem; max-width: 960px; width: 100%; margin: 0 auto; }

/* ─── Views ─────────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.section-title { font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em; }

/* ─── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--sand); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--grey);
  padding: 0.625rem 1rem;
  background: var(--sand);
  border-bottom: 1px solid var(--sand);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--sand); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(231,220,203,0.3); }
tbody td { padding: 0.625rem 1rem; color: var(--ink); vertical-align: middle; }

/* ─── Badge ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-a       { background: #E8F5E9; color: #2E7D32; }
.badge-b       { background: #E3F2FD; color: #1565C0; }
.badge-sent    { background: #E8F5E9; color: #2E7D32; }
.badge-error   { background: #FFEBEE; color: #B71C1C; }
.badge-pending { background: var(--sand); color: var(--grey); }

/* ─── Form card ─────────────────────────────────────────────────────────────── */
.form-card { background: #fff; border: 1px solid var(--sand); border-radius: var(--radius); padding: 1.5rem; max-width: 560px; }
.form-card .field { margin-bottom: 1rem; }
.form-card .field:last-child { margin-bottom: 0; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }

.hint { font-size: 0.8rem; color: var(--grey); margin-top: 0.3rem; line-height: 1.5; }

.key-box {
  background: var(--sand);
  border: 1px solid rgba(155,146,134,0.3);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  word-break: break-all;
  line-height: 1.55;
  margin-top: 0.5rem;
}

.check-group { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.check-item { display: flex; align-items: center; gap: 0.35rem; font-size: 0.875rem; }
.check-item input[type="checkbox"] { width: auto; accent-color: var(--oxblood); }

.result-list { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.375rem; }
.result-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 1px solid var(--sand);
  border-radius: var(--radius);
}
.result-row .result-url { flex: 1; word-break: break-all; color: var(--ink); }

.site-meta { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.site-domain-label { font-size: 1.125rem; font-weight: 500; }
.site-credentials { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }

.cred-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--sand);
  color: var(--grey);
}
.cred-pill.configured { background: #E8F5E9; color: #2E7D32; }

.tabs { display: flex; border-bottom: 1px solid var(--sand); margin-bottom: 1.5rem; }
.tab-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--grey);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn.active { color: var(--ink); border-bottom-color: var(--oxblood); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--grey); font-size: 0.9rem; }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 9999; }
.toast {
  padding: 0.625rem 1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideUp 0.2s ease;
}
.toast.toast-error { background: var(--oxblood); }
.toast.toast-ok    { background: #2E7D32; }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.35rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .cab-main { padding: 1rem; }
  .site-credentials { grid-template-columns: 1fr; }
  .cab-username { display: none; }
}
