/* Servipay — стили. Светлая и тёмная темы. */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --text: #1a2233;
  --text-muted: #66708a;
  --border: #dde2ec;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e8effd;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --success: #16a34a;
  --mark-bg: #fff1a8;
  --mark-text: inherit;
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .18);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #171e2e;
    --surface-2: #1e2740;
    --text: #e6eaf3;
    --text-muted: #8b94ab;
    --border: #2b3450;
    --accent: #4f83f7;
    --accent-hover: #6b97f9;
    --accent-soft: #1c2a4a;
    --danger: #f26b6b;
    --danger-soft: #3a1f24;
    --mark-bg: #7a6414;
    --mark-text: #fff;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любой авторский display (например, flex) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Экран входа ---------- */

#view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo { font-size: 40px; margin-bottom: 8px; }

.login-card h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: -.02em;
}

.login-subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.login-card form { text-align: left; }

.login-card label,
#editor label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

.login-card input,
#editor input,
#editor textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.login-card input:focus,
#editor input:focus,
#editor textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Кнопки ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .15s, color .15s, opacity .15s;
  white-space: nowrap;
}

.btn:disabled { opacity: .6; cursor: default; }

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

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-block { width: 100%; margin-top: 20px; }

.form-error {
  margin-top: 12px;
  padding: 9px 12px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  font-size: 13.5px;
}

/* ---------- Шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.01em;
}

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

.user-name {
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ---------- Панель поиска ---------- */

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  font: inherit;
  font-size: 15.5px;
  padding: 11px 38px 11px 40px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box input::-webkit-search-cancel-button { display: none; }

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
}

.search-clear:hover { background: var(--surface-2); color: var(--text); }

.stats {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 2px 10px;
  min-height: 18px;
}

/* ---------- Список компаний ---------- */

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.card-title mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  border-radius: 3px;
  padding: 0 1px;
}

.card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: background .15s, color .15s;
}

.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.card-details {
  margin: 10px 0 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.card-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.copy-btn {
  background: var(--accent-soft);
  color: var(--accent);
}

.copy-btn:hover { background: var(--accent); color: #fff; }

/* ---------- Пустые состояния ---------- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state p { margin: 0 0 16px; font-size: 15px; }

/* ---------- Диалог ---------- */

dialog {
  border: none;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  padding: 24px 26px;
  width: min(560px, calc(100vw - 40px));
}

dialog::backdrop {
  background: rgba(10, 15, 30, .5);
  backdrop-filter: blur(2px);
}

dialog h2 {
  margin: 0 0 6px;
  font-size: 19px;
  letter-spacing: -.01em;
}

#editor textarea {
  resize: vertical;
  min-height: 160px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: toast-in .18s ease-out;
}

.toast.error { background: var(--danger); color: #fff; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Адаптивность ---------- */

@media (max-width: 560px) {
  .toolbar { flex-direction: column; }
  .card-head { flex-direction: column; }
  .card-actions { align-self: flex-end; }

  /* Шрифт >= 16px, иначе iOS Safari автоматически зумит страницу при фокусе */
  .login-card input,
  #editor input,
  #editor textarea,
  .search-box input {
    font-size: 16px;
  }
}
