:root {
  --bg: #080c14;
  --surface: #0d1117;
  --surface2: #161b22;
  --surface3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text2: #8b949e;
  --text3: #484f58;
  --accent: #4f8ef7;
  --accent2: #1f3a6e;
  --green: #3fb950;
  --green2: #1a3a24;
  --amber: #d29922;
  --amber2: #3d2c00;
  --red: #f85149;
  --sidebar-w: 220px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
}

/* ─── SCREEN 1: USER SELECTION ─── */
.screen-users {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #0d1f3c 0%, var(--bg) 70%);
}

.logo-main { text-align: center; margin-bottom: 48px; }
.logo-main .wordmark { font-size: 28px; font-weight: 700; letter-spacing: 10px; color: var(--text); }
.logo-main .tagline { font-size: 11px; color: var(--text2); letter-spacing: 3px; margin-top: 6px; }
.logo-main .dot {
  display: inline-block; width: 8px; height: 8px;
  background: var(--green); border-radius: 50%; margin-right: 8px;
  animation: pulse 2s infinite;
}

@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

.users-label { font-size: 11px; color: var(--text3); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 20px; }

.users-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: 720px;
  width: 100%;
  padding: 0 20px;
}

.user-card {
  width: 130px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  /* Reset button */
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
.user-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--user-color);
  opacity: 0;
  transition: opacity 0.2s;
}
.user-card:hover { border-color: var(--user-color); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.user-card:hover::before { opacity: 1; }

.user-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: white;
  letter-spacing: 1px;
}
.user-name { font-size: 12px; color: var(--text2); }

/* ─── APP LAYOUT ─── */
.app-layout {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-logo {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: white; letter-spacing: 1px;
}
.sidebar-logo .logo-text { font-size: 13px; font-weight: 700; letter-spacing: 4px; line-height: 1.3; }

.sidebar-user {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}
.sidebar-user:hover { background: var(--surface2); }

.su-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.su-info { flex: 1; min-width: 0; }
.su-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role { font-size: 10px; color: var(--text2); }
.su-change { font-size: 10px; color: var(--text3); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section { padding: 6px 16px 4px; font-size: 10px; color: var(--text3); letter-spacing: 2px; text-transform: uppercase; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--text); border-left-color: var(--accent); }

.ni-icon { width: 16px; text-align: center; font-size: 14px; }
.ni-badge {
  margin-left: auto;
  background: var(--accent2);
  color: var(--accent);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-bottom {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
}
.sidebar-bottom .status-dot { display: inline-block; width: 6px; height: 6px; background: var(--green); border-radius: 50%; margin-right: 6px; }

/* ─── MAIN ─── */
.main { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 12px;
  background: var(--surface);
  flex-shrink: 0;
}
.topbar-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); }
.bc-active { color: var(--text); font-weight: 600; }
.bc-sep { color: var(--text3); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  transition: all 0.15s;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex; align-items: center;
  font-family: inherit;
}
.btn:hover { border-color: var(--text2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: #6ba3fa; border-color: #6ba3fa; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ─── DASHBOARD ─── */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub { font-size: 12px; color: var(--text2); }

.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

.offer-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: block;
  text-decoration: none;
  color: inherit;
}
.offer-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }

.oc-ref { font-size: 13px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; }
.oc-date { font-size: 11px; color: var(--text2); margin-bottom: 14px; }
.oc-stats { display: flex; gap: 16px; }
.oc-stat label { font-size: 10px; color: var(--text3); display: block; }
.oc-stat span { font-size: 16px; font-weight: 700; }

.new-offer-card {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  color: var(--text3);
  gap: 8px;
  font-family: inherit;
  font-size: inherit;
  width: 100%;
}
.new-offer-card:hover { border-color: var(--accent); color: var(--accent); }
.noc-icon { font-size: 28px; }
.noc-text { font-size: 12px; letter-spacing: 1px; }

/* ─── MODAL ─── */
.modal {
  position: fixed; inset: 0;
  background: rgba(8,12,20,0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
}
.modal.open { display: flex; }
.modal-panel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 420px;
  max-width: 90vw;
  overflow: hidden;
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--text2); font-size: 20px; line-height: 1; background: none; border: none; color: var(--text2); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.form-group input {
  width: 100%; padding: 8px 12px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px;
  font-family: inherit;
}
.form-group input:focus { outline: none; border-color: var(--accent); }
.form-group input::placeholder { color: var(--text3); }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ─── OFFER DETAIL ─── */
.offer-layout { display: flex; flex: 1; overflow: hidden; }

.pn-panel {
  width: 300px;
  min-width: 300px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

.pn-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.pn-header h3 { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); }

.pn-input-area {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.pn-input-area textarea {
  width: 100%; height: 60px; resize: none;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: 11px;
  padding: 6px; font-family: monospace;
  margin-bottom: 6px;
  display: block;
}
.pn-input-area textarea:focus { outline: none; border-color: var(--accent); }
.pn-input-area .btn { width: 100%; justify-content: center; }

.pn-list { flex: 1; overflow-y: auto; }
.pn-item {
  display: flex; align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  transition: background 0.1s;
}
.pn-item:hover { background: var(--surface2); }
.pi-num { font-size: 10px; color: var(--text3); width: 16px; flex-shrink: 0; }
.pi-pn { flex: 1; font-size: 12px; font-family: monospace; font-weight: 600; }
.pi-qty {
  font-size: 11px; font-weight: 700;
  background: var(--surface3); padding: 2px 8px; border-radius: 4px;
  color: var(--text2); min-width: 28px; text-align: center;
}
.pi-status { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.pi-status.found { background: var(--green); }

.pn-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text2);
  display: flex; justify-content: space-between;
  background: var(--surface2);
  flex-shrink: 0;
}

/* ─── MODULES PANEL ─── */
.modules-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.modules-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modules-header h3 { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); }

.modules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.module-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.module-card::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--module-color);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.module-card:hover { border-color: var(--module-color); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.module-card:hover::after { opacity: 0.04; }

.mc-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--module-color) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--module-color) 30%, transparent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}
.mc-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.mc-desc { font-size: 11px; color: var(--text2); line-height: 1.5; margin-bottom: 16px; }
.mc-action { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--module-color); font-weight: 600; letter-spacing: 0.5px; }
.mc-status { position: absolute; top: 14px; right: 14px; font-size: 10px; padding: 2px 8px; border-radius: 10px; }
.mc-status.ready { background: var(--green2); color: var(--green); }
.mc-status.soon { background: var(--surface3); color: var(--text3); }

/* ─── MODULE DETAIL MODAL ─── */
.module-detail {
  position: fixed; inset: 0;
  background: rgba(8,12,20,0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.module-detail.open { display: flex; }
.md-panel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 500px;
  max-width: 90vw;
  overflow: hidden;
}
.md-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.md-header h2 { font-size: 16px; font-weight: 700; }
.md-close { cursor: pointer; color: var(--text2); font-size: 20px; line-height: 1; background: none; border: none; }
.md-close:hover { color: var(--text); }
.md-body { padding: 24px; }
.upload-zone-big {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}
.upload-zone-big:hover { border-color: var(--accent); }
.uz-icon { font-size: 36px; margin-bottom: 12px; }
.uz-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.uz-sub { font-size: 12px; color: var(--text2); }
.md-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ─── PREVIEW ─── */
.box-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  min-width: 120px;
}
.box-stat label { font-size: 10px; color: var(--text3); letter-spacing: 1px; text-transform: uppercase; display: block; margin-bottom: 4px; }
.box-stat span { font-size: 16px; font-weight: 700; }

.preview-row td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.preview-row:last-child td { border-bottom: none; }
.preview-row:hover td { background: var(--surface3); }

.price-cell { text-align: right; font-family: monospace; font-size: 12px; }
.price-best { background: rgba(63,185,80,0.08); color: var(--green); font-weight: 700; border-radius: 4px; padding: 2px 6px; }
.price-na { color: var(--text3); }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }
