/* ============ TEMA O'ZGARUVCHILARI ============ */
:root {
  --bg: #f6f8fc;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99, 102, 241, 0.10), transparent 60%),
             radial-gradient(1000px 500px at -10% 110%, rgba(37, 99, 235, 0.10), transparent 60%);
  --card: #ffffff;
  --card-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-2: #2563eb;
  --on-primary: #ffffff;
  --danger: #dc2626;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --slate: #64748b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 4px 14px -6px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.22);
  --radius: 14px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
             radial-gradient(1000px 500px at -10% 110%, rgba(37, 99, 235, 0.14), transparent 60%);
  --card: #151f33;
  --card-2: #1b2740;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #263449;
  --primary: #6366f1;
  --primary-2: #3b82f6;
  --on-primary: #ffffff;
  --danger: #ef4444;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --slate: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 14px -6px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.6);
}

/* ============ ASOS ============ */
* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}

/* Yupqa scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 55%, transparent); background-clip: content-box; }

.hidden { display: none !important; }

h1, h2, h3 { margin: 0; line-height: 1.3; }

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

/* ============ ICONLAR ============ */
.ic {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.ic-lg { width: 40px; height: 40px; }
.ic-f { fill: currentColor; stroke: none; }

/* ============ TUGMALAR ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 550;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
  white-space: nowrap;
  min-height: 38px;
}
.btn:hover { background: var(--card-2); border-color: color-mix(in srgb, var(--border) 60%, var(--muted)); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: var(--on-primary);
  box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--primary) 70%, transparent);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-2), var(--primary-2));
  border-color: transparent;
  box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--primary) 80%, transparent);
}

.btn-danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); border-color: transparent; }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--card-2); }

.btn-ic { width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.btn-ic .ic { width: 19px; height: 19px; }

/* Toza yangilash tugmasi (aylana) */
.btn-refresh {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  color: var(--primary);
}
.btn-refresh:hover {
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  border-color: var(--primary);
}
.btn-refresh .ic { width: 19px; height: 19px; }
.btn-refresh.spinning .ic { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-sm { padding: 6px 11px; min-height: 32px; font-size: 13px; }
.btn-sm .ic { width: 15px; height: 15px; }
.btn-lg { padding: 12px 16px; font-size: 15px; }
.btn-block { width: 100%; }

/* ============ FORMLAR ============ */
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* iOS zoom bo'lmasligi uchun 16px */
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }

.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 13px; font-weight: 500; }
.field input, .field textarea { margin-top: 6px; font-weight: 400; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--muted); margin-bottom: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--primary); flex: none; cursor: pointer; }

.form-error {
  color: var(--red);
  font-size: 13.5px;
  min-height: 18px;
  margin-bottom: 4px;
}

/* ============ LOGIN ============ */
.view { min-height: 100vh; }

#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 28px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: pop 0.25s ease;
}
@keyframes pop {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.login-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--primary) 80%, transparent);
}
.login-logo .ic { width: 38px; height: 38px; }

.login-card h1 { font-size: 26px; letter-spacing: -0.02em; margin-bottom: 4px; }
.login-sub { color: var(--muted); margin: 0 0 26px; font-size: 14px; }

#login-form { display: flex; flex-direction: column; gap: 4px; text-align: left; }
#login-form .btn { margin-top: 10px; }

.theme-btn { margin-top: 22px; }

/* Barmoq izi tugmasi (login) */
.fp-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.fp-divider::before, .fp-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-fp {
  width: 100%;
  border-style: dashed;
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 7%, transparent);
}
.btn-fp:hover {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  border-style: solid;
  border-color: var(--primary);
}

/* ============ TOPBAR ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 16.5px; letter-spacing: -0.01em; }
.brand-ic {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--primary) 70%, transparent);
}
.brand-ic .ic { width: 19px; height: 19px; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--slate);
  transition: background 0.2s;
}
.conn-dot.online { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 20%, transparent); }
.conn-dot.offline { background: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 20%, transparent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.4; } }

/* ============ MAIN / STATS ============ */
.main { max-width: 1120px; margin: 0 auto; padding: 22px 22px 60px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-ic {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  color: var(--muted);
}
.stat-ic .ic { width: 20px; height: 20px; }
.stat-card.active .stat-ic { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.stat-card.expiring .stat-ic { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.stat-card.expired .stat-ic { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.stat-card.paused .stat-ic { background: color-mix(in srgb, var(--slate) 16%, transparent); color: var(--slate); }

.stat-num { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

/* ============ TOOLBAR ============ */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.search-box .ic {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.search-box input { padding-left: 38px; }

/* ============ SAYT KARTALARI ============ */
.sites { display: flex; flex-direction: column; gap: 13px; }

.site-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.site-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); box-shadow: var(--shadow-lg); }

.site-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.site-name { display: flex; align-items: center; gap: 10px; min-width: 0; }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}
.status-dot.active { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.status-dot.expiring { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 18%, transparent); }
.status-dot.expired { background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent); }
.status-dot.paused { background: var(--slate); box-shadow: 0 0 0 3px color-mix(in srgb, var(--slate) 18%, transparent); }
.status-dot.unmanaged { background: color-mix(in srgb, var(--muted) 45%, transparent); }

.site-domain {
  font-size: 16.5px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-domain:hover { color: var(--primary); text-decoration: none; }
.site-domain .ic { width: 15px; height: 15px; color: var(--muted); }

.badge {
  font-size: 12px;
  font-weight: 650;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge.active { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.badge.expiring { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); }
.badge.expired { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.badge.paused { background: color-mix(in srgb, var(--slate) 14%, transparent); color: var(--slate); }
.badge.unmanaged { background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); }

.site-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 7px 20px;
  margin: 13px 0;
}
.site-meta > div {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13.5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-meta .ic { width: 15px; height: 15px; color: color-mix(in srgb, var(--muted) 80%, transparent); flex: none; }
.site-meta b { color: var(--text); font-weight: 600; }

.days-slot { display: inline-block; }
.days-soon { color: var(--amber); font-weight: 700; }
.days-over { color: var(--red); font-weight: 700; }
.days-ok { color: var(--green); font-weight: 700; }

.docker-state.ok { color: var(--green); font-weight: 600; }
.docker-state.off { color: var(--red); font-weight: 600; }
.docker-state.warn { color: var(--amber); font-weight: 600; }

.method-tag { flex: none; }
.method-tag.docker { color: var(--primary); }
.method-tag.cmd { color: var(--muted); }

.container-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 7px;
  color: var(--muted);
  white-space: nowrap;
}

.auto-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.auto-tag .ic { width: 12px; height: 12px; }

.site-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.site-secrets {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}
.site-secrets > div { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-secrets .ic { width: 15px; height: 15px; color: color-mix(in srgb, var(--muted) 80%, transparent); flex: none; }
.site-secrets b { color: var(--text); font-weight: 600; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 56px 0;
  font-size: 15px;
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 14, 28, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px 40px;
  z-index: 100;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  padding: 22px;
  margin: auto 0;
  animation: slideup 0.22s ease;
}
@keyframes slideup {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-sm { max-width: 400px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}
.modal-head h3 { font-size: 17px; letter-spacing: -0.01em; }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--card-2); color: var(--text); }
.modal-close .ic { width: 17px; height: 17px; }

.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.spacer { flex: 1; }

.pay-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.5;
}
.pay-info b { color: var(--text); }

.quick-days {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}

/* ============ TARIX ============ */
.hist-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.hist-table th, .hist-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}
.hist-table th { color: var(--muted); font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.hist-table tr:last-child td { border-bottom: none; }

.settings-note { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.modal-hr { border: none; border-top: 1px solid var(--border); margin: 20px 0 16px; }

/* Barmoq izi bo'limi (sozlamalar) */
.bio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 650;
  font-size: 14.5px;
}
.bio-list { display: flex; flex-direction: column; gap: 8px; }
.bio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.bio-item .ic { color: var(--primary); width: 18px; height: 18px; flex: none; }
.bio-item .bio-name { font-weight: 600; font-size: 14px; color: var(--text); }
.bio-item .bio-date { font-size: 12px; color: var(--muted); }
.bio-item .spacer { flex: 1; }
.bio-empty { color: var(--muted); font-size: 13px; }

/* ============ TOAST ============ */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  animation: slidein 0.22s ease;
  max-width: 360px;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }

@keyframes slidein {
  from { transform: translateX(14px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  .main { padding: 14px 12px 50px; }
  .topbar { padding: 10px 12px; }
  .site-meta { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .modal-overlay { padding: 14px 10px 30px; }
}