
:root {
  --primary-blue: #0066ff;
  --primary-blue-hover: #0052cc;
  --primary-blue-soft: #e8f1ff;
  --light-bg: #f4f7fb;
  --light-card: #ffffff;
  --light-card-hover: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --success-green: #00d4aa;
  --success-soft: #e6faf5;
  --warning-orange: #ff6b35;
  --danger-red: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-card: 0 8px 32px rgba(15, 23, 42, 0.08);
  --shadow-button: 0 4px 16px rgba(0, 102, 255, 0.22);
  --sidebar-width: 260px;
  --radius: 3px;
  --radius-sm: 2px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: "Geologica", sans-serif;
  background: var(--light-bg);
  color: var(--text-primary);
  line-height: 1.5;
}

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

img { max-width: 100%; display: block; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all .2s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0066ff 0%, #0052cc 100%);
  color: #fff;
  box-shadow: var(--shadow-button);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 102, 255, 0.35);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--primary-blue);
  background: var(--light-card-hover);
}

.btn-success { background: var(--success-green); color: #fff; }
.btn-danger { background: var(--danger-red); color: #fff; }
.btn-block { width: 100%; }

/* Cards */
.card {
  background: var(--light-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  transition: border-color .2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}
textarea.form-control { min-height: 110px; resize: vertical; }
.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 46px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: var(--radius-sm);
}
.password-toggle:hover { color: var(--text-primary); }
.password-toggle img {
  width: 20px;
  height: 20px;
  display: block;
  opacity: .72;
  pointer-events: none;
}
.password-toggle:hover img { opacity: 1; }

/* Alerts */
.flash-wrap { margin-bottom: 16px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
}
.flash-success { background: var(--success-soft); color: #047857; border: 1px solid #a7f3d0; }
.flash-danger { background: var(--danger-soft); color: #b91c1c; border: 1px solid #fecaca; }
.flash-warning { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-approved { background: var(--success-soft); color: #047857; }
.badge-rejected { background: var(--danger-soft); color: #b91c1c; }

/* Public layout */
.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
}
.public-logo img { height: 40px; width: auto; max-width: 200px; object-fit: contain; }
.public-nav { display: flex; gap: 12px; align-items: center; }

.hero {
  padding: 56px 0 40px;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 32px;
  align-items: center;
}
.hero h1 {
  font-size: 2.6rem;
  line-height: 1.15;
  margin-bottom: 16px;
}
.hero p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 24px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-card);
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 24px;
}
.price-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: transform .2s, box-shadow .2s;
}
.price-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
}
.price-type { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.price-value { font-size: 2rem; font-weight: 700; color: var(--primary-blue); }
.price-note { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

.auth-wrap {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-card);
}
.auth-card .logo { height: 52px; width: auto; max-width: 260px; margin: 0 auto 12px; object-fit: contain; }
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header p { color: var(--text-secondary); font-size: 14px; }

/* Cabinet layout — sidebar like screenshot */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
}
.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-brand img { height: 36px; width: auto; max-width: 168px; margin-bottom: 8px; object-fit: contain; }
.sidebar-brand p {
  font-size: 12px;
  color: var(--text-secondary);
}
.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  width: 100%;
}
.nav-item svg { width: 18px; height: 18px; stroke: var(--text-secondary); }
.nav-item:hover {
  background: var(--primary-blue-soft);
  color: var(--primary-blue);
}
.nav-item.active {
  background: var(--primary-blue-soft);
  color: var(--primary-blue);
  border-left-color: var(--primary-blue);
}
.nav-item.active svg { stroke: var(--primary-blue); }

.nav-badge {
  margin-left: auto;
  background: var(--danger-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.sidebar-admin .sidebar-brand {
  background: linear-gradient(180deg, #f8fbff 0%, #fff 100%);
}

.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 12px 0 20px;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 28px 32px 40px;
  min-width: 0;
}
.page-header { margin-bottom: 24px; }
.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-header .subtitle::before {
  content: "";
  width: 36px;
  height: 3px;
  background: var(--primary-blue);
  border-radius: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  gap: 14px;
  align-items: center;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-blue-soft);
  color: var(--primary-blue);
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-number { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--text-secondary); }

.table-card { overflow: hidden; }
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.data-table tr:hover td { background: #fafcff; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.public-footer {
  padding: 24px 0 40px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 560px) {
  .public-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 0;
  }
  .public-nav {
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 8px;
  }
  .public-nav .btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
    padding: 10px 14px;
    font-size: 13px;
  }
  .hero {
    padding: 36px 0 28px;
  }
  .hero h1 {
    font-size: 2rem;
  }
  .price-grid {
    grid-template-columns: 1fr;
  }
  .auth-card {
    padding: 24px 18px;
  }
}

@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  .price-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; padding: 20px 16px; }
}

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
}

.history-list { display: flex; flex-direction: column; gap: 0; }
.history-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
}
.history-item:last-child { border-bottom: none; }
.history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.history-time {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 72px;
}
.history-body { font-size: 14px; color: var(--text-secondary); }

.copy-key {
  position: relative;
  display: inline-block;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  border: 1px dashed transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-primary);
  transition: border-color .15s;
  user-select: none;
  vertical-align: middle;
  white-space: nowrap;
}
.copy-key::after {
  content: '';
  position: absolute;
  inset: -1px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
  font-family: "Geologica", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.copy-key:hover {
  border-color: var(--primary-blue);
}
.copy-key:hover::after {
  content: 'Копировать';
  opacity: 1;
  background: var(--primary-blue-soft);
  color: var(--primary-blue);
  border: 1px dashed var(--primary-blue);
}
.copy-key--copied,
.copy-key.copy-key--copied {
  border-color: var(--success-green);
}
.copy-key--copied::after,
.copy-key.copy-key--copied::after {
  content: 'Скопировано';
  opacity: 1;
  background: var(--success-soft);
  color: #047857;
  border: 1px solid var(--success-green);
}
.copy-key--copied:hover::after,
.copy-key.copy-key--copied:hover::after {
  content: 'Скопировано';
}

.object-detail { max-width: 760px; }
.detail-grid { display: grid; gap: 0; }
.detail-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.detail-row dd {
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
}
@media (max-width: 560px) {
  .detail-row { grid-template-columns: 1fr; gap: 4px; }
}

.filter-bar {
  margin-bottom: 20px;
  padding: 16px 20px;
}
.filter-bar__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-end;
}
.custom-select {
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 320px;
}
.custom-select__wrap {
  position: relative;
}
.custom-select__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.custom-select__trigger:hover,
.custom-select.is-open .custom-select__trigger {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}
.custom-select__value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.custom-select__chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: transform .15s;
}
.custom-select.is-open .custom-select__chevron {
  transform: rotate(180deg);
}
.custom-select__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  max-height: 240px;
  overflow-y: auto;
  display: none;
}
.custom-select.is-open .custom-select__menu {
  display: block;
}
.custom-select__option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}
.custom-select__option:hover {
  background: var(--primary-blue-soft);
  color: var(--primary-blue);
}
.custom-select__option.is-active {
  background: var(--primary-blue-soft);
  color: var(--primary-blue);
  font-weight: 600;
}

.stats-grid--cash {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.stats-grid--live {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 520px;
}
.stat-card--compact {
  padding: 16px 14px;
  gap: 0;
}
.stat-card--compact .stat-number {
  font-size: 1.35rem;
}
.stat-card--compact .stat-label {
  font-size: 12px;
}

@media (max-width: 1100px) {
  .stats-grid--cash {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 720px) {
  .stats-grid--cash {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-bar__grid {
    flex-direction: column;
    align-items: stretch;
  }
  .custom-select {
    max-width: none;
  }
}
@media (max-width: 480px) {
  .stats-grid--cash {
    grid-template-columns: 1fr;
  }
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.zone-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zone-row {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 180px) 40px;
  gap: 8px;
  align-items: center;
}
.zone-row .zone-remove {
  padding: 10px 0;
  min-width: 40px;
}

.zone-key-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.zone-key-item {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1.2fr) minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid var(--border-color);
}
.zone-add-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
}

.admin-zone-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-zone-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0 0;
  border-top: 1px dashed var(--border-color);
}
.admin-zone-actions {
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .zone-row,
  .zone-add-form,
  .zone-key-item {
    grid-template-columns: 1fr;
  }
}

/* Registration wizard */
[hidden] { display: none !important; }
.reg-steps { display:flex; gap:12px; margin:0 0 24px; justify-content:space-between; }
.reg-step { display:flex; align-items:center; gap:8px; color:#64748b; font-size:14px; }
.reg-step span { display:grid; place-items:center; width:28px; height:28px; border-radius:50%; background:#e2e8f0; }
.reg-step.is-active { color:#0059dd; font-weight:600; }
.reg-step.is-active span, .reg-step.is-done span { background:#0059dd; color:white; }
.reg-nav { display:flex; gap:12px; margin-top:20px; }
.reg-nav .btn { flex:1; }
.form-label-row { display:flex; gap:12px; align-items:baseline; justify-content:space-between; margin-bottom:8px; }
.link-btn { border:0; background:transparent; color:#0059dd; font:inherit; font-size:13px; cursor:pointer; padding:4px 0; }
.link-btn:disabled { color:#64748b; cursor:default; }
.form-error { color:#b42318; font-size:14px; margin:12px 0; }
.form-hint.is-ok { color:#157347; }
@media(max-width:480px) { .reg-steps { gap:6px; } .reg-step { font-size:12px; gap:4px; } .form-label-row { flex-wrap:wrap; gap:4px; } }
