/* ==========================================================================
   2. LAYOUT SHELL (HEADER + SIDEBAR + WORKSPACE + LOGIN)
   ========================================================================== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Login Page */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.login-card .brand-badge {
  width: 52px;
  height: 52px;
}

.login-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

.login-subtitle {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.btn-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  background: var(--discord);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition);
}
.btn-discord:hover {
  background: var(--discord-hover);
}
.btn-discord:active {
  transform: translateY(1px);
}
.btn-discord svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Top Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(19, 24, 32, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 220px;
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  flex-shrink: 0;
}
.mobile-menu-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.brand-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f59e0b 0%, #c2410c 100%);
  color: #0c0f13;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.25);
  flex-shrink: 0;
}

.pack-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.site-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.header-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-main);
}
.header-user-pill img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}
.header-user-name {
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.players-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  height: 36px;
}
.players-control label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.players-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.stepper-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: var(--transition);
}
.stepper-btn:hover {
  background: var(--accent);
  color: #0c0f13;
}
.players-input {
  width: 36px;
  text-align: center;
  background: transparent;
  border: none;
  font-weight: 700;
  color: var(--accent);
  -moz-appearance: textfield;
}
.players-input::-webkit-outer-spin-button,
.players-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.players-input:focus {
  outline: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  transition: var(--transition);
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}
.btn:active {
  transform: translateY(1px);
}
.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  border-color: #f59e0b;
  color: #0c0f13;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.22);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
  border-color: #fbbf24;
  color: #0c0f13;
}

.btn-emerald {
  background: var(--emerald-soft);
  border-color: rgba(16, 185, 129, 0.38);
  color: #34d399;
}
.btn-emerald:hover {
  background: rgba(16, 185, 129, 0.24);
  border-color: var(--emerald);
}

.btn-accent-soft {
  background: var(--accent-soft);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}
.btn-accent-soft:hover {
  background: rgba(245, 158, 11, 0.24);
  border-color: var(--accent);
}

.btn-danger-soft {
  background: var(--crimson-soft);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}
.btn-danger-soft:hover {
  background: rgba(239, 68, 68, 0.24);
  border-color: var(--crimson);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
}
.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}
.btn-icon.danger:hover {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.5);
  background: var(--crimson-soft);
}
.btn-icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Main 2-column body */
.app-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--header-h));
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  z-index: 30;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
}

.sidebar-group {
  margin-bottom: 18px;
}

.sidebar-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 10px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cat-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-secondary);
  text-align: left;
  transition: var(--transition);
}
.cat-item:hover {
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-main);
}
.cat-item.active {
  background: var(--accent-soft);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--text-main);
}

.cat-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.ok {
  background: var(--emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}
.status-dot.warn {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}
.status-dot.bad {
  background: var(--crimson);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.45);
}

.cat-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-item.active .cat-item-name {
  font-weight: 600;
  color: #fde68a;
}

.cat-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 99px;
  flex-shrink: 0;
}
.cat-badge.ok {
  background: var(--emerald-soft);
  color: #34d399;
}
.cat-badge.warn {
  background: var(--amber-soft);
  color: #fbbf24;
}
.cat-badge.bad {
  background: var(--crimson-soft);
  color: #f87171;
}
.cat-badge.neutral {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Readiness Summary Footer in Sidebar */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel-alt);
}

.readiness-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 7px;
}
.readiness-label {
  color: var(--text-secondary);
  font-weight: 600;
}
.readiness-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--emerald);
}
.readiness-bar {
  height: 7px;
  background: var(--bg-input);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.readiness-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #f59e0b 0%, #10b981 100%);
  transition: width 0.25s ease;
}
.readiness-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 7px;
  line-height: 1.35;
}

/* Workspace */
.workspace {
  flex: 1;
  min-width: 0;
  padding: 22px 26px 60px;
  max-width: 1160px;
  margin: 0 auto;
  width: 100%;
}

.workspace-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.ws-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.ws-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.pill.ok {
  background: var(--emerald-soft);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}
.pill.warn {
  background: var(--amber-soft);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}
.pill.bad {
  background: var(--crimson-soft);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}
.pill.neutral {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
}

.ws-subtitle {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Wiki Info Box */
.wiki-box {
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.55;
}
.wiki-box b, .wiki-box strong {
  color: #7dd3fc;
}

/* Mode Settings Panel */
.settings-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.settings-row + .settings-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.setting-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  min-width: 115px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}
.seg-btn:hover {
  color: var(--text-main);
}
.seg-btn.active {
  background: var(--accent);
  color: #0c0f13;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-main);
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.range-inputs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.range-inputs .field-input {
  width: 96px;
}

.stages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}
.stage-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stage-field-wrap label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.alert-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-top: 12px;
}
.alert-inline.warn {
  background: var(--amber-soft);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
}
.alert-inline.bad {
  background: var(--crimson-soft);
  border: 1px solid rgba(239, 68, 68, 0.38);
  color: #fca5a5;
}
.alert-inline.info {
  background: var(--sky-soft);
  border: 1px solid rgba(56, 189, 248, 0.32);
  color: #bae6fd;
}

/* Action Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.search-box {
  position: relative;
  flex: 1 1 220px;
  max-width: 360px;
}
.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 34px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  transition: var(--transition);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-input);
}
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
