/* ==========================================================================
   Padoj — universal, bog'liqliksiz dizayn tizimi.
   Brend rangi logotipdan (rasm.png) olingan:
     asosiy yashil  #3C8934 · to'q  #2F7128 / #235A1E
     och yashil     #649C5C · #A2C39D
     krem           #F2F7F1 · oltin #C19D51
   Telefon, planshet va kompyuterda ishlaydi. Yorug' va qorong'i rejim.
   ========================================================================== */

:root {
  /* Brend */
  --brand: #3c8934;
  --brand-2: #2f7128;
  --brand-deep: #235a1e;
  --brand-light: #649c5c;
  --brand-50: #eef5ec;
  --brand-100: #dcebd7;
  --brand-200: #c3ddbc;
  --gold: #c19d51;
  --cream: #f2f7f1;

  /* Yuza va matn */
  --surface: #ffffff;
  --surface-2: #f3f7f1;
  --surface-3: #e9f1e6;
  --border: #dbe7d6;
  --border-strong: #c6d9c0;
  --text: #1c2a18;
  --muted: #5d6d57;
  --accent: var(--brand);
  --accent-hover: var(--brand-2);
  --accent-text: #ffffff;

  /* Brend fondagi matn */
  --on-brand: #f2f7f1;
  --on-brand-muted: rgba(242, 247, 241, 0.82);

  /* Holatlar */
  --danger: #c0392b;
  --danger-soft: #fbeae7;
  --danger-text: #ffffff;
  --ok: #2f8b4b;
  --ok-soft: #e7f5ec;

  /* Mos kelgan belgilar — talab bo'yicha SARIQ */
  --highlight-bg: #ffe14d;
  --highlight-text: #1b2416;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(20, 45, 16, 0.08), 0 2px 8px rgba(20, 45, 16, 0.06);
  --shadow: 0 2px 4px rgba(20, 45, 16, 0.08), 0 14px 34px rgba(20, 45, 16, 0.12);
  --shadow-lg: 0 18px 50px rgba(15, 40, 12, 0.22);
  --ring: 0 0 0 4px rgba(60, 137, 52, 0.28);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #16241a;
    --surface-2: #1c2e1f;
    --surface-3: #223a26;
    --border: #2b4530;
    --border-strong: #38553b;
    --text: #e7f1e3;
    --muted: #9cb396;
    --brand-50: #1a2c1c;
    --brand-100: #223a26;
    --brand-200: #2e4c30;
    --accent-text: #0d1a0c;
    --on-brand: #eef6ea;
    --danger-soft: #3a201d;
    --ok-soft: #1c3324;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 14px 34px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
    --ring: 0 0 0 4px rgba(100, 156, 92, 0.35);
    --highlight-bg: #e9c93f;
    --highlight-text: #1b2416;
  }
}

* {
  box-sizing: border-box;
}

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

/* Butun sahifa foni — logotipdagi yashil rang. Logotip fon bilan
   uyg'unlashib, kattaroq ko'rinadi. */
body {
  min-height: 100vh;
  color: var(--text);
  background-color: var(--brand-2);
  background-image:
    radial-gradient(1100px 620px at 12% -12%, rgba(255, 255, 255, 0.18), transparent 60%),
    radial-gradient(900px 520px at 108% 4%, rgba(193, 157, 81, 0.2), transparent 55%),
    linear-gradient(165deg, #3c8934 0%, #2f7128 52%, #234f1d 100%);
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-color-scheme: dark) {
  body {
    background-color: #0f1f10;
    background-image:
      radial-gradient(1100px 620px at 12% -12%, rgba(100, 156, 92, 0.22), transparent 60%),
      radial-gradient(900px 520px at 108% 4%, rgba(193, 157, 81, 0.12), transparent 55%),
      linear-gradient(165deg, #14261a 0%, #0f1f12 55%, #0a160b 100%);
  }
}

/* ---- sarlavha / logotip ------------------------------------------------ */

.site-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 18px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  text-align: left;
}

.site-header .logo {
  display: block;
  height: 112px;
  width: 112px;
  max-width: none;
  object-fit: cover;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(9, 32, 7, 0.4), 0 0 0 4px rgba(255, 255, 255, 0.14);
  flex: none;
}

/* ---- yashirin kirish imo-ishorasi -------------------------------------- */

/* Logotipni 5 soniya bosib turganda atrofida progress halqasi to'ladi.
   --p = 0..100 (foiz), public/js/panel-gate.js tomonidan boshqariladi. */
.logo-wrap {
  --p: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  flex: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.logo-ring {
  position: absolute;
  inset: -9px;
  width: calc(100% + 18px);
  height: calc(100% + 18px);
  transform: rotate(-90deg);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
}

.logo-ring .ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 5;
}

.logo-ring .ring-fill {
  fill: none;
  stroke: var(--gold);
  stroke-width: 5;
  stroke-linecap: round;
  /* r = 56 -> aylana uzunligi 351.86 */
  stroke-dasharray: 351.86;
  stroke-dashoffset: calc(351.86 - (351.86 * var(--p) / 100));
  filter: drop-shadow(0 0 6px rgba(193, 157, 81, 0.65));
}

.logo-wrap.pressing .logo-ring,
.logo-wrap.unlocking .logo-ring {
  opacity: 1;
}

.logo-wrap.pressing .logo {
  transform: scale(0.96);
}

.logo-wrap .logo {
  transition: transform 0.18s var(--ease);
}

.logo-wrap.unlocking .logo-ring .ring-fill {
  animation: gate-glow 0.9s ease-in-out infinite;
}

@keyframes gate-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(193, 157, 81, 0.5));
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(193, 157, 81, 0.95));
  }
}

.logo-hint {
  display: none;
  margin-top: 8px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #2a2005;
  background: linear-gradient(180deg, #d9b768 0%, #c19d51 100%);
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.logo-hint.show {
  display: inline-block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--on-brand);
  line-height: 1.05;
}

.brand-sub {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--on-brand-muted);
  text-transform: uppercase;
}

/* ---- asosiy konteyner -------------------------------------------------- */

.shell {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 16px 72px;
}

.shell.narrow {
  max-width: 440px;
}

/* ---- qidiruv ----------------------------------------------------------- */

.search-bar {
  position: relative;
  margin: 10px 0 20px;
}

.search-bar input {
  width: 100%;
  padding: 18px 52px 18px 54px;
  font-size: 18px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  outline: none;
  box-shadow: var(--shadow);
  transition: box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}

.search-bar input::placeholder {
  color: var(--muted);
}

.search-bar input:focus {
  border-color: var(--brand-light);
  box-shadow: var(--shadow), var(--ring);
}

.search-bar .search-icon {
  position: absolute;
  top: 50%;
  left: 18px;
  width: 22px;
  height: 22px;
  transform: translateY(-50%);
  color: var(--brand);
  pointer-events: none;
}

.search-bar .clear {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: none;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.search-bar .clear:hover {
  background: var(--brand-100);
  color: var(--brand-deep);
}

.search-bar .clear.show {
  display: block;
}

/* ---- mahsulot ro'yxati ------------------------------------------------- */

.results {
  display: grid;
  gap: 12px;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  padding-left: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-light) 100%);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card .left {
  min-width: 0;
}

/* Kod belgisi (nomi tepasidagi kichik kod) — oq karta fonida aniq ajralib
   turishi uchun oltin rangda. Yashil fon/karta bilan qo'shilib ketmaydi. */
.card .code {
  display: inline-block;
  margin-bottom: 7px;
  padding: 3px 11px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #2a2005;
  background: linear-gradient(180deg, #d9b768 0%, #c19d51 100%);
  border: 1px solid rgba(122, 93, 26, 0.4);
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 2px rgba(122, 93, 26, 0.22);
}

.card .name {
  font-size: 18px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.card .price {
  flex: none;
  font-size: 22px;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: -0.01em;
  color: var(--brand-deep);
  font-variant-numeric: tabular-nums;
}

.card .price .cur {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

@media (prefers-color-scheme: dark) {
  .card .price {
    color: var(--brand-light);
  }
}

/* Mos kelgan belgilar uchun sariq belgi. */
mark {
  padding: 0 2px;
  background: var(--highlight-bg);
  color: var(--highlight-text);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.hint {
  margin: 4px 6px 12px;
  color: var(--on-brand-muted);
  font-size: 14px;
  font-weight: 600;
}

/* ---- panel ------------------------------------------------------------- */

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(6px);
}

.tabs button {
  padding: 9px 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--on-brand-muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.tabs button:hover {
  color: var(--on-brand);
}

.tabs button.active {
  background: var(--surface);
  color: var(--brand-deep);
  box-shadow: var(--shadow-sm);
}

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

.card-box h2 {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}

input::placeholder {
  color: var(--muted);
}

input:focus,
select:focus {
  background: var(--surface);
  border-color: var(--brand-light);
  box-shadow: var(--ring);
}

/* Parol maydonlari va ko'z tugmasi. */
.pw-field {
  position: relative;
}

.pw-field input {
  padding-right: 46px;
}

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.pw-toggle:hover,
.pw-toggle.on {
  color: var(--brand-deep);
  background: var(--brand-100);
}

.price-field {
  position: relative;
}

.price-field input {
  padding-right: 38px;
}

.price-field .suffix {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  font-size: 15px;
  font-weight: 800;
  color: var(--brand);
  pointer-events: none;
}

/* ---- tugmalar ---------------------------------------------------------- */

button.btn {
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-text);
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(47, 113, 40, 0.28);
  transition: transform 0.12s var(--ease), box-shadow 0.15s var(--ease), filter 0.15s var(--ease);
}

button.btn:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(47, 113, 40, 0.34);
}

button.btn:active:not(:disabled) {
  transform: translateY(0);
}

button.btn.ghost {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
  box-shadow: none;
}

button.btn.ghost:hover:not(:disabled) {
  background: var(--brand-100);
  border-color: var(--brand-200);
  filter: none;
}

button.btn.danger {
  color: var(--danger-text);
  background: linear-gradient(180deg, #d24a3b 0%, var(--danger) 100%);
  box-shadow: 0 6px 16px rgba(192, 57, 43, 0.28);
}

button.btn.danger:hover:not(:disabled) {
  box-shadow: 0 10px 22px rgba(192, 57, 43, 0.34);
  filter: brightness(1.05);
}

button.btn.small {
  padding: 7px 12px;
  font-size: 13px;
}

button.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- jadvallar --------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-deep);
  background: var(--brand-50);
}

tbody tr {
  transition: background 0.12s var(--ease);
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.wrap {
  white-space: normal;
  overflow-wrap: anywhere;
}

td .price {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--brand-deep);
}

.updated {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 700;
}

.updated:hover {
  color: var(--brand-deep);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
}

.badge.sudo {
  background: rgba(193, 157, 81, 0.22);
  color: #8a6a1f;
}

.badge.off {
  background: var(--danger-soft);
  color: var(--danger);
}

@media (prefers-color-scheme: dark) {
  .badge.sudo {
    color: var(--gold);
  }
  th {
    color: var(--brand-light);
  }
  td .price {
    color: var(--brand-light);
  }
}

/* Admin jadvalidagi kod — karta belgisi bilan bir xil oltin rang. */
.code-chip {
  display: inline-block;
  padding: 2px 9px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #2a2005;
  background: linear-gradient(180deg, #d9b768 0%, #c19d51 100%);
  border: 1px solid rgba(122, 93, 26, 0.4);
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 2px rgba(122, 93, 26, 0.22);
}

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

/* ---- login ------------------------------------------------------------- */

.login-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  color: var(--brand-deep);
}

.login-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.field {
  margin-bottom: 14px;
}

.alert {
  margin-bottom: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  display: none;
}

.alert.show {
  display: block;
}

.alert.error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(192, 57, 43, 0.28);
}

.alert.success {
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid rgba(47, 139, 75, 0.3);
}

.hidden {
  display: none !important;
}

/* ---- modal ------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 26, 7, 0.6);
  backdrop-filter: blur(3px);
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 680px;
  max-height: 84vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.modal header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--brand-deep);
}

.modal .body {
  padding: 16px 20px 22px;
}

.modal .close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.modal .close:hover {
  color: var(--brand-deep);
  background: var(--brand-100);
}

@media (prefers-color-scheme: dark) {
  .login-title,
  .modal header h3,
  .modal .close:hover {
    color: var(--brand-light);
  }
}

.history-item {
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item .when {
  font-size: 13px;
  color: var(--muted);
}

.history-item .change {
  font-family: var(--mono);
  font-size: 15px;
}

.history-item .change .old {
  color: var(--muted);
  text-decoration: line-through;
}

.history-item .change .arrow {
  color: var(--muted);
  margin: 0 8px;
}

.history-item .change .new {
  color: var(--ok);
  font-weight: 800;
}

/* ---- jonli indikator --------------------------------------------------- */

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--on-brand-muted);
}

.conn .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--on-brand-muted);
}

.conn.live .dot {
  background: #7bf07f;
  box-shadow: 0 0 0 4px rgba(123, 240, 127, 0.28);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(123, 240, 127, 0.28);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(123, 240, 127, 0.12);
  }
}

/* Panel sarlavhasidagi login belgisi oq fonda ham o'qilishi uchun */
.panel-head .badge {
  background: rgba(255, 255, 255, 0.9);
  color: var(--brand-deep);
}

/* ---- moslashuvchan ----------------------------------------------------- */

@media (max-width: 640px) {
  .site-header {
    padding-top: 22px;
  }
  .brand {
    gap: 14px;
  }
  .site-header .logo {
    height: 84px;
    width: 84px;
    border-radius: 20px;
  }
  .logo-wrap {
    width: 84px;
    height: 84px;
  }
  .brand-name {
    font-size: 24px;
  }
  .brand-sub {
    font-size: 12px;
  }
  .card .name {
    font-size: 16px;
  }
  .card .price {
    font-size: 19px;
  }
  .grid-form {
    grid-template-columns: 1fr;
  }
  .panel-head {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
